Another thought came up as I was fiddling with a Tiddlywiki I’m using to track characters for a story I’m writing. I have a number of fields for various things I want to keep track of. One of the field ideas I had was to use a simple symbol (for example, “✠” or “⟁”) in a field called “affiliation” to designate which faction a character belongs to. Another field gives the character’s location (say, “New York”). On the “New York” tiddler, if I make a table for characters and had the “affiliation” field as one of the cells, would there be a way to format the cell so that the background color changed? It would make the affiliation pop out more. I could do it by hand, but is there a way to do it dynamically, with some sort of comparative statement, for instance if {{!!affiliation}}="⟁" set style="background-color:#FFD700"?
You can use a Dictionary Tiddler to map symbols to specific colors (see: colour palette) and then dynamically apply them using a filter.
Create a new tiddler (e.g., called ColorPalette) with the Content Type set to application/x-tiddler-dictionary. Add your symbol-to-color mapping in the text field of that tiddler:
⟁:red
✠:green
In your HTML table, use the style.* attribute syntax to fetch the color based on the affiliation field:
<td style.backgroundColor={{{ [[ColorPalette]getindex{!!affiliation}] }}}>
{{!!affiliation}}
</td>
1 Like
Perfect!
While applying it and testing it, I noticed one of the characters I was using somehow got changed to a different special character, for some reason. So, something new to figure out, but I’m immensely pleased at how well it worked! Thank you so very much!