How to use colours from the palette

47 views
Skip to first unread message

Stephen Kimmel

unread,
Feb 27, 2016, 5:46:44 PM2/27/16
to TiddlyWiki
My goal is to highlight some text with a background colour that changes whenever I select a different palette or change the colours on the palette. In general I've been using the form

@@background-color:yellow; I'm using a yellow background@@

which works just fine but doesn't change colors with the palette change. Since I can retrieve a colour from the palette using the form:

{{$:/palettes/Vanilla##alert-background}}

I tried this but alas it didn't work:

@@background-color:{{$:/palettes/Vanilla##alert-background}}; Retrieving from the data tiddler doesn't work@@

I can also retrieve a colour from the palette using the colour macro in the form: <<colour alert-background>> and that retrieves the actual value but

@@background-color:<<colour alert-background>>; And neither does the colour macro@@

doesn't work either.

Am I missing something obvious? Is there a reasonable workaround?


BJ

unread,
Feb 27, 2016, 6:10:27 PM2/27/16
to tiddl...@googlegroups.com
Hi Stephen,

you could do it this way

\define hilight2(color text)
@@background-color:$color$;$
text$@@
\end
\define hilight(color text)
<$macrocall $name="hilight2" color={{$color$}} text="""$text$"""/>
\end

<<hilight "$:/palettes/Vanilla##alert-
background" """this is some text""">>

all the best

BJ

Hegart Dmishiv

unread,
Feb 27, 2016, 6:12:09 PM2/27/16
to tiddl...@googlegroups.com
Hi Stephen,

How about a <<hilite>> macro, something like this...

\define hilite(text, color)
@@background-color:$color$;&nbsp;$text$&nbsp;@@
\end

I like to put a space before and after highlighted text, so you can really see the background. You could probably fiddle with this, and move $color$ into the macro itself, rather than as a parameter. I learned this trick in Prof. Schneider's {{DesignWrite}} course.

Hope this helps,

Hegart.


PS. @BJ - snap!
Reply all
Reply to author
Forward
0 new messages