Passing color around in macro

47 views
Skip to first unread message

T. E. Sanders

unread,
Feb 21, 2020, 5:18:07 PM2/21/20
to TiddlyWiki
Sorry guys, I know I have a lot of questions. I've gotten pretty far on what I'm trying to do. I have a macro where the main one that is called calls another in the way the tag pill macro works.

So I have colour={{{ [<__tag__>get[color]] }}} being passed to a 2nd where I do some manipulation and whatnot. 
This doesn't give me a variable like "#ff4455" but a list of parameters with colors. One of them is "primary" and I can see this is the color from the tiddler.

alert-background: #ffe476
alert-border: #b99e2f
alert-highlight: #881122
alert-muted-foreground: #b99e2f
background: #ffffff
blockquote-bar: <<colour muted-foreground>>
button-background:...
...
primary: #ff4455
...

SO this code:
<$vars foregroundColor=<<contrastcolour target:"""$colour$"""  fallbackTarget:"""$fallbackTarget$""" colourA:"""$colourA$""" colourB:"""$colourB$""">>
backgroundColor="""$colour$"""  >

won't work with this. I hardcoded a test color and it does work that way, which leads me to believe colour={{{ [<__tag__>get[color]] }}}. is indeed giving me something
other than a usable hex color.

How can I get a usable $colour$ variable into this macro from the color field in the tiddler?

Thanks again!

T. E. Sanders

unread,
Feb 21, 2020, 6:22:41 PM2/21/20
to TiddlyWiki
This is probably another example of me not understanding the syntax. This...

<$set name="col" filter="[all[current]get[color]]">

<$vars foregroundColor=<<contrastcolour target:"""$col$""" fallbackTarget:"""$fallbackTarget$""" ...
...

Though I can transclude "col" and see it's the correct color, I can't figure out how to get it into this <<contrastcolor target: ____. macro. If I put <<contrastcolor target:"#444444" then I see it works fine, so I'm not getting the var into properly. My col variable fixed my background issue. I can use it there with no problem, just not this <<contrastcolor macro

TonyM

unread,
Feb 21, 2020, 6:34:28 PM2/21/20
to TiddlyWiki
T E

The $param$ format is only valid in macros
\define macroname(param)
$param$ valid here however since you
set the variable you can use $(col)$ here in the macro
\end

You may also find using the macro call widget is an easier way to pass parameters to a macro

I know this is not a full answer, I would only give that if I tested it first, but I hope it helps

Regards
Tony

T. E. Sanders

unread,
Feb 21, 2020, 7:29:05 PM2/21/20
to TiddlyWiki
Hmmmm... I tried non-quoted and quoted versions of this:


      <$set name="col" filter="[all[current]get[color]]">
      <$vars foregroundColor=<<contrastcolour target:"""$(col)$""" fallbackTarget:"""$fallbackTarget$""" ...

Doesn't seem to take it.
Reply all
Reply to author
Forward
0 new messages