1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-02 14:29:55 +00:00
TiddlyWiki5/core/wiki/currpalettepreview.tid

61 lines
2.2 KiB
Plaintext
Raw Permalink Normal View History

2014-02-20 10:00:38 +00:00
title: $:/snippets/currpalettepreview
\whitespace trim
2024-11-10 09:52:43 +00:00
\procedure colour-div-filtered(class,styleName,styleColour)
2024-11-14 17:40:58 +00:00
<!-- Note the join, needed to cope with palette entries containing spaces -->
2024-11-17 16:11:10 +00:00
\function colour(name) [<colour-palette>getindex<name>] :else[<colour-palette>get[palette-import]getindex<name>] :map[subfilter<currentTiddler>join[ ]]
2024-11-14 17:40:58 +00:00
<$let
colour-palette=<<currentTiddler>>
2024-11-17 14:45:41 +00:00
colour-result={{{ [function[colour],<styleColour>] }}}
2024-11-14 17:40:58 +00:00
>
<div class=<<class>> style={{{ [<styleName>addsuffix[:]addsuffix<colour-result>addsuffix[;]] }}}>
<$slot $name="ts-raw" $depth="2"/>
</div>
2024-11-10 09:52:43 +00:00
</$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
2024-11-10 09:52:43 +00:00
<$transclude tiddler=<<currentTiddler>> index="$name$">
<$transclude tiddler="$:/config/DefaultColourMappings/$name$"/>
</$transclude>
\end colour
2024-11-10 09:52:43 +00:00
\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[;]] }}}>
2024-11-10 09:52:43 +00:00
<$slot $name="ts-raw" $depth="2"/>
</div>
</$wikify>
2024-11-10 09:52:43 +00:00
\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
2024-11-17 14:45:41 +00:00
\procedure palette-preview-component-list(tag)
<$list filter="[all[shadows+tiddlers]tag<tag>!has[draft.of]]" variable="componentTitle">
<$transclude $tiddler=<<componentTitle>> title=<<title>>/>
</$list>
\end palette-preview-component-list
\procedure palette-preview-thumbnail()
<$colour.div class="tc-palette-preview-thumbnail" styleName="background-color" styleColour="page-background">
2024-11-17 14:45:41 +00:00
<<palette-preview-component-list "$:/tags/Preview/Page">>
</$colour.div>
\end palette-preview-thumbnail
<<palette-preview-thumbnail>>