-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Explore to introduce CSS variables from themes and use in workbench #8151
Comments
@bgashler1 what are your plans how to compute the right colors for themes other than our default light and dark themes? Are CSS variables powerful enough to compute proper derived colors from the base editor background color? If we cannot do that with CSS variables, we have to find another solution (LESS?) I guess... |
Using css-variables for color values sounds like a good idea to me. It will help clarify the intend of every color und help us come up with a color system we should use across the workbench. |
@aeschli actually the fact that we cannot use When I filed this issue I was not aware that you cannot compute a color from a CSS variable using CSS. Still interested to hear what Brad has to say (who made this suggestion initially). |
Moving to SASS is a great idea for a variety of reasons, but in this particular instance, it can't actually help us directly. The challenge is that these colors need to be changed at run-time based on the theme users have selected; this is where CSS custom properties shine. Except, @bpasero is right that (for now) it's not easy to compute derived colors. But, there are two possible options to mitigate this: CSS blend modesWe can still use the CSS custom property base colors. Then we can apply CSS blending modes like CSS Level 4 color-mod()CSS Level 4 colors will fix the problem with not being able to derive colors by introducing While I'm not sure if this is currently supported in Chromium, we can use the css-next library, which is comparatively as fast as libsass they say and lets you use CSS 4 syntax today in all browsers. Odds are that we will be able to pull this dependency out soon since W3C is working on standardizing this right now. |
@bgashler1 I am assuming that we can push this out to the future and we are not blocked currently. |
@bpasero I wouldn't say we're blocked. The only side-effect of not doing this is that in any other theme but the dark and light, I can't tell what color the editor background is, so our box shadow trick that acts as a gradient mask over text looks more like a shadow. |
On cssRules.push(`:root { --monaco-editor-background: ${background}; }`);
cssRules.push(`:root { --monaco-editor-background-light: ${lighten(background, 20%)}; }`);
cssRules.push(`:root { --monaco-editor-background-dark: ${darken(background, 20%)}; }`);
function lighten(hex, percent) {...}
function darken(hex, percent) {...} This would save relying on CSS 4. |
Yes, that was my idea as well. |
We agreed in the UX meeting today to remove the mix-blend-mode and instead use rgba colors to avoid issues with anti-aliasing and other color side-effects that we cannot otherwise work around. |
Sounds good, I will move this to the backlog once we decide how to proceed with general workbench theming. |
Any plans on letting the user use CSS for setting icons (like what Atom does)? |
I just had an idea related to how we can use the variables approach that @bpasero mentioned above without having to rely in JavaScript to do color adjustments. We can use something like this...
This is by no means a substitute for true color transforms enabled by SASS or JavaScript (because it only lets you overlay and not truly lighten or darken). But it's a random idea I had. |
This color formula also can come in handy as a mixin for SCSS to determine the color that can be used over another color with the greatest transparency possible to equate to a desired color when overlayed. |
We decided to not go with CSS variables for now. |
It would be useful if we could introduce CSS variables to the workbench from the selected theme so that we can start using the colors in other areas of the workbench.
A quick hack in https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/services/themes/electron-browser/themeService.ts#L361 with
shows that I am able to pick up the color easily:
@aeschli any objections to introduce variables on
:root
for the colors defined in themes?The text was updated successfully, but these errors were encountered: