A design system boilderplate built with React. This project skeleton was created to help people get started with creating their own React component library with:
- written in React with TypeScript
- test with Jest
- exposed with Storybook to help you create and show off your components
- build with Rollup
Features:
To run all the tests (linter, typescript and Jest)
yarn test
Command | Description |
---|---|
linter |
run the linter (ESLint) |
test:jest |
run the jest tests |
tsc |
test the type checking |
yarn build
To run a live-reload Storybook server on your local machine
yarn install
yarn start
Let's say you have another project (test-app
) on your machine that you want to try installing the component library into without having to first publish the component library. In the test-app
directory, you can run:
yarn add ../react-design-system-boilderplate
which will install the local component library as a dependency in test-app
. It'll then appear as a dependency in package.json
like:
...
"dependencies": {
"react-design-system-boilderplate": "file:../react-design-system-boilderplate",
},
...
Your components can then be imported and used in that project.
First, make sure you have an NPM account and are logged into NPM using the npm login
command.
Then update the name
field in package.json
to reflect your NPM package name in your private or public NPM registry. Then run:
yarn publish
Let's say you created a public NPM package called my-component-library
with the TestComponent
component created in this repository.
Usage of the component (after the library installed as a dependency into another project) will be:
import React from 'react;';
import {TestComponent} from 'my-component-library';
const App = () => (
<div className="app-container">
<h1>Hello I'm consuming the component library</h1>
<TestComponent theme="primary" />
</div>
);
export default App;