CSS Wikitext in macro issue

50 views
Skip to first unread message

David Allen

unread,
Dec 21, 2019, 8:06:58 PM12/21/19
to TiddlyWiki
\define color_picker(label,field)
<tr>
<td>
$label$
</td>
<td>
<$edit-text field="$field$" type="number" class="custom_select"/
>
</td>
<td style="background-color: rgb(0,0,0);">
<div style="background-color: rgb({{!!$field$}}, {{!!$field$}}, {{!!$field$}});text-align: center;">{{!!$field$}}
</
div>
</td>
</
tr>
\end

I've finally discovered wikifying CSS, and I think I love it.  I'm trying to make a tiddler that contains some CSS controlling forms and the code above is one of the macros I use.  I'm trying to get a segment of the table to turn the same color (grayscale) as the value in the $field$ parameter.  For some reason, it is not working as I have it typed out here, but it looks (to me) like it should.

Does anyone know if I'm doing something wrong, or a better method of doing so?

A Gloom

unread,
Dec 21, 2019, 8:59:27 PM12/21/19
to TiddlyWiki
the field value transclusion may need a template to apply styling if I'm understanding correctly

have you tried wikitext styling markup?

A Gloom

unread,
Dec 21, 2019, 9:01:32 PM12/21/19
to TiddlyWiki
the field value transclusion may need a template to apply styling if I'm understanding correctly

David Allen

unread,
Dec 21, 2019, 9:03:10 PM12/21/19
to TiddlyWiki
I did and it didn't work

David Allen

unread,
Dec 21, 2019, 9:10:01 PM12/21/19
to TiddlyWiki
Found something that works and lets me use multiple such instances of this macro:

\define color_picker(label,field)
<tr>
<td>
$label$
</td>
<td>
<$edit-text field="$field$" type="number" class="custom_select"/>
</td>
<td>
<style>.style_$field$ {    background-color: rgb({{!!$field$}}, {{!!$field$}}, {{!!$field$}}); padding: 10px;}</style>
<div class="style_$field$"></div>
</td>
</tr>
\end

A Gloom

unread,
Dec 21, 2019, 9:40:22 PM12/21/19
to TiddlyWiki

Found something that works and lets me use multiple such instances of this macro

Nice! *poclets code* >> << : D

Eric Shulman

unread,
Dec 21, 2019, 10:30:56 PM12/21/19
to TiddlyWiki
On Saturday, December 21, 2019 at 5:06:58 PM UTC-8, David Allen wrote:
\define color_picker(label,field)
<tr>
<td>
$label$
</td>
<td>
<$edit-text field="$field$" type="number" class="custom_select"/
>
</td>
<td style="background-color: rgb(0,0,0);">
<div style="background-color: rgb({{!!$field$}}, {{!!$field$}}, {{!!$field$}});text-align: center;">{{!!$field$}}
</
div>
</td>
</
tr>
\end

Wikification does not occur *inside* parameters.  To achieve the results you want, you want to use a macro to construct the entire style="..." attribute value, like this:
\define colorstyle()  background-color: rgb({{!!$field$}}, {{!!$field$}}, {{!!$field$}});text-align: center;

and then, in your output macro, write:
<div style=<<colorstyle>> >{{!!$field$}} </div>

That should work.  Let me know how it goes.

enjoy,
-e

Reply all
Reply to author
Forward
0 new messages