Intergrate tiddlywiki palette colors and settings to custom CSS properties - #9333
Conversation
✅ Deploy Preview for tiddlywiki-previews ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Confirmed: Leilei332 has already signed the Contributor License Agreement (see contributing.md) |
|
Hi @Leilei332 ... I just saw your latest changes and I do have some thoughts. TW prefixes are there to make the live for users easier. IMO IMO Other IMO the same principle should be used for custom CSS properties. If something should be used by the core it is prefixed. This does not mean, that it is not allowed to be changed by the user. It is only an opinionated default name, that should "go out of the users way" IMO if we have custom CSS properties that are that long as this PR suggests, it will be a horror to use them in more complex CSS formulas. I think eg: IMO it should be I personally would prefer |
📊 Build Size Comparison:
|
| Branch | Size |
|---|---|
| Base (master) | 2448.0 KB |
| PR | 2449.8 KB |
Diff: ⬆️ Increase: +1.8 KB
✅ Change Note Status
All change notes are properly formatted and validated!
📝 $:/changenotes/5.4.0/#9333
Type: feature | Category: developer
Release: 5.4.0
Intergrate Tiddlywiki palette colors and settings to custom CSS properties
🔗 #9333
👥 Contributors: Leilei332
📖 Change Note Guidelines
Change notes help track and communicate changes effectively. See the full documentation for details.
| change-category: developer | ||
| github-links: https://github.com/TiddlyWiki/TiddlyWiki5/pull/9333 | ||
| github-contributors: Leilei332 | ||
|
|
There was a problem hiding this comment.
hmm, Since there is a second documentation tiddler, which shows both variants, I think the release note can only show the new behaviour - Just a thought
| :root { | ||
| <$list filter="[[$:/palettes/Vanilla]indexes[]]"> | ||
| --tpc-<<currentTiddler>>: <$transclude $variable="colour" $mode="inline" name=<<currentTiddler>>/>; | ||
| </$list> |
There was a problem hiding this comment.
I think the rendered output created with the following code looks a bit better, since it avoids the extra newlines.
:root {
<$list filter="[[$:/palettes/Vanilla]indexes[]]">
--tpc-<<currentTiddler>>: <$transclude $variable="colour" $mode="inline" name=<<currentTiddler>>/>;</$list>
| ```css | ||
| /* New way to get a palette color without wikitext */ | ||
| .tag { | ||
| background: var(--tp-color-tag-background); |
There was a problem hiding this comment.
IMO there is a typo --tpc. It should be --tpc-tag-background
| } | ||
| ``` | ||
|
|
||
| See [[Writing stylesheets in vanilla CSS]] and [[Core CSS Variables]] for details. No newline at end of file |
There was a problem hiding this comment.
| See [[Writing stylesheets in vanilla CSS]] and [[Core CSS Variables]] for details. | |
| See: | |
| * [[Writing stylesheets in vanilla CSS]] and [[Core CSS Variables]] for details. | |
| * https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/var |
The previous example actually doesn't work at all
| title: Core CSS Variables | ||
| type: text/vnd.tiddlywiki | ||
|
|
||
| <<.from-version 5.4.0>> Tiddlywiki CSS variable definitions starts with `--tp-*` and `--tpc-*`. They are mainly used to [[Write stylesheets in vanilla CSS|Writing stylesheets in vanilla CSS]]. These prefixes ''are reserved'' for Tiddlywiki, so it should not be used for user defined CSS variables. It is also not recommended to override these core CSS variables. |
There was a problem hiding this comment.
| <<.from-version 5.4.0>> Tiddlywiki CSS variable definitions starts with `--tp-*` and `--tpc-*`. They are mainly used to [[Write stylesheets in vanilla CSS|Writing stylesheets in vanilla CSS]]. These prefixes ''are reserved'' for Tiddlywiki, so it should not be used for user defined CSS variables. It is also not recommended to override these core CSS variables. | |
| <<.from-version 5.4.0>> Tiddlywiki CSS variable definitions starts with `--tp-*` and `--tpc-*`. They are mainly used to [[Write stylesheets in vanilla CSS|Writing stylesheets in vanilla CSS]]. | |
| * These prefixes ''are reserved'' for Tiddlywiki, so it should not be used for user defined CSS variables. | |
| * It is also ''not recommended'' to override these core CSS variables. |
There was a problem hiding this comment.
There also should be some information what --tp and --tpc means. This info even can be duplicated in several places if needed.
| <<.from-version 5.4.0>> Before v5.4.0, theme developers have to mix wikitext syntax with CSS syntax when writing stylesheets to intergrate Tiddlywiki color palettes and theme settings. With the introduction of [[Core CSS Variables]] in v5.4.0, theme developers can intergrate most Tiddlywiki palettes with vanilla CSS. | ||
|
|
||
| ! Getting Tiddlywiki palette colors | ||
| Tiddlywiki's custom properties for colors are prefixed `--tpc-`. Before v5.4.0, theme developers have to use the following wikitext to get a color value of a palette: |
There was a problem hiding this comment.
| Tiddlywiki's custom properties for colors are prefixed `--tpc-`. Before v5.4.0, theme developers have to use the following wikitext to get a color value of a palette: | |
| Tiddlywiki's custom properties for colors are prefixed `--tpc-` (tpc = ''t''w ''p''alette ''c''olour). Before v5.4.0, theme developers have to use the following wikitext to get a color value of a palette: |
|
|
||
| <<.from-version 5.4.0>> Tiddlywiki CSS variable definitions starts with `--tp-*` and `--tpc-*`. They are mainly used to [[Write stylesheets in vanilla CSS|Writing stylesheets in vanilla CSS]]. These prefixes ''are reserved'' for Tiddlywiki, so it should not be used for user defined CSS variables. It is also not recommended to override these core CSS variables. | ||
|
|
||
| Core CSS variables are defined in [[$:/core/stylesheets/custom-properties]]. |
There was a problem hiding this comment.
The tiddler $:/core/stylesheets/custom-properties is not human readable.
Is it possible to use code-body: yes and still use the tiddler properly?
If not IMO linking to it does not really make sense, so the link may be removed.
| } | ||
| ``` | ||
|
|
||
| While using CSS variables in media quert definitions doesn't work at all: |
There was a problem hiding this comment.
IMO typo: media query instead of quert
|
Thanks @Leilei332 |
|
@Leilei332 ... Even if this PR is merged, please have a look at my latest comments. There is a typo in the docs. ... And there seems to be a title-clash. Please check that |
This PR adds a stylesheet to intergrate palette colors and theme settings to CSS custom properties
Compared to using wikitext syntax, using custom CSS properties has these benefits:
var()is more advanced, it supports fallback.TODO