Skip to content

Chart: new gestalt-chart package setup #3143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Aug 22, 2023

Conversation

AlbertCarreras
Copy link
Contributor

@AlbertCarreras AlbertCarreras commented Aug 18, 2023

Summary

What changed?

Internal: new gestalt-chart package setup

DOCUMENTATION

When should you create a new gestalt- package instead of adding a new component to the existing gestalt?

Gestalt is a lightweight package with only 2 dependencies: "classnames" and "prop-types". By using the minimal amount of dependencies, we can maintain the size of the bundle small. If a new component requires external packages, it's worth isolating it in a single package so that importing Gestalt in our codebase keeps a small bundle.

When adding a new package, these are the three areas where you must do changes

image

####FIRST: BASIC SETUP

####Gestalt packages

  • create a new folder within /packages following the pattern gestalt-<component_name>

  • create 2 subfolders: /dist and /src

  • create files:

    • /: package.json*, and rollup.config.js*
    • /src: index.js*, .css, .js, and .jsdom.js.
    • /dist: gestalt-<component_name>.js.flow*
  • Use /package/gestalt or/package/gestalt-datepicker files as templates (copy & paste).

image

#####Gestalt configuration

  • Add the new package to the following files
    • .gitignore: Important step so that build files inside /dist do not get pushed to Github.
      image
    • .eslintignore: Important step to prevent getting eslint errors in build files inside /dist.
      image
  • gestalt/package.json: Important step so that your package gets built when running cd ~/gestalt && yarn build as well when you build the Gestalt Docs while developing when running cd ~/gestalt && yarn start.
    image
    • gestalt/package.json: Important step so that Netlify can build your new package when pushed to Github.
      image

####SECOND: DEVELOP YOUR COMPONENT

#####Gestalt Packages

  • Configure the new package//package.json to correctly setup dependencies:
    image
  • Configure the new package//rollup.config.js to correctly build your package:
    image
  • Develop your new component: .js and .css.
    • If your component is using external dependencies (external components), it might come with its own CSS styles.
    • A good approach is to not import the CSS file from the dependency (small bundles) and create a new file that only styles the classnames on the features used in the new component.
    • This approach will help you prevent styling while overriding the imported CSS.
    • The Gestalt library uses CSS modules. If your external component allows injecting your own classnames, use CSS modules. If not, work with global classes; to use global classes, wrap your component with:

image
image

####THIRD: CODE EDITORS & SANDBOXES

Add the new package to all code editors and sandboxes so they can work with your new package

Original datepicker package PR: https://github.com/pinterest/gestalt/pull/913/files#diff-528119d81e5a10738ae49f5e20d333ebc37cea63657eb9069281693e6dae0ad3

@AlbertCarreras AlbertCarreras requested a review from a team as a code owner August 18, 2023 15:27
@AlbertCarreras AlbertCarreras added the minor release Minor release label Aug 18, 2023
@netlify
Copy link

netlify bot commented Aug 18, 2023

Deploy Preview for gestalt ready!

Name Link
🔨 Latest commit 7e64daa
🔍 Latest deploy log https://app.netlify.com/sites/gestalt/deploys/64e4c9187cf33b0008f252de
😎 Deploy Preview https://deploy-preview-3143--gestalt.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

more

more

more

min

more

more
Copy link
Contributor

@rlingineni rlingineni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems Okay!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this file for?

@diyorbek
Copy link
Contributor

diyorbek commented Aug 22, 2023

LGTM 👍

@AlbertCarreras AlbertCarreras changed the title Internal: new gestalt-chart package setup Chart: new gestalt-chart package setup Aug 22, 2023
@AlbertCarreras AlbertCarreras merged commit 30d7f61 into pinterest:master Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor release Minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants