-
Notifications
You must be signed in to change notification settings - Fork 205
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
chore: make the spectrum-two theme fully functional #4731
Conversation
… into jnjosh/theming-systems
…ctrum-web-components into jnjosh/theming-systems
e082137
to
b80ffc3
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.
Great work! I left a few nit comments and a larger question around lightest
and darkest
artifacts 👍
scripts/spectrum-vars.js
Outdated
@@ -138,6 +138,7 @@ const processTypography = async ( | |||
// TODO: use resolve package to find node_modules | |||
// TODO: we need to revisit whether we need these | |||
const spectrumPaths = [ | |||
// Spectrum 1 | |||
path.resolve( | |||
path.join( | |||
__dirname, |
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.
nit: could we clean up some repetition and avoid using indexes below? For example, instead of relying on the i
values, we could structure the spectrumPaths
as objects with descriptive fields like system
.
const CSSbasePath = path.resolve(path.join(__dirname, '..', 'node_modules', '@spectrum-css'));
const spectrumPaths = [
// Spectrum 1
{ path: path.join(CSSbasePath, 'vars', 'dist'), system: 'spectrum-one' },
// Spectrum 2 (same path as S1)
{ path: path.join(CSSbasePath, 'vars', 'dist'), system: 'spectrum-two' },
// Express
{ path: path.join(CSSbasePath, 'expressvars', 'dist'), system: 'express' }
];
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, this would definitely be nicer!
My high-level approach with this PR was to apply as light a touch as possible, doing just what was necessary to make the new theme work, but it seems worth doing this to leave things in a cleaner state. I'll go ahead and make the change.
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.
Done! I started by applying your suggestion directly, then ended up simplifying a bit more in the process of changing to use import.meta.resolve
to find the @spectrum-css
packages.
scripts/spectrum-vars.js
Outdated
@@ -170,10 +183,19 @@ const foundVars = await findUsedVars(); | |||
|
|||
spectrumPaths.forEach((spectrumPath, i) => { |
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.
this could then look like
spectrumPaths.forEach(({ path, system }) => { ... }
|
||
:host, | ||
:root { | ||
-webkit-tap-highlight-color: rgb(0 0 0 / 0%); |
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 see this is also on the other systems, but why do we need this? 🤔
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.
Before we decide to remove this can we confirm if the tap effect coming up in iOS?
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.
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.
Not that I know of right now but I will try to dig into the glossary. But this shouldn't block the merge :)
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.
This comment is mostly for me to get more context. It is non-blocking.
"development": "./spectrum-two/theme-light.dev.js", | ||
"default": "./spectrum-two/theme-light.js" | ||
}, | ||
"./spectrum-two/theme-lightest-core-tokens.js": { |
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.
AFAIK there is no lightest
theme on S2.
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 was following the lead of the Express system, which also doesn't have lightest
or darkest
themes but nonetheless includes files for loading lightest
and darkest
. These files actually actually just load the light
and dark
values under the hood.
My assumption was that this was done to avoid failing ungracefully in the case where someone populates the system
and color
properties of <sp-theme>
with a non-existent pairing.
My instinct is that a more principled approach would be to rework <sp-theme>
so that you simply get dev mode warnings when trying invalid combinations, rather than using this "facade" approach within each theme...but a) I'm not sure whether any customers of the Express theme might be relying on the status quo; and b) again, my general approach to this PR was to get the spectrum-two
theme working with minimal changes to the code.
I am open to going a different way here, but my instinct remains to take a light touch for now, on the assumption that we'll likely end up making significant changes to the whole theming mechanism in the 1.x => 2.0 transition, and that would be a better time to revisit the approach 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.
This exports are a miss from our side while deprecating lightest
and darkest
theme. We can tackle it in the main PR. Thanks
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.
Understood, and that does make sense. I agree with the "let's keep changes to a minimum" approach for now. It's definitely something we can address later on.
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.
If nothing else, this provides yet another good data point for us to look at, whenever we take an holistic approach to theming, "systems", sp-theme,...
@@ -11,6 +11,8 @@ governing permissions and limitations under the License. | |||
*/ | |||
|
|||
import '../../spectrum-two/theme-light-core-tokens.js'; | |||
import '../../spectrum-two/theme-lightest-core-tokens.js'; |
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.
double check: lightest
and darkest
should not be needed?
@@ -58,7 +58,7 @@ | |||
"lit-html" | |||
], | |||
"dependencies": { | |||
"@lit-labs/observers": "^2.0.0", | |||
"@lit-labs/observers": "^2.0.2", |
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.
might as well go for the latest 2.0.3
version? unless there is a transitive dependency conflict :)
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 only made this change to ensure that all packages within SWC were pulling in the same version of observers
; the others were on 2.0.2
already.
The reason why I went down this path at all in this otherwise-unrelated PR is that the discrepancy was causing yarn link
to fail when linking UEC and SWC for testing purposes; making this change allowed yarn link
to work! 🎉
We could consider bumping everything to the latest version, but that seemed like a truly unrelated change best done in a separate PR.
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 we can create a follow up PR to version bumps all the dependencies. We usually have one planned from dependebot after we merge colors to main. This can stay at the current version only if you wish to!
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.
Thanks for the context. Let us keep this as it is - I was mostly wondering if you had faced other upgrade-related conflicts or difficulties.
scripts/spectrum-vars.js
Outdated
@@ -138,6 +138,7 @@ const processTypography = async ( | |||
// TODO: use resolve package to find node_modules |
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.
nit: on a side note, we could tackle this TODO and consider using resolve
to dynamically locate the node_modules
directory instead of hardcoding the paths below. Not sure if it is very needed, but I think this could help with symlinked packages.
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, I thought about that as well, but opted not to in keeping with my "lightest touch" approach to this PR. Let me know if you feel strongly about making this change now and we can discuss.
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 actually went ahead and took care of this when incorporating the other change you suggested. 🙌
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 see, thanks! 😄 And who knows - maybe it actually will make our future selves happy someday!
Thanks for the thorough review and suggestions, @rubencarvalho! I took care of the nits and commented with my rationale for including the |
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.
Thank you for the quick turn-around! 👍
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'd love to discuss the benefits of supporting non-core styles and lightest/darkest in S2. Both of these things we've marked deprecated in S1/Express and I don't want us to unconsciously promote consumers to use these types in S2 at least. S2 is not yet fully supported either way and I kinda feel okay if someone breaks their system because they were using lightest with S2. We already give dev mode warnings for this so I don't see why we're adding support for this in S2. I might be missing something bt this was basically my thought process while working on the testing-css-bridge-for-s2
branch few months back.
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.
Good PR!
scripts/spectrum-vars.js
Outdated
themes.forEach((theme) => { | ||
if (isExpress && ['lightest', 'darkest'].includes(theme)) return; | ||
if (!isSpectrum1 && ['lightest', 'darkest'].includes(theme)) { |
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.
lightest and darkest will be deprecated in 1.0! Can we include light
and dark
only?
import { Theme } from '../src/Theme.js'; | ||
import '../src/spectrum-two/core.js'; | ||
|
||
Theme.registerThemeFragment('darkest-spectrum-two', 'color', darkStyles); |
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.
darkest will be deprecated in 1.0! Should this be dark
?
import { Theme } from '../src/Theme.js'; | ||
import '../src/spectrum-two/core-tokens.js'; | ||
|
||
Theme.registerThemeFragment('darkest-spectrum-two', 'color', darkStyles); |
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.
darkest will be deprecated in 1.0! Should this be dark?
@@ -25,7 +25,7 @@ import { | |||
import { DARK_MODE } from '@spectrum-web-components/reactive-controllers/src/MatchMedia.js'; | |||
import '@spectrum-web-components/theme/sp-theme.js'; | |||
import '@spectrum-web-components/theme/src/themes.js'; | |||
import '@spectrum-web-components/theme/src/spectrum-two/themes-core-tokens.js'; | |||
import '@spectrum-web-components/theme/src/spectrum-two/themes.js'; |
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.
This needs to be updated in core-tokens.md
also
|
||
:host, | ||
:root { | ||
-webkit-tap-highlight-color: rgb(0 0 0 / 0%); |
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.
Before we decide to remove this can we confirm if the tap effect coming up in iOS?
|
||
:host, | ||
:root { | ||
-webkit-tap-highlight-color: rgb(0 0 0 / 0%); |
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.
Not that I know of right now but I will try to dig into the glossary. But this shouldn't block the merge :)
"development": "./spectrum-two/theme-light.dev.js", | ||
"default": "./spectrum-two/theme-light.js" | ||
}, | ||
"./spectrum-two/theme-lightest-core-tokens.js": { |
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.
This exports are a miss from our side while deprecating lightest
and darkest
theme. We can tackle it in the main PR. Thanks
@@ -58,7 +58,7 @@ | |||
"lit-html" | |||
], | |||
"dependencies": { | |||
"@lit-labs/observers": "^2.0.0", | |||
"@lit-labs/observers": "^2.0.2", |
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 we can create a follow up PR to version bumps all the dependencies. We usually have one planned from dependebot after we merge colors to main. This can stay at the current version only if you wish to!
As for including the non-core (global) tokens in the The rationale is that we want to get customers to As for including Does this make sense? |
Thanks for the explanation! I feel |
Sure, that makes sense to me. My suggestion would be to merge this PR, and then follow up with a new PR to remove |
Sounds great! I think we are all in the same page now! Thanks everyone |
Closing this PR in favor of the cleanly reconstructed #4859 |
Description
The
spectrum-two
theme didn't yet have all of the necessary plumbing intools/styles
andtools/theme
.This PR adds the missing files and updates various build scripts to create a fully functioning
spectrum-two
theme.Note that the
spectrum-two
theme (like thespectrum
andexpress
themes) includes thecore-global
CSS variables to ensure that application views relying on these variables will not break when migrating to thespectrum-two
theme. Per the plan of record, these variables remain deprecated and will be removed in a future major version of SWC.Related issue(s)
Motivation and context
Allow the
spectrum-two
theme to be used and tested.How has this been tested?
Tested in the Storybook theme switcher, in both SWC and the downstream UEC project.