CSS architecture changes#2646
Draft
itsmedavep wants to merge 3 commits into
Draft
Conversation
Initial plumbing for reorganization and style dictionary changes
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This branch changes the CSS architects in four ways:
We had and issue where we were duplicating
:rootand:hoststyles in the package.The result is that the packaged stylesheet drops from about 96.9 kB, and 2
:rootblocks , and 21:hostselectors down to roughly 83.9 kB , a single:rootblock, and 0 `:host' selectors in the package CSS.Additions
Removals
Changes
abstractssplit. On mainelements/abstracts/index.scssis both:That is the core duplication issue. Here I have introduced
elements/abstracts/api.scssas the non-emitting Sass API, and updated a large set of legacy component and element styles to import that instead of theabstractsentry that emitted CSS. The same idea was applied to sizing withsizing-core.scssso Sass values can be reused without repeaditly re-emitting root CSS.src/index.scssforwards both legacy component CSS and web component element CSS. That was why main leaked:hostrules into the CSS package.In this branch
src/index.scssis reduced to the composition of:elements/index.scsscomponents/index.scssutilities/index.scssThat means that the actual web component
styles.component.scssfiles are no longer being forwarded into the package.:rootand:hosttoken outputs from the JSON tokens. That change added generated files like:src/elements/abstracts/custom-props.host.css'src/elements/abstracts/custom-prop.css`
Legacy components still use the
:roottokens files. Web components use the:hostfiles where needed.elements/base/base.cssno longer imports the skeleton/global custom-element files. Those moved intoelements/cfpb-utilities/global.scsswhile the global tokens are grouped inelements/abstracts/tokens.scss.What that provided was a clean conceptual split:
components' = legacy class based CSSelements= web component foundation CSSabstracts` = tokens/foundationsutilities/mixins.scsselements/cfpb-button/mixins.scsselements/cfpb-icon-text/mixin.scssThat was needed because some files were importing CSS emitting only to use a mixin. That is the dependancy that creates duplication.
Bottom line is that change gets us smaller CSS and makes sure that future component additions are less likely to reintroduce the the
:rootduplication or the:hostinclusion in the package. A new WC won't have to rely on the global package accidentally carrying its variables or styles. A new legacy component doesn't have to worry about pulling in a Sass helper that will duplicate tokens. (probably not terribly important since we are not going to be introducing legacy components).It should help with architectural clarity:
This approach replaces accidental coupling of things with being explicit:
:roottokens vs:hosttokensTesting
dist/index.cssbyyarn buildand comparing size to main and then searching for:rootduplication and:hostinclusion.Screenshots
Notes and todos
Checklist
Testing checklist
Browsers
Check the current browser support cutoff list for browsers that are advisable
to prioritize for testing.
Accessibility
Other