Background color from color palette

162 views
Skip to first unread message

stevesuny

unread,
Jan 12, 2018, 12:48:48 PM1/12/18
to TiddlyWiki
Hi Folks,

I'm creating a simple slideshow macro, and trying to set the background color of tiddlers dynamically from the color palette.

I've added this to ViewTemplate (actually, I copied the $:/core/ui/ViewTemplate from https://tiddlywiki.com/talkytalky/) which allows me to set background color according to the background-color field.


\define frame-styles()
background-color: $(backgroundColour)$;
border-color: $(backgroundColour)$;
\end


In my current color palette tiddler ($:/palettes/DWS)  I've added these lines:

1: #DEFF65
2: #FF9563
3: #FF7575
4: #5AD3FF
5: #A7FF7B

In each of my tiddlers to be colored, I have a field slidenum set to 1..5.

In my macro I've got this define: 

\define bgcolor() {{$:/palettes/DWS##$(slidenum)$}}

And I am using these commands to try to set the background color for each tiddler:

<!--set bg color of all slides in show -->
<$list filter="[tag<slidetag>!sort<slidenum>]">
<$vars slidenum={{!!slidenum}}>
<$action-setfield background-color=<<bgcolor>>/>
</$vars>
</$list>

It almost works, but in my background-color field, instead of the value from the palettte tiddler, I get:

{{$:/palettes/DWS##1}}

Some sort of escaping, I'm sure. Any help much appreciated!

//steve.

TonyM

unread,
Jan 12, 2018, 7:37:03 PM1/12/18
to TiddlyWiki
steve

I do not know the full answer, but expect I could find it, there is much valuable info following the trail in your own tiddlywiki. I believe there is a macro for setting colours to values found in the pallet that tiddlywiki uses itself.

Evan has also being developing solutions to allow you to use values from fields, variables and macros in html tags as well.

Regards
Tony

Jeremy Ruston

unread,
Jan 13, 2018, 8:21:18 AM1/13/18
to tiddl...@googlegroups.com
Hi Steve

Untested, but try this:

<!--set bg color of all slides in show -->
<$list filter="[tag<slidetag>!sort<slidenum>]">
<$vars slidenum={{!!slidenum}}>
<$wikify name="rgb" text=<<bgcolor>>>
<$action-setfield background-color=<<rgb>>/>
</$wikify>
</$vars>
</$list>

Given that you’ve got a transclusion in the variable ‘bgcolor’, the wikify widget is simply rendering that transclusion, ie converting it into the underlying value.

Best wishes

Jeremy.




--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/850c9dbb-8920-4121-a459-2702380b7fa7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

stevesuny

unread,
Jan 14, 2018, 12:25:51 PM1/14/18
to TiddlyWiki
Jeremy et al thanks! This almost worked as proposed, but I figured it out. I was having trouble getting the "#" into the field value.

Here is the working macro, currently implemented at DesignWriteStudio (this is for a class I am teaching this semester at SUNY Polytechnic Institute). I had to do some odd dancing around in the defines to get the "#" to show up in the background-color field.

Questions now: 

<1> on phone, the "prev" and "next" buttons are not properly displaying; too far over to the left
<2> I'd like to set the slidenum field to be the same name as the "slidetag"  -- so that a given tiddler can be used/ordered in multiple slideshows. That would require a transclusion of some sort that I haven't begun to figure out. 
<3> I'd hope to be able to color the slide in the same <list> as displaying the slides, but that may not be possible? As you can see, I run through the slides on a <list> twice: once to set the bg color, once to open into the story river.

And I hope to bundle this as a plugin (soon).

Thannks!

//steve.

(macro code follows)








\define bgcolor() {{$:/palettes/DWS##$(slidenum)$}}
\define bgcolor2() #$(rgb)$
\define punchshow(slidetag)

<!--macro creates slideshow of tiddlers tagged with slidetag and ordered by field slidenum.  sets bgcolor according to values in customized palette (palette name is hardcoded on first line of macro). requires modified viewTemplate. requires $:/themes/tiddlywiki/punch, $:/core/ui/ViewTemplate/next, $:/core/ui/ViewTemplate/prev, $:/core/ui/ViewTemplate/endslideshow -->

<!--capture slidetag in variable-->
<$set name=slidetag value="$slidetag$">

<!--button text, close all tiddlers, hide sidebar, close open tiddlers, change theme, activate next/prev buttons, activate endslideshow button in ViewTemplate-->

<$button set="$:/state/sidebar" setTo="no" tooltip={{$:/language/Buttons/HideSideBar/Hint}} aria-label={{$:/language/Buttons/HideSideBar/Caption}} >
<$action-sendmessage $message="tm-close-all-tiddlers"/>
<$action-setfield $tiddler="$:/theme" text="$:/themes/tiddlywiki/punch"/>
<$action-setfield $tiddler="$:/core/ui/ViewTemplate/next" tags="$:/tags/ViewTemplate"/>
<$action-setfield $tiddler="$:/core/ui/ViewTemplate/prev" tags="$:/tags/ViewTemplate"/>
<$action-setfield $tiddler="$:/core/ui/ViewTemplate/endslideshow" tags="$:/tags/ViewTemplate"/>

<!--set default return-->
<$action-setfield $tiddler="$:/fromTiddler" text=<<currentTiddler>>/>

<!--set bg color of all slides in show -->
<$list filter="[tag<slidetag>!nsort[slidenum]]">
<$vars slidenum={{!!slidenum}}>
<$wikify name="rgb" text=<<bgcolor>>>
<$action-setfield background-color=<<bgcolor2>>/>
</$wikify>
</$vars>
</$list>

<!--gather and open all tiddlers with field matching slidetag with slidetag field as order-->
<$list filter="[tag<slidetag>!nsort[slidenum]]">
<$action-navigate $to=<<currentTiddler>> />
</$list>
View slideshow <<slidetag>><br>
</$button>
\end

\define endslideshow()
<$button set="$:/state/sidebar" setTo="no">
<$action-setfield $tiddler="$:/theme" text="$:/themes/tiddlywiki/heavier"/>
<$action-listops $tiddler="$:/core/ui/ViewTemplate/next" $field="tags" $filter="[[]]"/>
<$action-listops $tiddler="$:/core/ui/ViewTemplate/prev" $field="tags" $filter="[[]]"/>
<$action-listops $tiddler="$:/core/ui/ViewTemplate/endslideshow" $field="tags" $filter="[[]]"/>
<$action-sendmessage $message="tm-close-all-tiddlers"/>
<$action-navigate $to={{$:/fromTiddler}}/>
End Slideshow
</$button>
\end
Reply all
Reply to author
Forward
0 new messages