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 https://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".
A new version of reactist is published both on npm and GitHub Package Registry whenever a new release on GitHub is created.
In the GitHub PR that contains your new changes, make sure that you also include the following:
-
Add tests for bugs and new feature
-
Update relevant docs (storybooks, readme)
-
Execute:
npm run validate
and make sure no errors nor warnings are shown
-
Describe your changes in
CHANGELOG.md
-
Bump the version in
package.json
andpackage-lock.json
by running:
npm --no-git-tag-version version <major|minor|patch>
Note that the steps above are also documented in the PR template that you will be prompted with whenever you open a new reactist GitHub PR.
Once your changes have been merged to main
, create a new GitHub release:
-
Visit https://github.com/Doist/reactist/releases/new
-
In the "Choose a tag" dropdown, type the new release version (i.e. vX.Y.Z) and select "Create new tag: vX.Y.Z on publish"
-
In the "Release title" field, type the new release version (i.e. vX.Y.Z)
-
In the "Describe the release" box, paste the same content you added to the
CHANGELOG.md
, but without the title header -
Make sure the "Set as the latest release" checkbox is checked
-
Click "Publish release"
-
Make sure that a new GitHub action is now running (this will automatically perform all the necessary steps to publish the package)
-
Once the action is complete, check https://npmjs.com/package/@doist/reactist and verify that there's a new public release
Finally, be sure to update both todoist-web and twist-web to use the new reactist version you just published.
The storybook hosted on GitHub pages will be automatically updated on each push to main
. Should there be a problem, try running the action manually from the Actions settings.