I am trying to liven up a custom button on each tiddler toolbar to have a colour dependent on an integer value [ 1 to 100 ] stored in a field on the tiddler.
I am copying the very cool feature in the Journal tool icon where a macro call inside the SVG file is parsed by Tiddlywiki and ends up substituing the integer value returned by the macro before the SVG is parsed by the browser ( that’s how the Journal icon displays the day of the month )
RatingSVG is the name of the macro - returns value 1 to 100, here the number will appear within the icon when it is displayed as a button.
Here is the SVG - the text statement and call to RatingSVG are very near the end of this script.
<svg width="22pt" height="22pt" class="tc-image-bts-phone-landscape-fill tc-image-button" viewBox="0 0 16 16"><path
d="m 2,12.5 c -1.1045695,0 -2,-0.895431 -2,-2 v -6 c 0,-1.1045695 0.8954305,-2 2,-2 h 12 c 1.104569,0 2,0.8954305 2,2 v 6 c 0,1.104569 -0.895431,2 -2,2 z"
id="path4120"
sodipodi:nodetypes="sssssssss"
style="fill:#206ee1; fill-opacity:0.3" /><text class="tc-fill-background" font-family="Helvetica" font-size="8" font-weight="bold" ><tspan x="8" y="10" text-anchor="middle"><<RatingSVG>></tspan></text></svg>
That works fine! The button is displayed as an icon with an integer value displayed on the button.
What I would like to do now is to play around with altering the colour of the button according to the value of the rating [ 1 to 100 ] so I could for instance replace
style="fill:#206ee1 ..."
With
style="fill:hsl(<<RatingSVG>>, 100%, 50%) ..."
However the macro does not seem to be evaluated when it is ‘called’ from with quotes, when I use my browsers developer tools to view the final parsed SVG I still see the macro name-call rather than the integer value expected to be returned from that call.
Any ideas how to successfully inject macro returned values inside quotes in this situation? I don’t know for sure that the problem is caused by the quotes but it seems likely to me as the other call that labels the button with the macro return does work.
Thanks!