0.1.2 • Published 1 year ago

tatyanaa-test-library v0.1.2

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

TSDX React w/ Storybook User Guide

CONFLUENCE PAGE

This TSDX setup is meant for developing React component libraries (not apps!) that can be published to NPM. If you’re looking to build a React-based app, you should use create-react-app, razzle, nextjs, gatsby, or react-static.

If you’re new to TypeScript and React, checkout this handy cheatsheet

Commands

TSDX scaffolds your new library inside /src, and also sets up a Parcel-based playground for it inside /example.

The recommended workflow is to run TSDX in one terminal:

npm start

This builds to /dist and runs the project in watch mode so any edits you save inside src causes a rebuild to /dist.

Then run either Storybook or the example playground:

Storybook

Run inside another terminal:

npm run storybook

This loads the stories from ./stories.

NOTE: Stories should reference the components as if using the library, similar to the example playground. This means importing from the root project directory. This has been aliased in the tsconfig and the storybook webpack config as a helper.

Example

Then run the example inside another:

cd example
npm i # or yarn to install dependencies
npm start # or yarn start

The default example imports and live reloads whatever is in /dist, so if you are seeing an out of date component, make sure TSDX is running in watch mode like we recommend above. No symlinking required, we use Parcel's aliasing.

To do a one-off build, use npm run build or yarn build.

To run tests, use npm test or yarn test.

Configuration

Code quality is set up for you with prettier, husky, and lint-staged. Adjust the respective fields in package.json accordingly.

React Testing Library

No testing libraries setup yet.

Rollup

TSDX uses Rollup as a bundler and generates multiple rollup configs for various module formats and build settings. See Optimizations for details.

TypeScript

tsconfig.json is set up to interpret dom and esnext types, as well as react for jsx. Adjust according to your needs.

Publishing to NPM

We recommend using np.

StoryBook Addons

storybook/addon-essentials → Essential addons → a set of addons that allows for quite seamless development of components (offering docs, views, controls, viewports for different devices, measuring of components dimensions etc)

storybook/addon-a11y' → Accessibility Addon | Storybook: Frontend workshop for UI development - great tool to help us do accessibility checks

storybook-addon-xd-designs' → storybook-addon-xd-designs Addon | Storybook: Frontend workshop for UI development - would allow us to attach mockups

  addons: [
    '@storybook/addon-links',
    '@storybook/addon-essentials',
    '@storybook/addon-a11y',
    'storybook-addon-xd-designs',
  ],