1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-02-10 16:10:02 +00:00

Fix preview of filtered palettes

This commit is contained in:
Jeremy Ruston 2024-11-10 09:52:43 +00:00
parent b54d56ec47
commit 297ae7eccb
3 changed files with 33 additions and 14 deletions

View File

@ -59,7 +59,7 @@ muted-foreground: #bbbbbb
network-activity-foreground: #448844 network-activity-foreground: #448844
notification-background: #ffffdd notification-background: #ffffdd
notification-border: #999999 notification-border: #999999
page-background: [function[colour],[primary]colour-oklch[0.9]] page-background: [function[colour],[primary]colour-oklch:l[0.5]colour-oklch:c[.1]]
pre-background: #f5f5f5 pre-background: #f5f5f5
pre-border: #cccccc pre-border: #cccccc
primary: #5778d8 primary: #5778d8
@ -104,7 +104,7 @@ tag-foreground: #ffffff
testcase-accent-level-1: #c1eaff testcase-accent-level-1: #c1eaff
testcase-accent-level-2: #E3B740 testcase-accent-level-2: #E3B740
testcase-accent-level-3: #5FD564 testcase-accent-level-3: #5FD564
tiddler-background: [function[colour],[page-background]colour-oklch:h[0.5]] tiddler-background: [function[colour],[page-background]colour-oklch:c[.4]]
tiddler-border: [function[colour],[background]] tiddler-border: [function[colour],[background]]
tiddler-controls-foreground-hover: #888888 tiddler-controls-foreground-hover: #888888
tiddler-controls-foreground-selected: #444444 tiddler-controls-foreground-selected: #444444

View File

@ -1,10 +1,10 @@
title: $:/palettes/TwentyTwenties/Green title: $:/palettes/TwentyTwenties/Green
name: TwentyTwenties (Green) name: TwentyTwenties (Green)
description: Modern and flexible description: Modern and flexible, Greenish
tags: $:/tags/Palette tags: $:/tags/Palette
type: application/x-tiddler-dictionary type: application/x-tiddler-dictionary
color-scheme: light color-scheme: light
palette-type: modern palette-type: modern
palette-import: $:/palettes/TwentyTwenties palette-import: $:/palettes/TwentyTwenties
page-background: #6e803c primary: #3c6e80

View File

@ -2,22 +2,41 @@ title: $:/snippets/currpalettepreview
\whitespace trim \whitespace trim
\procedure colour(name) \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 \whitespace trim
<$transclude $tiddler=<<currentTiddler>> $index=<<name>>> <$transclude tiddler=<<currentTiddler>> index="$name$">
<$transclude $tiddler="$:/palettes/Vanilla" $index=<<name>>> <$transclude tiddler="$:/config/DefaultColourMappings/$name$"/>
<$transclude $tiddler={{{ [[$:/config/DefaultColourMappings/]addsuffix<name>] }}}/>
</$transclude>
</$transclude> </$transclude>
\end colour \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) \widget $colour.div(class,styleName,styleColour)
<%if [<styleName>!match[]] %> <%if [<styleName>!match[]] %>
<$wikify name="colour-result" text={{{ [[<<colour ]addsuffix<styleColour>addsuffix[>>]] }}} mode="inline"> <%if [<currentTiddler>get[palette-type]match[modern]] %>
<div class=<<class>> style={{{ [<styleName>addsuffix[:]addsuffix<colour-result>addsuffix[;]] }}}> <$transclude $variable="colour-div-filtered" class=<<class>> styleName=<<styleName>> styleColour=<<styleColour>>/>
<$slot $name="ts-raw"/> <%else%>
</div> <$transclude $variable="colour-div-wikified" class=<<class>> styleName=<<styleName>> styleColour=<<styleColour>>/>
</$wikify> <%endif%>
<%else%> <%else%>
<div class=<<class>>> <div class=<<class>>>
<$slot $name="ts-raw"/> <$slot $name="ts-raw"/>