-
-
Notifications
You must be signed in to change notification settings - Fork 850
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
Dark theme experiment, design token thoughts, and theming improvements #381
Comments
Another important thing to call out with the current dark theme approach is that it uses a number of light DOM styles. This is problematic for users who nest themed components inside of their own shadow roots (see #390). This won't be an issue if we can make theming depend solely on design tokens. I think this is the approach @mcjazzyfunky was suggesting early on and would like to acknowledge that. 😄 |
Just a few comments as I have noodled around a little with alternative dark themes. Just in case that your experiment will be successful, the following three minor changes might be useful:
|
To visualize some of the ideas behind this experiment, please find below a desktop-first-and-only protoype of a shoelace theme designer (=> "prototype" as in "don't expect anything to work" 😉). Ideas behind this theme designer:
https://shoelace-theme-designer.vercel.app/ Here is for example a bootstrapish Shoelace light theme. |
Wow @mcjazzyfunky, that looks awesome! 👍👍 |
This is really, really nice. Let's work on #413 (since it will add more core design tokens) and revisit this afterwards. @mcjazzyfunky is this something you'd be interested in contributing to the project as an official theme generator? I could see something like it being hosted at |
@claviska |
Absolutely. I have ideas to expand on it — just feeling out whether you'd be open to sharing it with the community. 🙌 |
+1 for using just the Design Tokens instead of parts, parts are great for specific overrides but other than that they seem limiting :) +1 also for the Theme Generator, which could also be very useful in order to test how flexible Shoelace is in terms of "adapting to a style" or design system, if this is something that matters for the scope of this project of course. Given how flexible and agnostic WCs are, I believe having the ability to use the same components in multiple projects which adopt different Design Systems [by tweaking them in order to resemble the rest of the projects' styles] would be great! |
From my comment here:
I feel pretty strongly about not being able to customize individual components with design tokens. Those are best suited for high-level changes that components can share, but most component-specific customizations should be done with parts. (There's more explanation about this in the comment I linked above.) |
Yeah I see your point, the Bootstrap example you made was pretty clear. Also I've been looking at other WC kits these days (eg. Ionic) and it seems that most of them indeed offer a decent amount of customization via CSS Variables, but not for everything. Because obviously there'd be the need to just create an infinite amount of variables to support any kind of customization, and you'd never be fully satisfied I guess. Parts seem indeed the optimal solution for customizing in detail, it's a pity Constructable Stylesheets are not yet adopted by all browsers. Actually this "issue" made me think about how I'm structuring my apps (since I'd like to build entire apps with a tool like Lit) and I'm thinking about not using Shadow DOM for my own components (unless they're leaf nodes, or part of an UI Kit)! Let's see where it goes :) Thanks! |
@UserGalileo I think it's pretty reasonable to build app-level components without Shadow DOM since you know the general lay of the land in terms of styling and markup structure — with the escape hatch that you can always switch it on if you need a more reusable/encapsulation behavior. |
@jaredcwhite Yep honestly I'm not particularly concerned about styles but more about losing Slots and the fact that I once saw the argument made by Lit's creator that removing it would not be a best practice. But I think it's fair to say that you can remove it when talking about app-level components, and although it's not the same thing I'll experiment using "render props" instead of slots! |
Here's an example that shows why this "dark theme experiment" is so important. We surely all agree that @hanc2006 's new date picker is looking awesome - here's how it looks in light theme: This is how it currently looks with dark theme (the implementation of the date picker has not been finished, the necessary dark theme adjustments have not been implemented yet): And this is how it would look - out of the box, without any special customizations - if this "dark theme experiment" was a success (be aware that the automatically generated dark theme used in the following screenshots is not optimized) [Edit: In case this might be confusing: The images use a background color of |
@claviska If this "dark theme experiment" turns out to be a success, it may be useful to introduce a new custom CSS property Example/* Hack to switch between background colors depending on theme mode */ background: linear-gradient( var(--sl-color-primary-400) calc(100% * (1 - var(--sl-theme-mode))), var(--sl-color-primary-600) calc(100% * (1 - var(--sl-theme-mode))), var(--sl-color-primary-600) calc(100% * var(--sl-theme-mode)) ); |
Here are the upcoming changes to theming scraped from the upcoming changelog: This release improves theming by offering both light and dark themes that can be used autonomously. It also adds a variety of new color primitives and changes the way color tokens are consumed. Previously, color tokens were in hexidecimal format. Now, Shoelace now uses an .example {
/* rgb() is required now */
color: rgb(var(--sl-color-neutral-500));
} This is more verbose than previous versions, but it has the advantage of letting you set the alpha channel of any color token. .example-with-alpha {
/* easily adjust opacity for any color token */
color: rgb(var(--sl-color-neutral-500) / 50%);
} This change applies to all design tokens that implement a color.
Some reiterations and afterthoughts: The "base" theme is now the "light" theme, and the light theme and dark theme can be consumed independently now (previously you had to load the base theme no matter what). Stylesheets are provided both as raw CSS and as importable Lit's The new "inverted" dark mode is pretty slick. If you adhere to the color scale throughout your app, you get a reasonably nice dark theme for your entire app for free — including future components. I expect that the The additional color primitives might seem unnecessary, but they help maintain consistent color usage when you need to stray from semantic palettes. They also make it easier to adapt your theme by overriding You'll notice a new CodePen link attached to each code example. When you click on it in the preview link, the stylesheet will 404 because it's looking for I realize the next release will include more breaking changes. I apologize for that, but I'm confident things are heading in the right direction now in terms of theming. I appreciate your continued patience as I work towards the 2.0.0 stable release! These changes will be available in the 2.0.0-beta.48 release and can be previewed here. |
@claviska Great. Theming is much more flexible now. Thanks. and use With the new version it is almost impossible to create a good-looking contrast-rich theme as you cannot flexibly customize the text color for the buttons and badges. |
These were temporarily removed. Additional design tokens are being added back before this goes out, and something to account for these will be available. |
Is there a plan to add color variables for buttons @claviska I'm doing a plugin to get the the variables from Figma where the variables are always design this way:
Here is where Shoelace "breaks the contract" with buttons and colors for example: .button--standard.button--primary {
background-color: var(--sl-color-primary-600);
border-color: var(--sl-color-primary-600);
color: var(--sl-color-neutral-0);
} This CSS doesn't allow a designer in Figma to change the primary button color from I know you are worried about variable hell but I think to add more variable will just provide flexibility when needed and current users can just ignore them without breaking their current design. We need to add variables like --sl-button-color-primary: var(--sl-color-primary-600);
... |
@carlos-verdes you're really going to love the work that @lindsaym-fa has done for Web Awesome ("Shoelace 3") 😆 |
We already have a dark theme but, based on user feedback, I'd like to experiment a bit more before calling it stable.
Currently, the dark theme uses the same color tokens as the base (light) theme. The idea was that
--sl-color-gray-100
would always be light and--sl-color-gray-900
would always be dark. In other words, the color scale never changes.The problem with this approach is that themes require more than just token changes. Take a look at the current dark theme: https://github.com/shoelace-style/shoelace/blob/next/src/styles/dark.scss
There are many component-specific selectors that become harder to manage as components evolve and new ones are added. Furthermore, third-party components that use the design tokens have to be styled independently.
This experiment will change the context of the color scale for dark themes, effectively reversing the lightness of each color so dark themes can be crafted solely from design token changes. This is a lot like inverting the light theme, but color tokens will be tweaked for better aesthetics.
TL;DR – The goal of this experiment is to produce a dark theme that only modifies color tokens while enabling the dark theme to apply to all components, including those made by third-parties that utilize Shoelace's design tokens.
I also want to use this experiment as a vehicle for exploring design token improvements (see #423) and other general theming improvements (#437, #438).
The text was updated successfully, but these errors were encountered: