-
Notifications
You must be signed in to change notification settings - Fork 144
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
named themes #440
named themes #440
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.
I don’t like the “scheme”/“theme” distinction. It’s too similar (and I don’t understand what a “scheme” is now by reading this…). Edit: I guess this is suggesting that a “scheme” is specifically a “color scheme” which is part of a “theme”. Saying “color scheme” would be clearer, but if themes are composable, we don’t need to make a distinction.
Also… I want to have composable themes, so that you can compose e.g. a set of colors with a set of fonts.
Thinking out loud for now (I'll work on that tomorrow): If we do composable themes, then dark mode can be a theme again! It should be easy to accept theme to be either a string or an array of strings, and then apply that with the same logic I've already coded. It would probably mean that if you have three themes you will load 3 rollup'd styleshhets, not one that concatenate the three. I'd still want to not use the default style if I specify a theme; but then if the default theme has a name too, I ---
theme: default, comic-sans, solarized
--- or ---
theme:
- default
- comic-sans
- solarized
--- |
The default theme is currently called “auto”, not default. And it doesn’t mean loading multiple bundles. I looked at doing this previously (and decided it wasn’t worth the effort… but I’m fine revisiting), and it just means turning the theme option into an auto-generated stylesheet. So, if you have the default theme: auto then you get the default stylesheet @import url("observablehq:theme-auto.css");
@import url("observablehq:default.css"); but if you change the theme to light theme: light then you get @import url("observablehq:theme-light.css");
@import url("observablehq:default.css"); and if you want multiple themes theme: [comic-sans, solarized] then you get @import url("observablehq:theme-comic-sans.css");
@import url("observablehq:theme-solarized.css");
@import url("observablehq:default.css"); This approach would mean some redundancy in the generated CSS bundles if you use different themes on different pages, but I think that’s totally acceptable as an initial solution (and we could do code-splitting if we wanted to avoid that in the future). |
I guess we also have to decide how you could do a custom theme… like would you say |
Adds a themes project configuration option, which lists all the available themes by name (the name is the key).
A theme is an object with a style property indicating the a local file (typically
docs/custom.css
) to use as the (only) stylesheet for this page.For example, to reference a new solarized theme, create a
docs/solarized.css
stylesheet and set:Themes can be referenced in any page by specifying the theme option in the front-matter:
Any theme that is used on (at least) one page in the project gets built as
_observablehq/{name}.css
with rollup.Some considerations:
docs/style.css
closes #60