This repository is the home for all of Toptal's reusable UI, split up into distinct monorepo packages distributed through NPM:
- @toptal/picasso - core UI building blocks
- @toptal/picasso-charts - reusable charts, based on
recharts - @toptal/picasso-forms - a form solution, based on
react-final-form - @toptal/picasso-codemod - scripts that help developers migrate to the latest version
- @toptal/picasso-shared - shared utilities between the packages
Please read our documentation here
In order to run storybook you need to execute yarn start which will spin up storybook server on http://localhost:9001.
| Command | Description |
|---|---|
| build:package | Build the packages |
| build:storybook | Build Storybook as static website |
| commit | Interactive conventional commits |
| generate:component | Generate a new component template |
| generate:example | Generate a new component component code example |
| generate:svg-components | Generate JSX components from SVGs |
| generate:icons | Generate JSX components from SVGs (only icons) |
| generate:pictograms | Generate JSX components from SVGs (only pictograms) |
| happo | Run Happo locally and generate report on happo.io |
| happo:storybook | Run Happo for Storybook on CI |
| lint | Lint all files |
| start | Start storybook instance and inspect components |
| test | Run jest and cypress tests |
| test:integration | Run cypress tests |
| test:integration:open | Run cypress in development mode |
| test:unit | Run unit tests |
| test:unit -u | Update jest snapshots |
| test:unit:watch | Run unit tests in watch mode |
| typecheck | Validate typescript compilation |
In Picasso, we keep icons and pictograms in svg format and transform them into React components to make usage in React projects easier. This transformation is processed by the svgr tool.
Pictograms are stored in a separate package due to their size and use cases.
To add a new icon to @toptal/picasso or pictogram to @toptal/picasso-pictograms please follow these steps:
-
Prepare your SVG:
- Make sure that it has
viewBoxattribute specified - Make sure that
viewBoxsize is0 0 16 16for icon and0 0 64 64for pictogram (be careful this isn't just a simple value set!) - Make sure all paths are expanded and strokes are not used
- Make sure that it has
-
Add your SVG file(s) to the Picasso project:
packages/picasso/src/Icon/svg/[your_icon_name].svg # icons packages/picasso-pictograms/src/Pictograms/svg/[your_pictogram_name].svg # pictograms
-
Run the command
yarn generate:svg-components # runs generation for icons and pictograms yarn generate:icons # generates icons yarn generate:pictograms # generates pictograms
This command will prepare corresponding react components and add export statements index files.
After Picasso will be released with your changes you can start using your icons and pictograms as described in the Icons section and Pictograms section.
-
Create a new folder under
/packagesand add to it:package.jsonby runninglerna add. SpecifyToptalas the author andsrc/index.tsin themainkeytsconfig.build.jsonusing this template with paths to thenode_modulesof any used packages from the/packagesdirectory
{ "extends": "../../tsconfig.build.json", "compilerOptions": { "outDir": "./build", "paths": { "@toptal/picasso/*": ["node_modules/@toptal/picasso/src/*"], "@toptal/picasso": ["node_modules/@toptal/picasso/src/index"] } }, "include": ["./src/**/*"], "exclude": [ "**/*.example.jsx", "**/*.example.tsx", "**/test.jsx", "**/test.tsx" ] }CHANGELOG.mdusing this template (All notable changes to the package will be documented in this file automatically)
# Change Log All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
-
Add the new package to:
- the
pathskey in/tsconfig.json - the
aliaskey in/.storybook/main.js - the
importsvariable in/.storybook/components/CodeExample/CodeExample.tsx - the new record to Dockerfile
- the
In order to develop or debug Picasso in parallel with your project without the need to publish new Picasso versions, you need to link Picasso to your project. And once finished unlink it.
You will probably notice that linking process links @toptal/picasso and react. It is due to React restriction of only once instance used in the project [1] [2], so we link to Picasso's react version.
To link Picasso follow these steps:
In Picasso project directory:
- Checkout Picasso project from GitHub
- Install Picasso dependencies with
yarn install - Build Picasso inside Picasso package folder (
./packages/picasso/) withyarn build:package - Create a link with running in the root path
yarn symlink(creates all links to Picasso packages and React link)
In your project directory:
- Link Picasso and React with
yarn link @toptal/picasso react - Start your project and changes in Picasso will be visible in your project!
To unlink Picasso follow these steps:
In your project directory:
- Unlink Picasso with
yarn unlink @toptal/picasso react - Re-install dependencies with
yarn install --force
(Optional) In Picasso project directory:
- Unlink with
yarn symlink:off - Re-install dependencies with
yarn install --force
If you use davinci-engine to manage your application - tree shaking works by default when you build your project in the production mode.
In other cases when you use custom webpack build configuration you should check these three things to make sure you will have Picasso tree-shaked:
- You run your build in
productionmode - You are not transforming your ES modules into
commonjsduring the build process. Usually, it's default behavior of popular babel presets - modules configuration - You have
sideEffectsprop in yourpackage.jsonset tofalsevalue or don't have it at all
Have a happy tree shaking! :)
