Overview • Getting Started • Architecture • Guidelines • Testing
We use the best tools to improve our workflow, allowing us to create an awesome library of components!
- ReactJs v16
- Type checking with PropTypes
- styled-components for styling components and application
- Compiling of modern JavaScript with Babel and bundling with Webpack
- Jest and Testing library for unit/ui testing
- Automated Git hooks with Husky
- Code linting using Eslint
- Code formatter using Prettier
- Developing isolated UI components with Storybook
To get started you need to meet the prerequisites, and then follow the installation instructions.
Figma file: https://www.figma.com/file/IGr2xoqcZX91CU7CDr4ZsI
For more info on configuring your design tokens file, visit "How to configure design tokens with Figma API"
You can clone our Git repository:
$ git clone [email protected]:klaufel/pattern-library-skeleton.git
Hooking it up is as easy as running:
$ npm run install
This command will install all the required dependencies. Please note that npm install
is only required on your first start, or in case of updated dependencies.
$ npm run storybook
$ npm run tokens
Based on the Atomic Design principles, a methodology for creating design systems, there are five distinct levels of components:
- Atomic Design component structure:
- Atoms
- Molecules
- Organism
- Templates
- Pages
When we use a UI library, the highest abstraction of components that we expose would be an organism
. The rest of the template
and page
components are built within the application that imports the library.
└── src
├── components
│ ├── atoms
│ ├── molecules
│ ├── organism
│ └── pages *
├── docs
├── figma-tokens
├── styles
└── index.js (entry point)
src
: The place where we put our application source code -components
Add your components here! This folder is divided from Atomic Design principles.docs
Our documentation as stories for the design system.figma-tokens
Directory containing functions to generate figma design tokens with API.styles
Directory to add global styles and theme to build components.index.js
Entry point, import all components and export to generate package to use in project as a dependency.
└── MyComponent
├── __stories__
│ └── MyComponent.stories.{js|mdx}
├── __tests__
│ ├── __snapshots__
│ │ └── MyComponent.test.js.snap
│ └── MyComponent.test.js
├── MyComponent.styles.js
└── index.js
- mycomponent: Directory containing our component.
__stories__
: Directory containing the stories for Storybook.MyComponent.stories.js
: File containing the component stories.
__tests__
: Directory containing the tests for Jest.__snapshots__
: Directory containing the autogenerated Jest Snapshots.MyComponent.test.js.snap
: Autogenerated Snapshot file.
MyComponent.test.js
: File containing the component tests.
MyComponent.styles.js
: File containing the component styles (styled-components / CSS-in-JS).index.js
: File containing the React component, HTML or other imports from ui-library.
$ npm run lint
Find problems in your code (js)
$ npm run prettier:check
Find format problems in your code.
$ npm run prettier:write
Fix format problems in your code.
Jest, a delightful javascript testing framework and Testing Library build on top of DOM testing library by adding APIs for working with React components.
$ npm run test
Will perform your unit testing.
$ npm run test:update
Will perform your unit testing and update snapshots.
$ npm run test:watch
Will perform your unit testing and watchers tests.
$ npm run test:coverage
Will perform your unit testing and show coverage.
$ npm run test:coverage-web
Will perform your unit testing, show coverage, and open the report in your default browser.