-
Notifications
You must be signed in to change notification settings - Fork 156
feat(global-styles): Create mechanism for global resets & primitives to be shared between components #11182
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
Closed
jkaeser
wants to merge
463
commits into
carbon-design-system:main
from
jkaeser:feat/v2-global-styles-util
Closed
feat(global-styles): Create mechanism for global resets & primitives to be shared between components #11182
jkaeser
wants to merge
463
commits into
carbon-design-system:main
from
jkaeser:feat/v2-global-styles-util
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…panel (carbon-design-system#10739) * fix(ui-shell): adjust header action button * fix(header-global-action): set the panel expanded state * fix(ui-shell): add tooltip-text for initial
* chore(workflows): allow on feat/* * fix(percy): ensure percy runs * chore(react): remove package * chore(e2e): remove react in workflows * fix(react): adding pictogram and removing react e2e * fix(test): installed enzyme * fix(tests): tests succeed * chore(jest): update snapshots * fix(yarn): update lockfile * fix(yarn): updated lockfile * fix(storybook): react wrapper now compiles --------- Co-authored-by: kennylam <[email protected]>
* fix(cwc-v2): fix styles and theme examples * fix(docs): add style info * fix(styles): remove layer tokens from styles * fix(styling): temp layout mixin * fix(ui-shell): missing style and format code * fix(popover): button style extend * fix(overflow): missing class and fix prefixes * fix(code): format everything * fix(combo-box): placeholder padding * fix(data-table): batch actions size * fix(examples): with update theme token info * fix(tile): add emit layout token for all variants * fix(ui-shell): storybook padding * fix(styling-story): test * fix(styling): docs set specific tag --------- Co-authored-by: Anna Wen <[email protected]>
* fix(styling): missing tokens * fix(search): hover * fix(search): format and remove pointer events * fix(data-table): hover * fix(search): expandable size
Co-authored-by: Anna Wen <[email protected]>
Co-authored-by: Ariella Gilmore <[email protected]>
…design-system#10767) * chore(upgrade-cwc-v2): upgrade to latest carbon styles/icons * fix(header-global-action): bring back header action button --------- Co-authored-by: Ariella Gilmore <[email protected]> Co-authored-by: Anna Wen <[email protected]>
Co-authored-by: kennylam <[email protected]>
Closes carbon-design-system#11117 This upgrades Typescript to v5 **New** - {{new thing}} **Changed** - `@carbon/web-components` and `@carbon/ibmdotcom-web-components` upgraded to Typescript 5 **Removed** - {{removed thing}} <!-- React and Web Component deploy previews are enabled by default. --> <!-- To enable additional available deploy previews, apply the following --> <!-- labels for the corresponding package: --> <!-- *** "test: e2e": Codesandbox examples and e2e integration tests --> <!-- *** "package: services": Services --> <!-- *** "package: utilities": Utilities --> <!-- *** "RTL": React / Web Components (RTL) --> <!-- *** "feature flag": React / Web Components (experimental) -->
…at/footer-v2-updates feat(footer): v2 layout updates
…m#11043) * feat(styles): update card-group and video-player styles --------- Co-authored-by: kennylam <[email protected]>
Co-authored-by: kennylam <[email protected]>
…x/video-player-v2-alignment fix(video-player): v2 alignment
…x/v2-carbon-dependencies fix(dependencies): core carbon updates
…onents" This reverts commit 062a358.
This reverts commit 05e00d0.
This was a super interesting concept, and theoretically, by the PR description, makes good sense. In practice IIRC, the styles package was too tangly to make this workable. Still useful as an architecture document, but closing for now for cleanup purposes. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
owner: Innovation Team
used when the engineering work will be done by Hybrid Cloud with DDS engineers as consultants
package: carbon web components
package: styles
Work necessary for the Carbon for IBM.com styles package
package: utilities
Work necessary for the Carbon for IBM.com utilities package
package: web components
Work necessary for the IBM.com Library web components package
prototype
Proof of concept work that should not be merged down
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related Ticket(s)
Closes #10794
Description
This PR creates two new lower-level concepts, which when combined allow components to adopt one or more "global" stylesheets.
Consider the wide variety of components that contain button styles. Instead of re-defining those button styles in each component's own internal stylesheets, we can define those styles in one place and have all components adopt that single stylesheet.
This should reduce the filesize (and therefore bandwidth used/blocking time) of every single component by stripping out large chunks of the CSS. Additionally, since each component class defines it's own stylesheet, moving those duplicated styles to a single stylesheet that can be adopted many times frees up large chunks of system memory.
To prove the efficacy of this approach, I've also implemented this setup into the
button-group
andbutton-group-item
components. To further reduce each component's definition size I've split the suite of styles (button-group.scss
) into individual stylesheets for each component. (button-group.scss
andbutton-group-item.scss
).CarbonBase class
The
CarbonBase
class is intended to exist between the LitElement framework and all carbon components. As of this PR, its only job is to handle the global style adoption, but it could also take on the role of the StableSelector mixin or act as another entry point to all components.CarbonStyles class
The
CarbonStyles
class acts as a global storage point for all the CSS primitives. Each stylesheet can be requested by name using thegetStyleSheets()
method, which will return an array ofCSSStyleSheet
objects.How it all ties together
CarbonStyles
class, which converts the imported CSS strings intoCSSStyleSheet
objects, and stores them on the class instance keyed by name (e.g. "reset").CarbonBase
class that extendsLitElement
. It provides mechanisms for extending elements to attach theCSSStyleSheet
objects to the shadow root'sadoptedStylesheets
._requestCarbonStyles()
method defines which primitives should be adopted, by default requesting reset and type primitives. This method can be overridden by extending classes in the event they need to request additional primitives (e.g. button styles) or they don't need one or more of the default primitives.connectedCallback()
lifecycle method.Changelog
New
CarbonBase
andCarbonStyles
classesChanged
button-group.scss
files into individual component stylesheets