[TW5] how to make swatch macro more flexible

34 views
Skip to first unread message

Zyb

unread,
Apr 23, 2017, 10:43:07 AM4/23/17
to TiddlyWiki
I’m playing around with palettes and I noticed that the swatches remain blank when the respective palette entry doesn’t contain a hex code but another call of <<colour>>.

Since I am using a system adapted from the Solar Flare palette which works with base colours, I use hex codes only for custom colour styles and reference them with calls (like for example <<colour tz-base1-dark>>) for all existing TW styles in the palette editor. I.e. none of the swatch ‘types’ have a hex code entry and all swatch fields are white which makes the palette preview useless.

For reference, this is $:/snippets/currpalettepreview where the swatches are defined. Can value={{##$colour$}} be changed to do what I want, i.e. resolve the call of <<colour>>?

\define swatchStyle()
background-color: $(swatchColour)$;
\end
\define swatch(colour)
<$set name="swatchColour" value={{##$colour$}}>
<div class="tc-swatch" style=<<swatchStyle>>/>
</$set>
\end
<div class="tc-swatches-horiz">
<<swatch foreground>>
<<swatch background>>
<<swatch muted-foreground>>
<<swatch primary>>
<<swatch page-background>>
<<swatch tab-background>>
<<swatch tiddler-info-background>>
</div>

Thanks! Tyll
Reply all
Reply to author
Forward
0 new messages