1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-12 11:10:27 +00:00
TiddlyWiki5/core/wiki/currpalettepreview.tid
2024-11-10 09:52:43 +00:00

65 lines
2.6 KiB
Plaintext

title: $:/snippets/currpalettepreview
\whitespace trim
\procedure colour-div-filtered(class,styleName,styleColour)
\function colour(name) [<currentTiddler>getindex<name>] :map[subfilter<currentTiddler>]
<$let colour-filter={{{ [<currentTiddler>getindex<styleColour>] }}}>
<!-- Note the join, needed to cope with palette entries containing spaces -->
<$let colour-result={{{ [subfilter<colour-filter>join[ ]] }}}>
<div class=<<class>> style={{{ [<styleName>addsuffix[:]addsuffix<colour-result>addsuffix[;]] }}}>
<$slot $name="ts-raw" $depth="2"/>
</div>
</$let>
</$let>
\end colour-div-filtered
\procedure colour-div-wikified(class,styleName,styleColour)
<!-- Define our own deeply backwards compatible local versions of the colour macro -->
\define colour(name)
\whitespace trim
<$transclude tiddler=<<currentTiddler>> index="$name$">
<$transclude tiddler="$:/config/DefaultColourMappings/$name$"/>
</$transclude>
\end colour
\define color(name) <<colour $name$>>
<$wikify name="colour-result" text={{{ [[<<colour ]addsuffix<styleColour>addsuffix[>>]] }}} mode="inline">
<div class=<<class>> style={{{ [<styleName>addsuffix[:]addsuffix<colour-result>addsuffix[;]] }}}>
<$slot $name="ts-raw" $depth="2"/>
</div>
</$wikify>
\end colour-div-wikified
\widget $colour.div(class,styleName,styleColour)
<%if [<styleName>!match[]] %>
<%if [<currentTiddler>get[palette-type]match[modern]] %>
<$transclude $variable="colour-div-filtered" class=<<class>> styleName=<<styleName>> styleColour=<<styleColour>>/>
<%else%>
<$transclude $variable="colour-div-wikified" class=<<class>> styleName=<<styleName>> styleColour=<<styleColour>>/>
<%endif%>
<%else%>
<div class=<<class>>>
<$slot $name="ts-raw"/>
</div>
<%endif%>
\end $colour.div
\procedure palette-preview-thumbnail()
<$colour.div class="tc-palette-preview-thumbnail" styleName="background-color" styleColour="page-background">
<$colour.div class="tc-palette-preview-thumbnail-story">
<$list filter="HelloThere GettingStarted" variable="title">
<$list filter="[all[shadows+tiddlers]tag[$:/tags/Preview/Story]!has[draft.of]]" variable="componentTitle">
<$transclude $tiddler=<<componentTitle>> title=<<title>>/>
</$list>
</$list>
</$colour.div>
<$colour.div class="tc-palette-preview-thumbnail-sidebar" styleName="color" styleColour="sidebar-foreground">
<$list filter="[all[shadows+tiddlers]tag[$:/tags/Preview/SideBar]!has[draft.of]]" variable="componentTitle">
<$transclude $tiddler=<<componentTitle>> title=<<title>>/>
</$list>
</$colour.div>
</$colour.div>
\end palette-preview-thumbnail
<<palette-preview-thumbnail>>