-
Notifications
You must be signed in to change notification settings - Fork 198
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: further simplify icon markup in t-shirt size component #1070
Conversation
BREAKING CHANGE: .spectrum-FieldButton has been removed, use .spectrum-ActionButton instead
will be overwritten and fixed when https://git.corp.adobe.com/Spectrum/spectrum-dna/pull/458 merged
BREAKING CHANGE: markup now requires spectrum-ActionButton where all uses of spectrum-FieldButton were
docs: add migration guide and sizing examples BREAKING CHANGE: .spectrum-ProgressBar--large renamed to .spectrum-ProgressBar--sizeM, .spectrum-ProgressBar--large renamed to .spectrum-ProgressBar--sizeS is required for previous BREAKING CHANGE: ProgressBar .is-warning renamed to .is-notice, .is-critical renamed to .is-negative
docs: add examples with custom widths
VRT successfully! 🎊 |
Will these icon specific size classes be required after this change? https://github.com/adobe/spectrum-css/blob/tshirt-size-workflow-icon-continue/components/icon/workflow-icons.css#L21-L65 |
No more specific size classes required. |
I think I misstated my question... Good to hear that is wouldn't be required! Would Spectrum CSS still maintain those classes for optional use, going forward? |
@Westbrook yes absolutely; we do want all of the standard icon sizes to be usable. This PR simply changes their sizes contextually where we know what size the icons need to be. We still need to really chew on this and understand if we're being consistent if we go this route; take a look at ProgressBar, it has t-shirt sizing and uses FieldLabel, which also has t-shirt sizing. You must specify the size of the FieldLabel used within the ProgressBar manually. It would be overreach for ProgressBar to change FieldLabel's variables for font size, weight, margin, etc contextually. Given the ProgressBar and FieldLabel issue, does it make sense for Button to reach into Icon and do the same thing? Yes, it's only dimensions, but where do we draw the line? |
I'd less call this "reaching into" a component than defining what scope a component is delivered in, which would lead me to think that a ProgressBar effecting a FieldLabel internal to it would be little different than a Button effecting the Icon within it. In either case, would delivering the internal component at a different size than the external element be considered "Spectrum correct"? If not, I'd hope that the cascade managed this without need of specific classes, this goes the extra mile of reducing the likelihood of breaking changes like we've seen in the move from |
I can definitely see that, but where do we draw the line? Only icons can be contextually sized? I think that's fair, honestly, but need to hear from the rest of the team.
Almost certainly not, which is definitely a good argument for this approach.
My point exactly on the other PR comment adobe/spectrum-web-components#669 (comment); token-driven icon sizing means that consumers aren't on the hook for updating markup when a design decision is made. That said, the
Agreed. I think we're on the right track, but let's be sure to think about the system as a whole when we make changes that introduce a completely new API, as this one does (variable driven icon sizing is API!). |
@jianliao please rebase 🙏 |
VRT successfully! 🎊 |
Spectrum CSS documentation build successfully! 🎉 |
|
||
.spectrum-Icon { | ||
&, | ||
img, |
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.
FYI: Nesting the size of img
and svg
in the same rules as .spectrum-Icon
will likely cause issue in code like:
spectrum-css/components/tooltip/index.css
Lines 137 to 149 in 731aeab
.spectrum-Tooltip-typeIcon { | |
margin-inline-start: calc( | |
var(--spectrum-tooltip-icon-margin-x) - var(--spectrum-tooltip-padding-x) | |
); | |
margin-inline-end: var(--spectrum-tooltip-icon-margin-x); | |
width: var(--spectrum-tooltip-icon-size); | |
height: var(--spectrum-tooltip-icon-size); | |
align-self: flex-start; | |
flex-shrink: 0; | |
/* Adjusts for weird misalignment */ | |
margin-block-start: 1px; | |
} |
Maybe the goal is to ALWAYS use CSS Custom Properties in this sort of context? In that case we'd need to have any such instance updated as part of this PR or prior to an actual release of these changes.
An alternative would be to not directly size the img
and svg
content and set them as:
block-size: 100%;
inline-size: 100%;
Thoughts?
One thing I'll add to the FieldLabel -> ProgressBar discussion here is that I've been thinking of "specifically-sized" sizing, and "auto-sized based on context" sizing. So ProgressBar auto-sizing to the right size for FieldLabel really does make sense to me (as long as the interface for doing so is well encapsulated). CSS variables seem to give the tools to do this, but it might be overly cumbersome to support directly in SpectrumCSS in some contexts. Icons are simple enough that I think it does. |
@pfulton As we're reworking the tooling elsewhere and seem to have a new approach to t-shirt size variables, should this PR be closed? Is there anything else in here we want to maintain? |
Description
The targets that I want to achieve include:
Implementation detail:
--spectrum-icon-user-defined-height
is for component team(spectrum-react, spectrum-webcomponents) to customize the height.--spectrum-icon-tshirt-size-height
will be provided by each t-shirt size component in its size class like.spectrum-ActionButton--sizeL
. See here.--spectrum-icon-default-height
. It is the default value when no user-defined and t-shirt size variable provided. For workflow icon height, it is default as DNA variable--spectrum-alias-workflow-icon-size-m
.spectrum-Icon--sizeS
andspectrum-UIIcon-CornerTriangle100
from workflow icon and ui icon svg element, we need to provide the t-shirt size variable in its wrapper element CSS class like.spectrum-ActionButton--sizeM
. See here. The html markup for an ActionButton would look like:Open issues
To distinguish workflow icon and ui icon, I need to use
spectrum-UIIcon
for ui icon. This is not a new class, but I could not find anywhere we use it. It would be a breaking change.I defined a series of CSS variables that are not from DNA. Not sure where to put them, I just insert them into
components/vars/css/components/spectrum-icon.css
. It is not ideal as this file will be overridden each time we upgrade the DNA.In each component css, we have to define t-shirt size variable unused anywhere in that file. I have to comment out
postcss-dropunusedvars
for this purpose. Need to enhance this postcss plugin to provide a white list maybe?All the new variables name are TBD. For example:
How and where has this been tested?
Screenshots
To-do list