This project using:
It also features:
- Storybook to help you create and show off your components
- Jest and React Testing Library enabling testing of the components
npm run test
npm run build
To run a live-reload Storybook server on your local machine:
npm run storybook
To export your Storybook as static files:
npm run storybook:export
You can then serve the files under storybook-static
using S3, GitHub pages, Express etc.
npm run generate YourComponentName
This will generate:
/src
/YourComponentName
YourComponentName.tsx
YourComponentName.stories.tsx
YourComponentName.test.tsx
YourComponentName.types.ts
YourComponentName.scss
The default templates for each file can be modified under util/templates
.
Don't forget to add the component to your index.ts
exports if you want the library to export the component!
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:
npm i --save ../wb-ui-kit
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": {
...
"@boosters/wb-ui-kit": "file:../wb-ui-kit",
...
},
...
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.
Push changes to GitHub!
Push your changes to main branch with commit like below:
git commit -m “fix: …”
commit will trigger a patch update (1.0.0 → 1.0.1)
git commit -m “feat: …”
commit will trigger a minor update (1.0.0 → 1.1.0)
git commit -m “BREAKING CHANGE: …”
in the commit body and with any type of commit will trigger a major update (1.0.0 → 2.0.0)
For publish package on npmjs run:
npm publish
Usage of the component (after the library installed as a dependency into another project) will be:
import React from "react";
import { TestComponent } from "@boosters/wb-ui-kit";
const App = () => (
<div className="app-container">
<h1>Hello I'm consuming the component library</h1>
<TestComponent theme="primary" />
</div>
);
export default App;
https://6267ee827524a3004ad88eca-ywrlasoccm.chromatic.com/?path=/story/accordion--default