|
| 1 | +[](https://github.com/code4rena-dev/components-library/actions/workflows/test-runner.yml) |
| 2 | + |
| 3 | +# Code4rena Components Library |
| 4 | + |
| 5 | +## Using Components in your project |
| 6 | + |
| 7 | +Start by installing the components library in your project: |
| 8 | + |
| 9 | +``` |
| 10 | +npm install @code4rena/components-library |
| 11 | +``` |
| 12 | + |
| 13 | +Next, to ensure that all the components have the appropriate styling, import the library's css file in your application's wrapping Layout or in any page/component wrapping your application where you would normally import global styling. |
| 14 | +``` |
| 15 | +import "@code4rena/components-library/dist/style.css"; |
| 16 | +``` |
| 17 | + |
| 18 | +All the components in this package can be accessed through named imports. For a full list of available components, take a look at our [Storybook](components-library-wine.vercel.app) |
| 19 | + |
| 20 | +``` |
| 21 | +import { Alert } from "@code4rena/components-library"; |
| 22 | +
|
| 23 | +<Alert {...args} /> |
| 24 | +``` |
| 25 | + |
| 26 | +## Run Storybook |
| 27 | +Storybook will run on [http://localhost:6006](http://localhost:6006) |
| 28 | + |
| 29 | +``` |
| 30 | +npm run storybook |
| 31 | +``` |
| 32 | +OR |
| 33 | +``` |
| 34 | +yarn storybook |
| 35 | +``` |
| 36 | + |
| 37 | +### Storybook Actions |
| 38 | +If you want to make use of [Storybook actions](https://storybook.js.org/docs/angular/essentials/actions) for a specific component, please refer to the `Input.stories.tsx` file. The recommendation is to pass the event handler function directly to the Story component as opposed to passing it through _ComponentName.args_. Passing the event handler function through the **args** parameter may not log the event in the `Actions` tab of the Story's dashboard. |
| 39 | + |
| 40 | +## Testing |
| 41 | +For testing, we are using [Jest](https://jestjs.io/docs/getting-started) and [React Testing Library](https://testing-library.com/docs/react-testing-library/intro/). |
| 42 | + |
| 43 | +To maintain the standards, test files should be named `componentName.test.tsx` and be placed inside the component folder for which the test relates to. |
| 44 | + |
| 45 | +To run tests you can use the command below (please ensure all tests are passing before creating your PRs) |
| 46 | +``` |
| 47 | +npm test |
| 48 | +``` |
| 49 | +OR |
| 50 | +``` |
| 51 | +yarn test |
| 52 | +``` |
| 53 | + |
| 54 | +## Publishing to NPM |
| 55 | + |
| 56 | +A GitHub Action has been developed to help automate package releases. All that you will need to do is: |
| 57 | + |
| 58 | +1. Make sure to increase the `version` field in the **package.json** |
| 59 | +2. On the GitHub repo's home page, navigate to the righthand side and click on **Create a new release** |
| 60 | +3. Give the release a `title` and `description` outlining the changes made in the release |
| 61 | +4. Choose/Create a **tag** corresponding to the new version that was added in the package.json in **step 1** |
| 62 | +5. Once the details are filled out, submit the release. You will get taken to a confirmation page. This process will automatically trigger the GitHub action that will publish the package to npm. |
0 commit comments