Open source React components made with ❤️ by Doist.
Check out our live demo. It includes all currently implemented components plus a live playground to interact with them in different states.
You can add Reactist to your project by installing it from npm:
npm install @doist/reactist
To import a component within your code:
import { Loading } from '@doist/reactist'
//OR
import Loading from '@doist/reactist/dist/Loading'
You also need to load the CSS file of reactist somewhere in your app. For instance:
<link rel="stylesheet" type="text/css" href="./node_modules/@doist/reactist/styles/Loading.css" />
If you prefer to include static files grab the minified build from the dist folder.
<script src="./node_modules/@doist/reactist/dist/reactist.cjs.production.min.js"></script>
<link rel="stylesheet" type="text/css" href="./node_modules/@doist/reactist/styles/reactist.css" />
You can find our changelog here.
We leverage package.json
's engines
field to specify the node/npm versions to be used while in development. The easiest way to switch quickly is through fnm.
It's worth noting that fnm can automatically switch to a project's specified node version when it encounters a .nvmrc
file. To do so, use the --use-on-cd
flag when generating your shell's config script with fnm env
.
Once fnm is installed, clone the repository. Then, switch to the required node version, and run its setup task:
git clone https://github.com/doist/reactist.git
cd reactist
fnm install
fnm use
npm run setup
The setup task will install dependencies and run various validations (linting, type checking, tests).
We identified two major modes of development for Reactist. First, running an interactive storybook and see the changes you make to a component in an isolated environment. This is especially helpful when developing new components. And second, improving existing components in real-life applications.
The development of new components is streamlined by the ability to generate new component templates using plop:
npm run plop component
This command will prompt you to provide all the information needed to create a new component template. The most important piece of information needed is the component name, which you can provide even as a phrase (e.g. "dropdown select" will generate a DropdownSelect
component template).
The generated source files include the component implementation with sample props and styles, plus a small test file and storybook source files as well.
You also need to export your new component by adding a reference to it in the top-level index file.
For the first development mode run:
npm run storybook
This boots up a development server with hot reloading on http://localhost:6006. You can iterate on the components in the existing stories or add a completely new one.
For the second development mode you can leverage npm start:yalc
. First, make sure you have yalc
installed globally:
npm install -g yalc
Then, in the reactist repository run:
npm run start:yalc
this will publish Reactist to yalc
and watch for changes.
In your host application you can then link to your local Reactist version:
cd ~/your-app
yalc add @doist/reactist
To undo the changes and switch back to the reactist version from npm, do the following:
cd ~/your-app
# restore the original reactist version
yalc remove @doist/reactist
# re-install reactist from npm
npm install
For convenience, you can add a dev:reactist
script in your host application to automate the process of adding and removing the local Reactist version:
{
// ...
scripts: {
// ...
'predev:reactist': 'yalc add @doist/reactist',
'dev:reactist': 'npm run dev', // or whatever your development script is
'postdev:reactist': 'yalc remove @doist/reactist && npm i',
},
}
Then, to develop against Reactist, just run:
npm run dev:reactist
Independent of the development you operate in to produce a new build (e.g. before submitting a PR) run:
npm run build
Note: This will not update the docs. In case you want to update the docs you need to run:
npm run build:storybook
Tests are executed by running:
npm run test
During development you may find it beneficial to continuously execute the tests. This works by running:
npm run test -- --watch
MacOS users might need to upgrade watchman with brew install watchman
when experiencing troubles with the watch mode. See this issue for details: jestjs/jest#1767
Reactist relies on Chromatic to run visual regression tests on our component during the CI step in GitHub.
To enable such tests, just add chromatic: { disableSnapshot: false }
as a story parameter in your stories. Example:
<Canvas>
<Story
name="Main demo"
parameters={{
docs: { source: { type: 'code' } },
chromatic: { disableSnapshot: false },
}}
>
<BannerExamples theme="light" />
</Story>
</Canvas>
We recommend you enable these tests on those Storybook stories that have several different variants of the component under testing. Enabling them on one or two stories per component should be sufficient in most cases (there's no need to enable them on all stories).
When you open a GitHub PR, you'll notice the "UI Review" and "UI Tests" CI steps.
- Clicking on "Details" will bring you to the Chromatic UI (if you don't already have a Chromatic account, please sign-up using your GitHub account).
- Now you can review and accept your changes (or go back and change your code).
- When you're happy with your changes, make sure to mark them as "Approved".
This project uses release-please to automate version management and package publishing.
-
Make your changes using Conventional Commits:
feat:
for new features (minor version bump)fix:
for bug fixes (patch version bump)style:
for code style changesperf:
for performance improvementsrefactor:
for refactoring codetest:
for adding/updating testsbuild:
for build/dependency changesdocs:
for documentation changesci:
for CI changesrevert:
for reverting previous commitsfeat!:
orfix!:
for breaking changes (major version bump)chore:
for maintenance tasks (NOTE: these are not included in the changelog)
-
When commits are pushed to
main
:- Release-please automatically creates/updates a release PR
- The PR includes version bump and changelog updates
- Review the PR and merge when ready
-
After merging the release PR:
- A new GitHub release is automatically created
- A new tag is created
- The
publish
workflow is triggered - The package is published to npm and GitHub Packages
- Storybook documentation is automatically updated
The storybook hosted on GitHub pages will be automatically updated on each push to main
. If there's a problem, try running the action manually from the Actions settings.