This respository serves as a way for me and contributers to learn the nuances of creating a component library.
- clone the repo
- set up NVM (Node version manager) and then run
nvm usewithin the root directory. This will allownvmto look for.nvmrcin the project and use the specified version.- You may not have this version specified in the app. In this case you would need to run
nvm installand then runnvm use
- You may not have this version specified in the app. In this case you would need to run
- in the root directory, run
yarn install - in the root directory, run
yarn storybook-- this should start the local storybook server athttp://localhost:6006/. - run
npm install -g plopto globally install PlopJs - (Optional) If using VS code, grab the Prettier and eslint vscode extensions
- This project uses storybook for local development.
- This Project uses Yarn as a package manager
- Components are written exclusively in Typescript using React as a framework
- Styling is done with StyledComponents
- PlopJs is used to automatically generate component files
- Linting and code formatting are done by eslint and prettier using the airbnb styleguide
- This project uses Husky and Commitlint to enforce commit rules
- This project uses Rollup to compile the library
- TODO: publish package using
npm-publish - TODO: ADD Jest and React Testing Library for testing purposes
detviler-components/
├─ .storybook/
├─ node_modules/
├─ src/
│ ├─ components/
│ │ ├─ Button/ // every component has these 6 files at minimum
│ │ │ ├─ Button.stories.tsx // the *.stories.tsx file contains all stories for storybook
│ │ │ ├─ Button.styles.tsx // the *.styles.tsx file contains all necessary styled components
│ │ │ ├─ Button.tsx // the *.tsx is the main component file
│ │ │ ├─ Button.types.ts // the *.types.ts contains all types and interfaces for the component
│ │ │ ├─ Button.tests.ts // the *.tests.ts contains all tests for the component
│ │ │ ├─ index.ts // the index.ts file exports the component for use
│ │ ├─ Icon/
│ │ ├─ Link
│ │ ├─ Theme/
│ │ │ ├─ themeDefault.js // themeDefault is a default theme that can be used with themeProvider
│ │ │ ├─ ThemeProvider.tsx // ThemeProvider optionally provides the theme for consumers
│ ├─ index.ts // index.ts exports all components
│ ├─ types.ts // types.ts contains all global types
├─ .gitignore
├─ package.json
├─ README.md
├─ tsconfig.json
├─ yarn.lock
For the time being, the master branch will be main. Eventually it would be great to set up husky/commitlint to add automatic versioning and commit message enforcement, but for now we will just have to do things manually. For the time-being, we will:
- branch off of main
- create a branch per feature
- in most cases, a "feature" will be a component
- For example, if we wanted to create an Icon component, our branch would be called
feat/iconand it would be branched off of the latest inmain - An example commit message might be
feat(icon): adds icon directory and file structure
If you're not developing a feature, but simply fixing a bug, you would instead create a branch called something like fix/icon-display-correct-image and a commit message such as fix(icon): updates icon to display correct image
If you're doing something like updating the Readme to document changes, you would instead create a branch called chore/readme-add-icon-documentation and a commit message such as chore(readme): adds icon documentation
- from the root directory, run
plopand type the component name using a capital letter. This will generate all 6 necessary files for the component along with boilerplate for each file. If this does not run successfully, see step 5 of the Installation section.