• Stars
    star
    121
  • Rank 293,924 (Top 6 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 6 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Toptal UI components library

lerna #-frontend-exp-core

This repository is the home for all of Toptal's reusable UI, split up into distinct monorepo packages distributed through NPM:

Contributing

Please read our documentation here

Running storybook

In order to run storybook you need to execute yarn start which will spin up storybook server on http://localhost:9001.

Project commands

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

Adding icons and pictograms

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:

  1. Prepare your SVG:

    • Make sure that it has viewBox attribute specified
    • Make sure that viewBox sizes are 0 0 16 16 and 0 0 24 24 for icon (there should always be two icon variants) and 0 0 64 64 for pictogram (be careful this isn't just a simple value set!)
    • Make sure all paths are expanded and strokes are not used
  2. 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
  3. 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.

Adding new packages

  1. Create a new folder under /packages and add to it:

    • package.json by running lerna add. Specify Toptal as the author and src/index.ts in the main key
    • tsconfig.build.json using this template with paths to the node_modules of any used packages from the /packages directory
    {
      "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.md using 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.
  2. Add the new package to:

    • the paths key in /tsconfig.json
    • the alias key in /.storybook/main.js
    • the imports variable in /.storybook/components/CodeExample/CodeExample.tsx
    • the new record to Dockerfile

Linking with other projects

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.

Link

To link Picasso follow these steps:

In Picasso project directory:

  1. Checkout Picasso project from GitHub
  2. Install Picasso dependencies with yarn install
  3. Build Picasso inside Picasso package folder (./packages/picasso/) with yarn build:package
  4. Create a link with running in the root path yarn symlink (creates all links to Picasso packages and React link)

In your project directory:

  1. Link Picasso and React with yarn link @toptal/picasso react
  2. Start your project and changes in Picasso will be visible in your project!

Unlink

To unlink Picasso follow these steps:

In your project directory:

  1. Unlink Picasso with yarn unlink @toptal/picasso react
  2. Re-install dependencies with yarn install --force

(Optional) In Picasso project directory:

  1. Unlink with yarn symlink:off
  2. Re-install dependencies with yarn install --force

Tree shaking

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:

  1. You run your build in production mode
  2. You are not transforming your ES modules into commonjs during the build process. Usually, it's default behavior of popular babel presets - modules configuration
  3. You have sideEffects prop in your package.json set to false value or don't have it at all

Have a happy tree shaking! :)

More Repositories

1

gitignore.io

Create useful .gitignore files for your project
Swift
8,174
star
2

haste-server

open source pastebin written in node.js
JavaScript
2,885
star
3

keycodes

Easy visualizer for JavaScript KeyCodes
TypeScript
2,153
star
4

chewy

High-level Elasticsearch Ruby framework based on the official elasticsearch-ruby client
Ruby
1,857
star
5

webdevchecklist.com

Web Developer Checklist
HTML
1,802
star
6

gitignore

The largest collection of useful .gitignore templates
1,653
star
7

haste-client

CLI client for haste-server
Ruby
625
star
8

active-job-style-guide

This Background Jobs style guide is a list of best practices working with Ruby background jobs.
466
star
9

crystalball

Regression Test Selection library for your RSpec test suite
Ruby
321
star
10

granite

Business Actions architecture for Rails apps
Ruby
168
star
11

xene

πŸ€– Modern library with simple API to build great conversational bots.
TypeScript
66
star
12

jvm-monitoring-agent

Monitor JVM from within, detect thread blocks and automatically save threads dump
Java
50
star
13

codeowners-checker

Check .github/CODEOWNERS consistency
Ruby
49
star
14

webpack-assets

Webpack Assets for Rails
Ruby
42
star
15

BestPracticesChromeExtension

Web Developer Checklist
JavaScript
37
star
16

component-resolver-webpack

Webpack plugin that simplifies process of components loading
JavaScript
32
star
17

chewy_example

Chewy example application
Ruby
32
star
18

test-distrib

Ruby
25
star
19

license-cop

A nifty script that fetches the licenses for all your third-party libraries
Python
24
star
20

disqus_api

Disqus API for ruby
Ruby
23
star
21

spring-commands-rubocop

RuboCop command for Spring
Ruby
19
star
22

chai-react-suite

JavaScript
16
star
23

archfiend

A basic daemon generator
Ruby
8
star
24

davinci-github-actions

Reusable Github Actions for davinci based applications
JavaScript
8
star
25

jenkins-job-trigger-action

GitHub Action for triggering Jenkins Jobs and wait build result.
Ruby
7
star
26

trixie

CLI tool to fetch secrets in development
Ruby
6
star
27

rspec-any_of

any_of/all_of argument matcher for RSpec
Ruby
5
star
28

eslint-config-toptal

Shared eslint config for Toptal projects
JavaScript
5
star
29

example_granite_application

Example application for Granite framework
Ruby
4
star
30

rack-rake_task

A simple Rack middleware that allows execution of Rake tasks via the HTTP request
Ruby
2
star
31

slack-mass-messenger

Allows the user to send personalized message to multiple Slack users so it appears on Slack as sent by the user themselves.
Python
2
star
32

topcall-release

1
star
33

tracker-api-load-tester

JavaScript
1
star
34

gitignore.io-docs

Gitignore.io documentation
1
star
35

granite-form

Form builder for granite based on ActiveData
Ruby
1
star
36

rails_commander

Programmatical (Ruby) wrapper to Rails' CLI
Ruby
1
star