Skip to content
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

Creating a primer_view_components.css bundle that will ship with the npm package #1316

Merged
merged 4 commits into from
Aug 17, 2022

Conversation

jonrohan
Copy link
Member

@jonrohan jonrohan commented Aug 17, 2022

What

We've talked a few times about the overhead it takes to develop components twice for rails architecture. Once in primer/css and again in primer/view_components. This disconnect can lead to multiple versions and iterations happening in primer/css before any component is actually ready. 1 2 3 4 5 6

This pull aims to mirror what we did for delivering web-components with PVC but for CSS. We worked on this in another PR to see if we could render a SegmentedControl #1315 to add a postcss pipeline and compile the segmented_control.css. Ideally I would like to leave the bundle in this PR empty, and add the component css in my segmented_control branch.

How

Because this is essentially a new build system, we want to be more forward thinking with the code written here and opt for using PostCSS with the preset-env plugin that allows us to write more CSS spec features like, nested selectors, match functions, container queries etc.

  1. 👀 We made a PR for testing with a docs build that has SegmentedControl rendered from the PVC package. What you're seeing on that page is the component rendered with the CSS provided by the bundle.
  2. 👀 We also test published a pre version from this pull request that contains an empty for now css bundle file compiled from the primer.css source.

Currently this runs on the build:css package.json script. Running a postcss-cli command. I intentionally left this pretty simple because I figured we might want to integrate this into rollup or webpack later.

In our github.com production bundle we have a few options:

  1. We could include the compiled css file in our main bundle by adding a @import "@primer/view-components/app/assets/styles/primer_view_components.css" import line. This is most likely what we'll start with.
  2. We could use css modules to load specific bundles for each component dynamically when the component is included on the page. This is more work, but would be worth the reward.

Footnotes

  1. https://github.com/primer/css/pull/2083

  2. https://github.com/primer/css/pull/2174

  3. https://github.com/primer/css/pull/2194

  4. https://github.com/primer/css/pull/2195

  5. https://github.com/primer/css/pull/2202

  6. https://github.com/primer/css/pull/2205

@changeset-bot
Copy link

changeset-bot bot commented Aug 17, 2022

🦋 Changeset detected

Latest commit: c894e3f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/view-components Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@jonrohan jonrohan temporarily deployed to github-pages August 17, 2022 02:27 Inactive
@jonrohan jonrohan marked this pull request as ready for review August 17, 2022 02:46
@jonrohan jonrohan requested a review from a team August 17, 2022 02:46
@jonrohan jonrohan temporarily deployed to github-pages August 17, 2022 02:52 Inactive
@jonrohan jonrohan enabled auto-merge (squash) August 17, 2022 18:26
@jonrohan jonrohan temporarily deployed to github-pages August 17, 2022 18:31 Inactive
@jonrohan jonrohan merged commit 6241f13 into main Aug 17, 2022
@jonrohan jonrohan deleted the build_primer_view_components_css branch August 17, 2022 18:37
@primer-css primer-css mentioned this pull request Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants