|
1 | 1 | [](https://github.com/code4rena-dev/components-library/actions/workflows/test-runner.yml)
|
2 | 2 |
|
3 | 3 | # Code4rena Components Library
|
| 4 | +--- |
4 | 5 |
|
5 | 6 | ## Using Components in your project
|
6 | 7 |
|
| 8 | +### 1. Installing the library |
7 | 9 | Start by installing the components library in your project:
|
8 | 10 |
|
9 | 11 | ```
|
10 | 12 | npm install @code4rena/components-library
|
11 | 13 | ```
|
12 | 14 |
|
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. |
| 15 | +### 2. Component Styling |
| 16 | +Next, to ensure that all the components have the appropriate styling, **import the library's styles** into your application. This can be done in one of two ways: |
| 17 | + |
| 18 | +1. If you have a global CSS/SCSS file, you can import the custom styles using the CSS import rule into that global file. |
| 19 | +``` |
| 20 | +@import "@code4rena/components-library/styles" |
14 | 21 | ```
|
15 |
| -import "@code4rena/components-library/dist/style.css"; |
| 22 | +2. Another option is to import it in any layout/page/component which wraps your entire web application; in doing so, you make sure the styling bubbles down to all pages of the application using the library's components. |
| 23 | +``` |
| 24 | +import "@code4rena/components-library/styles"; |
16 | 25 | ```
|
17 | 26 |
|
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) |
| 27 | +### 3. Importing Components |
| 28 | +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](https://components-library-wine.vercel.app) |
19 | 29 |
|
20 | 30 | ```
|
21 | 31 | import { Alert } from "@code4rena/components-library";
|
22 | 32 |
|
23 | 33 | <Alert {...args} />
|
24 | 34 | ```
|
25 | 35 |
|
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 |
| 36 | +### 4. Typescript Support |
| 37 | +All components in this library have TypeScript support. Types for all complex component props are also named exports available through the `/types` subdirectory (see example below): |
35 | 38 | ```
|
| 39 | +import { ButtonSize, ButtonType, ButtonVariant } from "@code4rena/componenets-library/types"; |
36 | 40 |
|
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 `Button.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 |
| -## Publishing to NPM |
46 |
| - |
47 |
| -A GitHub Action has been developed to help automate package releases. All that you will need to do is: |
48 |
| - |
49 |
| -1. Make sure to increase the `version` field in the **package.json** |
50 |
| -2. On the GitHub repo's home page, navigate to the righthand side and click on **Create a new release** |
51 |
| -3. Give the release a `title` and `description` outlining the changes made in the release |
52 |
| -4. Choose/Create a **tag** corresponding to the new version that was added in the package.json in **step 1** |
53 |
| -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. |
| 41 | +<Button |
| 42 | + label="Sample Button" |
| 43 | + type={ButtonType.BUTTON} |
| 44 | + variant={ButtonVariant.SECONDARY} |
| 45 | + size={ButtonSize.NARROW} |
| 46 | +/> |
| 47 | +``` |
0 commit comments