[TW5] Using Tiddler Color and Icon in macros

87 views
Skip to first unread message

TonyM

unread,
Jan 17, 2018, 8:25:08 PM1/17/18
to TiddlyWiki
Hi Folks,

A Question I have not being able to answer

I have tiddlera calling a macro

<<macroname tiddlerb>>


The Macro is global ie tagged  with $:/tags/Macro

In the tiddlercmacro tiddler I have

\define macroname(tiddlername)
<div class="dropdown" >
 
<button class="dropbtn">
   
<$transclude tiddler="$tiddlername$" field=caption mode=inline/>
 
</button>
 
<div class="dropdown-content">....

The Above is displaying the content of the caption field as the button name - as wanted.

However I have tried a number of things and can not seem to also do the following.

Display the icon from  tiddler="$tiddlername$" field=icon
Colour the icon and caption from tiddler="$tiddlername$" field=color

Thanks in Advance
Tony

Mark S.

unread,
Jan 17, 2018, 11:18:49 PM1/17/18
to TiddlyWiki

Maybe like this:

\define custombutton(color,icon,caption)
<$button style="background-color:$color$">@@background-color:$color$;
{{$icon$}} $caption$@@</$button>
\end

<$macrocall $name=custombutton color={{ButtonInfo!!color}} icon={{ButtonInfo!!icon}} caption={{ButtonInfo!!caption}} /
>

Using a tiddler ButtonInfo which has fields color=lightblue, icon=$:/core/images/chevron-down, and caption="A little blue"

-- Mark

TonyM

unread,
Jan 18, 2018, 3:39:28 AM1/18/18
to TiddlyWiki
Mark,

Thanks for the Suggestion

I am still getting hard to resolve problems

\define mymenubutton(color,icon,caption)
<$button class="dropbtn" style="@@background-color:$color$">@@background-color:$color$;$icon$ {{$caption$}}@@</$button>
\end
\define showmenu(menuname)
<$set name="currentMenu" value="[[$menuname$]]">
<$set name=menufilter tiddler="$menuname$" field="menu-filter" emptyValue={{$:/PSaT/MyMenus/menufilterdefault}}>
<div class="dropdown">
 
<$macrocall $name=mymenubutton color="{{$menuname$!!color}}" icon="{{$menuname$!!icon}}" caption="$menuname$!!menu-caption"/>
....

In the above case I have the Caption working but not the icon and color
The Icon returnes the correct name of the icon not the icon
And if I remove the {{ }}  from the macro call they do not work as the caption does

I suppose the key difference is the tiddler name is in fact provided as $menuname$

Thanks,

I will investigate with a fresh mind tomorrow.

Tony

TonyM

unread,
Jan 18, 2018, 3:49:00 AM1/18/18
to TiddlyWiki
Accidental Discovery

Something that works

Rather than use the icon field I created an additional one
menu-icon If this icon tiddler name is in {{   }}
The macro call icon="{{$menuname$!!menu-icon}}"
And the button $icon$ 

The Problem  is it stops me using the default icon field and Color (VALUE #ff8080) from the $menuname$ tiddler.

Tony

TonyM

unread,
Jan 18, 2018, 4:21:20 AM1/18/18
to TiddlyWiki
Solution;

But do not know all the reasons

\define mymenubutton(menucolor,icon,caption)
<$button class="dropbtn" style="background-color:$menucolor$;"> $icon$ {{$caption$}}</$button>

\end
\define showmenu(menuname)
<$set name="currentMenu" value="[[$menuname$]]">
<$set name=menufilter tiddler="$menuname$" field="menu-filter" emptyValue={{$:/PSaT/MyMenus/menufilterdefault}}>
<div class="dropdown">

 
<$macrocall $name=mymenubutton menucolor={{$menuname$!!menu-color}} icon="{{$menuname$!!menu-icon}}" caption="$menuname$!!menu-caption"/>


Regards
Tony
Reply all
Reply to author
Forward
0 new messages