-
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
refactor(card): rename mod and refactor some usage of mods and vars #2444
Conversation
File metricsSummaryTotal size: 4.51 MB* Table reports on changes to a package's main file. Other changes can be found in the collapsed Details section below.
Detailscard
* Results are not gzipped or minified. * An ASCII character in UTF-8 is 8 bits or 1 byte. |
var(--spectrum-card-background-color) | ||
--mod-card-preview-background-color, | ||
var( | ||
--mod-card-background-color, |
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.
Should I mark the backwards compatible fallback --mod-card-background-color
as being deprecated here? It was setting the background on the preview elements, while the main card background is set to transparent directly.
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.
I kinda like this hierarchy, reminds me of a font stack. Most specific is a preview-namespaced mod, then the general card mod, then the variable. So I don't mind it as is, but there's also not really a precedent for it in our components as far as I know. Not really an answer, just thoughts 😁
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.
What I was thinking is that ideally it seems like the gallery and quiet variations should be setting --mod-card-background-color: transparent
in the CSS instead of background-color: transparent;
, and then the --mod-card-preview-background-color
would be used to set the background color. That seems to fit with our existing conventions and keeps the general bg color mod available for gallery. That would break any existing usage of --mod-card-background-color
though.
e1fe044
to
cd7e341
Compare
🚀 Deployed on https://pr-2444--spectrum-css.netlify.app |
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.
Looks great. Just a couple questions/thoughts.
@@ -824,21 +842,20 @@ governing permissions and limitations under the License. | |||
var(--spectrum-card-horizontal-preview-padding) | |||
); | |||
background-color: var( | |||
--mod-card-background-color, | |||
var(--spectrum-card-background-color) | |||
--mod-card-preview-background-color, |
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.
Is there a reason we wouldn't include both --mod-card-preview-background-color
and --mod-card-background-color
here?
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.
Yeah, this is tied to the general issue around the mod renaming. Here's a visual to better demonstrate:
--mod-card-preview-background-color: red;
--mod-card-background-color: lightblue;
These are two separate background colors, and the left side defaults to a different grey that I wouldn't expect to also change if changing the main bg color (that changes the right side).
var(--spectrum-card-background-color) | ||
--mod-card-preview-background-color, | ||
var( | ||
--mod-card-background-color, |
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.
I kinda like this hierarchy, reminds me of a font stack. Most specific is a preview-namespaced mod, then the general card mod, then the variable. So I don't mind it as is, but there's also not really a precedent for it in our components as far as I know. Not really an answer, just thoughts 😁
cd7e341
to
942c91c
Compare
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.
Nice updates and I appreciate the linting fixes introduced here too!
942c91c
to
9146756
Compare
9146756
to
bfa2411
Compare
fix(card): rename misnamed instance of background color mod The custom mod property for the background color was named incorrectly in one of the declarations. refactor(card): cleanup mods and vars around use of preview bg The custom properties and mods were not differentiating between the card background and the preview div background used in the quiet, gallery, and horizontal variations. This did not work well with the horizontal variant which has both a card background and a preview background, when some of the mis-named mods were fixed. A few unset custom properties with spectrum prefixed naming also appeared to be intended as mods, and now have mod equivalents: --spectrum-card-background-color-quiet --spectrum-card-background-color-hover-quiet --spectrum-card-content-margin-top-quiet --spectrum-card-minimum-width-quiet - Creates new custom properties for the preview background colors, that were previously being set through changing a mod value. - Renames --spectrum-card-preview-border-width to --spectrum-card-preview-border-width-selected to match with its usage
bfa2411
to
30ef29b
Compare
Description
fix(card): rename misnamed instance of background color mod
The custom mod property for the background color was named incorrectly in one of the declarations.
This mod renaming was made in the reverted PR #2417 , which had some issues with the Horizontal variant. This does an additional bit of refactoring cleanup to address this:
refactor(card): cleanup mods and vars around use of preview bg
The custom properties and mods were not differentiating between the card background and the preview div background used in the quiet, gallery, and horizontal variations. This did not work well with the horizontal variant which has both a card background and a preview background, when some of the mis-named mods were fixed.
A few unset custom properties with spectrum prefixed naming also appeared to be intended as mods, and now have mod equivalents. These did not exist in the repo or in the tokens package, and have been removed/replaced:
--spectrum-card-background-color-quiet
--spectrum-card-background-color-hover-quiet
--spectrum-card-content-margin-top-quiet
--spectrum-card-minimum-width-quiet
This PR creates new custom properties for the preview background colors, that were previously being set through changing a mod value. It also renames
--spectrum-card-preview-border-width
to--spectrum-card-preview-border-width-selected
to match with its usage.A fallback was kept to maintain the use of
--mod-card-background-color
for the quiet variants. The horizontal variant now uses--mod-card-preview-background-color
, as it has both a card background color and a "preview" element background color.How and where has this been tested?
Please tag yourself on the tests you've marked complete to confirm the tests have been run by someone other than the author.
Validation steps
--mod-card-background-color
to a color and it should change the background color (does not in prod). Setting the deprecated fallback--mod-spectrum-card-background-color
should also change it.--mod-card-preview-background-color
should change the preview area bg color for quiet, and horizontal variants--mod-card-preview-background-color-hover
should change the preview area bg color for quiet variantsRegression testing
Validate:
Screenshots
To-do list