caplink-saas-ui-shared-component-library
v1.21.0
Published
A shared UI component library for React projects from Caplink
Downloads
1,130
Keywords
Readme
caplink-saas-ui-shared-component-library
This project is a shared component library for the Caplink SaaS UI. It is built using React and Storybook.
Installation
- Clone the repository
- Run
npm install
to install the dependencies - Run
npm run storybook
to start the Storybook server
Usage
To use the components in your project, you can install the package from npm:
npm install @caplink/saas-ui-shared-component-library
Then import the components you need:
import { Button } from '@caplink/saas-ui-shared-component-library';
Development
Components
All the components are located in the 'component-library' folder. Each component should be in its own folder, with the component file and any other files it needs (like styles, tests, etc).
An expected component development workflow would be:
- Create a new folder for the component
- Create the component file (e.g. MyComponent.js)
- Create a story file (e.g. MyComponent.stories.js)
- Create a test file (e.g. MyComponent.spec.js)
- Create a style file (e.g. MyComponent.css) (if needed, we use tailwindcss for styles)
- If it's a complex component, create a Cypress test file (e.g. MyComponent.spec.js in the 'cypress' folder)
Folder structure
- All the components are located in the '/component-library' folder.
- Each component should be in its own folder, with the component file and any other files it needs (like styles, tests, etc).
- Cypress tests are located in the 'cypress' folder and should follow the same folder structure as the components.
Storybook
We use Storybook to develop and test the components. To start the Storybook server, run:
npm run sb:dev
npm run sb:build
This will start the Storybook server and open a browser window with the Storybook UI. You can use this to develop and test the components.
This is the gallery of components that we use to develop and test the components. It's also used to generate the documentation for the components, so it's important to keep it up to date and encompassing relevant states and use cases within the stories.
Testing
We use multiple testing libraries to test our components. We use Jest for unit tests and Cypress for more complex integration tests that require a browser.
- All unit tests are located in the same folder as the component they are testing. The file name should be the same as the component file name, but with a '.spec.xxx' suffix.
- All Cypress tests are located in the 'cypress' folder.
Contributing
This is a project for the Caplink SaaS UI team. If you are a member of the team, you can contribute to this project by following the standard Git workflow:
- Create a new branch for your feature or bug fix
- Make your changes
- Push your branch to the remote repository
- Create a pull request
Developing components with tests is a requirement for contributing to this project.