-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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: add experimental contextual layout token system #13287
Conversation
✅ Deploy Preview for carbon-components-react ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for carbon-elements ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
|
Thanks for clarifying @janhassel! Makes sense 😄 |
@alisonjoseph Ok, I wrapped |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reviewed on my end and looks good - would just want a last pass / visual review
@alisonjoseph @aagonzales Let me know if you have any questions! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved! Awesome work Jan!!! 🚀 🎉
@alisonjoseph @aagonzales I think one of you still need to approve the changes in percy for all tests to pass |
Implementation of #10619
Closes #10318
Closes #10617
Closes #13423
Contributes to #6202
Contributes to #7704
Contributes to #10616
This PR adds an experimental system for contextual layout tokens. These allow for layout contexts to change specific rendering settings that are applied to all components within a context. At the moment, these settings are
size
anddensity
.The system consists mainly of the sass module, but also offers a convenience component in React which can be used to create a new layout context.
The following example will set both
Button
as well asTextInput
to usesize = lg
The system is backwards compatible and components accepting a
size
prop will still render in the appropriate size. In addition, any component explicitly setting asize
will use that over the layout context's setting:The following example will render Button as
sm
andTextInput
aslg
."Density" is an experimental new layout setting which can be set to
condensed
(defaults tonormal
). It will provide a preferredpadding-inline
value which isspacing-05
fornormal
andspacing-03
forcondensed
.Components can use the sass functions to more easily access the layout context settings:
Components that use non-standard sizes can still participate in layout contexts by locally overriding the tokens. An example can be seen in the
Tag
styles.See the updated
packages/styles/docs/sass.md
document for the full details.In order to apply specific constraints to children components that might differ from their own preference, the
<LayoutConstraint>
utility component can be used. Like<Layout>
all it does is setting class names.An example of this use case is the icon-only content switcher. It uses IconButton under the hood which supports all sizes and defaults to
lg
. The ContentSwitcher though should only supportsm
->lg
and defaults tomd
.This PR includes migration for the following components:
padding-inline
was changing for each step belowlg
)