mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-02-09 07:30:01 +00:00
Support for imported palettes
Also consolidate the palette entries into a temporary palette before compiling them Note that imported palettes is not currently recursive
This commit is contained in:
parent
4e2f2bebd0
commit
b54d56ec47
@ -104,7 +104,7 @@ tag-foreground: #ffffff
|
||||
testcase-accent-level-1: #c1eaff
|
||||
testcase-accent-level-2: #E3B740
|
||||
testcase-accent-level-3: #5FD564
|
||||
tiddler-background: [function[colour],[primary]colour-oklch[0.95]]
|
||||
tiddler-background: [function[colour],[page-background]colour-oklch:h[0.5]]
|
||||
tiddler-border: [function[colour],[background]]
|
||||
tiddler-controls-foreground-hover: #888888
|
||||
tiddler-controls-foreground-selected: #444444
|
||||
|
10
core/palette-templates/TwentyTwentiesGreen.tid
Normal file
10
core/palette-templates/TwentyTwentiesGreen.tid
Normal file
@ -0,0 +1,10 @@
|
||||
title: $:/palettes/TwentyTwenties/Green
|
||||
name: TwentyTwenties (Green)
|
||||
description: Modern and flexible
|
||||
tags: $:/tags/Palette
|
||||
type: application/x-tiddler-dictionary
|
||||
color-scheme: light
|
||||
palette-type: modern
|
||||
palette-import: $:/palettes/TwentyTwenties
|
||||
|
||||
page-background: #6e803c
|
@ -1,33 +1,69 @@
|
||||
title: $:/core/macros/CSS
|
||||
tags: $:/tags/Macro
|
||||
|
||||
\procedure actions-compile-palette(inputTitle,outputTitle)
|
||||
<!-- Redefine colour function to use the input palette -->
|
||||
<$let tv-palette-name=<<inputTitle>>>
|
||||
<!-- Process modern filter-based palettes -->
|
||||
\procedure actions-compile-palette-filtered(tempPalette,outputTitle)
|
||||
<!-- Make the colour function use the input palette -->
|
||||
<$let
|
||||
tv-palette-name=<<tempPalette>>
|
||||
>
|
||||
<$list filter="[<tempPalette>indexes[]sort[]]" variable="colour-name">
|
||||
<$let colour-filter={{{ [<tempPalette>getindex<colour-name>] }}}>
|
||||
<!-- Note the join, needed to cope with palette entries containing spaces -->
|
||||
<$action-setfield $tiddler=<<outputTitle>> $index=<<colour-name>> $value={{{ [subfilter<colour-filter>join[ ]] }}}/>
|
||||
</$let>
|
||||
</$list>
|
||||
</$let>
|
||||
\end actions-compile-palette-filtered
|
||||
|
||||
\procedure actions-compile-palette-wikified(tempPalette,outputTitle)
|
||||
<!-- Define our own deeply backwards compatible local versions of the colour macro -->
|
||||
\define colour(name)
|
||||
\whitespace trim
|
||||
<$transclude tiddler=<<tempPalette>> index="$name$">
|
||||
<$transclude tiddler="$:/config/DefaultColourMappings/$name$"/>
|
||||
</$transclude>
|
||||
\end colour
|
||||
\define color(name) <<colour $name$>>
|
||||
<$list filter="[<tempPalette>indexes[]sort[]]" variable="colour-name" $debug="yes">
|
||||
<$wikify name="colour-value" text={{{ [<tempPalette>getindex<colour-name>] }}} mode="inline">
|
||||
<$action-setfield $tiddler=<<outputTitle>> $index=<<colour-name>> $value=<<colour-value>>/>
|
||||
</$wikify>
|
||||
</$list>
|
||||
\end actions-compile-palette-wikified
|
||||
|
||||
\procedure actions-compile-palette(inputTitle,outputTitle,defaultImport="$:/palettes/Vanilla")
|
||||
<$let
|
||||
tempPalette="$:/temp/palette-source"
|
||||
>
|
||||
<!-- Clear the temporary consolidated palette -->
|
||||
<$action-deletetiddler $tiddler=<<tempPalette>>/>
|
||||
<!-- Consolidate the imported palette -->
|
||||
<$let importTitle={{{ [<inputTitle>get[palette-import]else<defaultImport>] }}}>
|
||||
<%if [<importTitle>!match[]] %>
|
||||
<$list filter="[<importTitle>indexes[]sort[]]" variable="colour-name">
|
||||
<$action-setfield $tiddler=<<tempPalette>> $index=<<colour-name>> $value={{{ [<importTitle>getindex<colour-name>] }}}/>
|
||||
</$list>
|
||||
<%endif%>
|
||||
</$let>
|
||||
<!-- Consolidate the main palette -->
|
||||
<$list filter="[<inputTitle>indexes[]sort[]]" variable="colour-name">
|
||||
<$action-setfield $tiddler=<<tempPalette>> $index=<<colour-name>> $value={{{ [<inputTitle>getindex<colour-name>] }}}/>
|
||||
</$list>
|
||||
<!-- Compile the temporary palette to the output palette -->
|
||||
<%if [<inputTitle>get[palette-type]match[modern]] %>
|
||||
<$list filter="[<inputTitle>indexes[]sort[]]" variable="colour-name">
|
||||
<$let colour-filter={{{ [<inputTitle>getindex<colour-name>] }}}>
|
||||
<!-- Note the join, needed to cope with palette entries containing spaces -->
|
||||
<$action-setfield $tiddler=<<outputTitle>> $index=<<colour-name>> $value={{{ [subfilter<colour-filter>join[ ]] }}}/>
|
||||
</$let>
|
||||
</$list>
|
||||
<$transclude $variable="actions-compile-palette-filtered" tempPalette=<<tempPalette>> outputTitle=<<outputTitle>>/>
|
||||
<%else%>
|
||||
<!-- Process legacy wikified palettes -->
|
||||
<$list filter="[<inputTitle>indexes[]sort[]]" variable="colour-name">
|
||||
<$wikify name="colour-value" text={{{ [<inputTitle>getindex<colour-name>] }}} mode="inline">
|
||||
<$action-setfield $tiddler=<<outputTitle>> $index=<<colour-name>> $value=<<colour-value>>/>
|
||||
</$wikify>
|
||||
</$list>
|
||||
<$transclude $variable="actions-compile-palette-wikified" tempPalette=<<tempPalette>> outputTitle=<<outputTitle>>/>
|
||||
<%endif%>
|
||||
<!-- Remove the temporary consolidated palette -->
|
||||
<!-- <$action-deletetiddler $tiddler=<<tempPalette>>/> -->
|
||||
</$let>
|
||||
\end actions-compile-palette
|
||||
|
||||
\procedure actions-switch-colour-palette(paletteTitle)
|
||||
<$action-log $msg="switching palette" $to=<<paletteTitle>> actions-compile-palette=<<actions-compile-palette>>/>
|
||||
\procedure tv-action-refresh-policy() always
|
||||
<$action-deletetiddler $tiddler="$:/temp/palette-colours"/>
|
||||
<$action-setfield $tiddler="$:/palette" $field="text" $value=<<paletteTitle>>/>
|
||||
<$transclude $variable="actions-compile-palette" inputTitle="$:/palettes/Vanilla" outputTitle="$:/temp/palette-colours"/>
|
||||
<$transclude $variable="actions-compile-palette" inputTitle=<<paletteTitle>> outputTitle="$:/temp/palette-colours"/>
|
||||
\end actions-switch-colour-palette
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user