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

feat(scss): Optimized SCSS to remove need to separately load @carbon/styles #1652

Merged
merged 11 commits into from
Sep 5, 2023

Conversation

nstuyvesant
Copy link
Contributor

@nstuyvesant nstuyvesant commented Aug 15, 2023

Problems this solves...

  • Previously, @carbon/charts and the packages for React, Angular, Svelte, and Vue required that @carbon/styles/css/styles.css be loaded IN ADDITION TO the styles for the chart component libraries. This caused the entire stylesheet for @carbon/styles to be loaded including styles for components not used by @carbon/charts increasing download times. It also added extra work to implement @carbon/charts (more moving parts and more documentation).
  • Loading @carbon/styles/css/styles.css also applies a CSS reset which messes up Bootstrap and Material Design's CSS reset. That forces developers who do not want body-level @carbon/styles styling to use the shadow DOM for components.
  • @carbon/styles was only needed for the toolbar and its modal (tabular representation). These are overflow-menu, button, modal, and data-table modules in @carbon/styles that should have been loaded by their corresponding Carbon Charts SCSS components.
  • @carbon/charts SCSS used @import which is deprecated
  • @carbon/import-once was used as a workaround because @import was used instead of @use for network diagram components.
  • There were many cases of @use 'something' as *; which makes it difficult to understand where variables originate.
  • The regular and condensed font CSS custom properties were associated with the chart wrapper which does not include the tooltip and modal dialog for the tabular representation of the data.
  • Some SCSS modules were not getting loaded at all. These turned out to be duplicates of modules that were being loaded from a different folder.
  • SCSS globals appeared in index.scss rather than their own file that could be loaded with @use by other modules.
  • Some SCSS modules loaded other modules they did not use.
  • StackBlitz examples needed to load @carbon/styles and sass (latter to avoid an install prompt by StackBlitz).
  • In general, the SCSS flow was very difficult to follow previously.
  • @carbon/charts-angular exports specified the dist folder for styles.css and styles.min.css but because the dist folder is what's published (rather than the parent), these paths were wrong.

How to test this

Because StackBlitz normally loads styles.css from the latest version of @carbon/charts, please use this StackBlitz example. The file packages/core/dist/styles.css has been copied and pasted into a file in the example then loaded. Please note that the Zoom button is always hidden in StackBlitz examples (not specific to this PR).

@nstuyvesant nstuyvesant requested review from theiliad, Akshat55 and a team as code owners August 15, 2023 21:35
@nstuyvesant nstuyvesant requested review from zvonimirfras and removed request for a team August 15, 2023 21:35
@netlify
Copy link

netlify bot commented Aug 15, 2023

Deploy Preview for carbon-charts-core ready!

Name Link
🔨 Latest commit 262a6ca
🔍 Latest deploy log https://app.netlify.com/sites/carbon-charts-core/deploys/64f0b866dbe59b0009dd926b
😎 Deploy Preview https://deploy-preview-1652--carbon-charts-core.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.

@netlify
Copy link

netlify bot commented Aug 15, 2023

Deploy Preview for carbon-charts-react ready!

Name Link
🔨 Latest commit 262a6ca
🔍 Latest deploy log https://app.netlify.com/sites/carbon-charts-react/deploys/64f0b867d537450008279c7c
😎 Deploy Preview https://deploy-preview-1652--carbon-charts-react.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.

@netlify
Copy link

netlify bot commented Aug 15, 2023

Deploy Preview for carbon-charts-angular ready!

Name Link
🔨 Latest commit 262a6ca
🔍 Latest deploy log https://app.netlify.com/sites/carbon-charts-angular/deploys/64f0b866817ec70008efc6a7
😎 Deploy Preview https://deploy-preview-1652--carbon-charts-angular.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.

Copy link
Member

@theiliad theiliad left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@theiliad theiliad left a comment

Choose a reason for hiding this comment

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

@nstuyvesant something is wrong with the fonts here

before

image

after

image

@nstuyvesant
Copy link
Contributor Author

@nstuyvesant something is wrong with the fonts here

before

image after image

Fixed with latest push.

Copy link
Member

@theiliad theiliad left a comment

Choose a reason for hiding this comment

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

LGTM

@theiliad theiliad merged commit d970944 into carbon-design-system:master Sep 5, 2023
4 checks passed
@theiliad theiliad deleted the scss-optimization branch September 5, 2023 18:24
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.

None yet

2 participants