-
Notifications
You must be signed in to change notification settings - Fork 171
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
Update Media Object to support new color theme variables #5187
Update Media Object to support new color theme variables #5187
Conversation
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 approach! I think this is fine since this component is deprecated as you said.
} | ||
|
||
&--venue { | ||
@extend %vf-iconed-list-item; | ||
// prettier-ignore | ||
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="90" height="90" viewBox="0 0 90 90.000001"><g transform="translate(-111.967 -929.337)" color="%23000"><path fill="none" stroke-width="4" overflow="visible" enable-background="accumulate" d="M111.967 929.336h90v90h-90z"/><circle r="6.5" cy="24.5" cx="23.5" transform="matrix(1.846 0 0 1.846 113.583 929.105)" fill="' + vf-url-friendly-color($color-mid-dark) + '" stroke-width="2" overflow="visible" enable-background="accumulate"/><circle r="21" cy="45" cx="45" transform="matrix(1.429 0 0 1.429 92.682 910.05)" fill="none" stroke="' + vf-url-friendly-color($color-mid-dark) + '" stroke-width="4.2" stroke-linejoin="round" overflow="visible" enable-background="accumulate"/><path d="M152.967 931.736l8-2.4v15h-8zM160.967 1016.336h-8v-12h8zM198.967 970.336v8h-12v-8zM114.967 978.336v-8h12v8z" overflow="visible" fill="' + vf-url-friendly-color($color-mid-dark) + '" stroke-width="6" enable-background="accumulate"/></g></svg>'); | ||
|
||
.is-dark & { |
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.
Yes, that's the easiest way to deal with legacy components not supporting the CSS variables.
I'd just add support for having is-dark/is-light class name on itself as well:
.is-dark &,
&.is-dark
And similar with is-light
to make sure we can override it to light if needed.
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'm not sure I totally follow, @bartaz - you're saying to add the is-dark
theme class onto the p-media-object__meta-list-item
itself? What would be the scenario in which someone would need to add the theme class directly onto this element?
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.
Yes, the theme class names can be put on any level. So as a simplification for such legacy components I think it's good to at least support 2 "extremes" (setting class on body - which should be the new most common way to do it, or setting it on component itself - which was the old way to do it).
We do it in similar way in icons:
vanilla-framework/scss/_patterns_icons.scss
Lines 373 to 377 in 70b856e
body.is-dark &, | |
&.is-light, // DEPRECATED: use is-dark instead | |
&.is-dark { | |
@include vf-icon-applications($colors--dark-theme--icon); | |
} |
This way, we should be always able to override the parent theme, by setting theme on the component.
For example if there is a mix of is-dark
and is-light
on parent elements (because page is dark, but then there is a light strip, and in this light strip there is media object), if the media object thinks it should be "dark" (because of dark class on body), but is actually on light background, we can set is-light
on it directly, to override it.
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.
Sorry, I guess I'm still misunderstanding.
The way I have it written, a descendent selector is used to implement themed icons:
.is-dark .p-media-object__meta-list-item--date
If I add an additional selector in the way I'm interpreting your comment, this wouldn't really add any useful functionality:
.p-media-object__meta-list-item---date.is-dark
Because there's no reason to add the theme class at this child level. My descendent selector would already handle both the cases of the theme class existing at the body
level or at the component (.p-media-object
or similar) level.
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.
Ah, sorry, my bad. They way I mentioned is supposed to be on component root element level.
You know what, it's a legacy component anyway, likely not used in any dark theme situations. So your approach should be fine. In case we spot a bug with that we will address it properly (likely by updating those icons, or redesigning that).
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.
LGTM, sorry for the confusion.
Done
Please note the code comment at the top of the file: we can no longer use the
vf-url-friendly-color
function for theming the icons, as it cannot interpolate CSS variables during compilation (since they only exist at runtime). Instead, I hard-coded different inline icons with specific colors for light/dark themes (paper will use the light theme colors). I think this works, particularly given this element is intended to be deprecated anyway.Fixes WD-11867
QA
Check if PR is ready for release
If this PR contains Vanilla SCSS code changes, it should contain the following changes to make sure it's ready for the release:
Feature 🎁
,Breaking Change 💣
,Bug 🐛
,Documentation 📝
,Maintenance 🔨
.package.json
should be updated relative to the most recent release, following semver convention: