From f88915728f0a024f957df98a576e19114ddf89ba Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Sat, 9 Nov 2024 16:15:33 +0000 Subject: [PATCH] Introduce new static palette architecture --- core/palette-templates/TwentyTwenties.tid | 151 ++++++++++++++++++++++ core/wiki/macros/CSS.tid | 47 +++++-- core/wiki/paletteswitcher.tid | 6 +- core/wiki/startup-actions/set-palette.tid | 5 + 4 files changed, 198 insertions(+), 11 deletions(-) create mode 100644 core/palette-templates/TwentyTwenties.tid create mode 100644 core/wiki/startup-actions/set-palette.tid diff --git a/core/palette-templates/TwentyTwenties.tid b/core/palette-templates/TwentyTwenties.tid new file mode 100644 index 000000000..ddd988530 --- /dev/null +++ b/core/palette-templates/TwentyTwenties.tid @@ -0,0 +1,151 @@ +title: $:/palettes/TwentyTwenties +name: TwentyTwenties +description: Modern and flexible +tags: $:/tags/Palette +type: application/x-tiddler-dictionary +color-scheme: light +palette-type: modern + +alert-background: #ffe476 +alert-border: #b99e2f +alert-highlight: #881122 +alert-muted-foreground: #b99e2f +background: #ffffff +blockquote-bar: [function[colour],[muted-foreground]] +button-background: +button-foreground: +button-border: +code-background: #f7f7f9 +code-border: #e1e1e8 +code-foreground: #dd1144 +diff-delete-background: #ffc9c9 +diff-delete-foreground: [function[colour],[foreground]] +diff-equal-background: +diff-equal-foreground: [function[colour],[foreground]] +diff-insert-background: #aaefad +diff-insert-foreground: [function[colour],[foreground]] +diff-invisible-background: +diff-invisible-foreground: [function[colour],[muted-foreground]] +dirty-indicator: #ff0000 +download-background: #34c734 +download-foreground: [function[colour],[background]] +dragger-background: [function[colour],[foreground]] +dragger-foreground: [function[colour],[background]] +dropdown-background: [function[colour],[background]] +dropdown-border: [function[colour],[muted-foreground]] +dropdown-tab-background-selected: #ffffff +dropdown-tab-background: #ececec +dropzone-background: rgba(0,200,0,0.7) +external-link-background-hover: inherit +external-link-background-visited: inherit +external-link-background: inherit +external-link-foreground-hover: inherit +external-link-foreground-visited: #0000aa +external-link-foreground: #0000ee +footnote-target-background: #ecf2ff +foreground: #333333 +highlight-background: #ffff00 +highlight-foreground: #000000 +message-background: #ecf2ff +message-border: #cfd6e6 +message-foreground: #547599 +modal-backdrop: [function[colour],[foreground]] +modal-background: [function[colour],[background]] +modal-border: #999999 +modal-footer-background: #f5f5f5 +modal-footer-border: #dddddd +modal-header-border: #eeeeee +muted-foreground: #bbbbbb +network-activity-foreground: #448844 +notification-background: #ffffdd +notification-border: #999999 +page-background: [function[colour],[primary]colour-oklch[0.9]] +pre-background: #f5f5f5 +pre-border: #cccccc +primary: #5778d8 +selection-background: +selection-foreground: +select-tag-background: +select-tag-foreground: +sidebar-button-foreground: [function[colour],[foreground]] +sidebar-controls-foreground-hover: #000000 +sidebar-controls-foreground: #aaaaaa +sidebar-foreground-shadow: rgba(255,255,255, 0.8) +sidebar-foreground: #acacac +sidebar-muted-foreground-hover: #444444 +sidebar-muted-foreground: #c0c0c0 +sidebar-tab-background-selected: #f4f4f4 +sidebar-tab-background: #e0e0e0 +sidebar-tab-border-selected: [function[colour],[tab-border-selected]] +sidebar-tab-border: [function[colour],[tab-border]] +sidebar-tab-divider: #e4e4e4 +sidebar-tab-foreground-selected: +sidebar-tab-foreground: [function[colour],[tab-foreground]] +sidebar-tiddler-link-foreground-hover: #444444 +sidebar-tiddler-link-foreground: #999999 +site-title-foreground: [function[colour],[tiddler-title-foreground]] +stability-stable: #008000 +stability-experimental: #c07c00 +stability-deprecated: #ff0000 +stability-legacy: #0000ff +static-alert-foreground: #aaaaaa +tab-background-selected: #ffffff +tab-background: #d8d8d8 +tab-border-selected: #d8d8d8 +tab-border: #cccccc +tab-divider: #d8d8d8 +tab-foreground-selected: [function[colour],[tab-foreground]] +tab-foreground: #666666 +table-border: #dddddd +table-footer-background: #a8a8a8 +table-header-background: #f0f0f0 +tag-background: #eecc66 +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-border: [function[colour],[background]] +tiddler-controls-foreground-hover: #888888 +tiddler-controls-foreground-selected: #444444 +tiddler-controls-foreground: #cccccc +tiddler-editor-background: #f8f8f8 +tiddler-editor-border-image: #ffffff +tiddler-editor-border: #cccccc +tiddler-editor-fields-even: #e0e8e0 +tiddler-editor-fields-odd: #f0f4f0 +tiddler-info-background: #f8f8f8 +tiddler-info-border: #dddddd +tiddler-info-tab-background: #f8f8f8 +tiddler-link-background: [function[colour],[background]] +tiddler-link-foreground: [function[colour],[primary]] +tiddler-subtitle-foreground: #c0c0c0 +tiddler-title-foreground: #182955 +toolbar-new-button: +toolbar-options-button: +toolbar-save-button: +toolbar-info-button: +toolbar-edit-button: +toolbar-close-button: +toolbar-delete-button: +toolbar-cancel-button: +toolbar-done-button: +untagged-background: #999999 +very-muted-foreground: #888888 +wikilist-background: #e5e5e5 +wikilist-item: #ffffff +wikilist-info: #000000 +wikilist-title: #666666 +wikilist-title-svg: [function[colour],[wikilist-title]] +wikilist-url: #aaaaaa +wikilist-button-open: #4fb82b +wikilist-button-open-hover: green +wikilist-button-reveal: #5778d8 +wikilist-button-reveal-hover: blue +wikilist-button-remove: #d85778 +wikilist-button-remove-hover: red +wikilist-toolbar-background: #d3d3d3 +wikilist-toolbar-foreground: #888888 +wikilist-droplink-dragover: rgba(255,192,192,0.5) +wikilist-button-background: #acacac +wikilist-button-foreground: #000000 diff --git a/core/wiki/macros/CSS.tid b/core/wiki/macros/CSS.tid index 09c85efe9..92c349665 100644 --- a/core/wiki/macros/CSS.tid +++ b/core/wiki/macros/CSS.tid @@ -1,17 +1,44 @@ title: $:/core/macros/CSS tags: $:/tags/Macro - -\define colour(name) -\whitespace trim -<$transclude tiddler={{$:/palette}} index="$name$"> - <$transclude tiddler="$:/palettes/Vanilla" index="$name$"> - <$transclude tiddler="$:/config/DefaultColourMappings/$name$"/> - - -\end +\procedure actions-compile-palette(inputTitle,outputTitle) + +\function colour(name) + [getindex] :else[[$:/config/DefaultColourMappings/]addsuffixget[text]] +\end colour + +<%if [get[palette-type]match[modern]] %> + <$list filter="[indexes[]sort[]]" variable="colour-name"> + <$let colour-filter={{{ [getindex] }}}> + + <$action-setfield $tiddler=<> $index=<> $value={{{ [subfilterjoin[ ]] }}}/> + + +<%else%> + + <$list filter="[indexes[]sort[]]" variable="colour-name"> + <$wikify name="colour-value" text={{{ [getindex] }}} mode="inline"> + <$action-setfield $tiddler=<> $index=<> $value=<>/> + + +<%endif%> +\end actions-compile-palette -\define color(name) <> +\procedure actions-switch-colour-palette(paletteTitle) +<$action-log $msg="switching palette" $to=<> actions-compile-palette=<>/> +<$action-deletetiddler $tiddler="$:/temp/palette-colours"/> +<$action-setfield $tiddler="$:/palette" $field="text" $value=<>/> +<$transclude $variable="actions-compile-palette" inputTitle="$:/palettes/Vanilla" outputTitle="$:/temp/palette-colours"/> +<$transclude $variable="actions-compile-palette" inputTitle=<> outputTitle="$:/temp/palette-colours"/> +\end actions-switch-colour-palette + +\function colour(name) +[[$:/temp/palette-colours]getindex] :else[[$:/config/DefaultColourMappings/]addsuffixget[text]] +\end colour + +\function color(name) +[function[colour],] +\end color \define box-shadow(shadow) `` diff --git a/core/wiki/paletteswitcher.tid b/core/wiki/paletteswitcher.tid index 33ed55c7e..7e4a06020 100644 --- a/core/wiki/paletteswitcher.tid +++ b/core/wiki/paletteswitcher.tid @@ -1,7 +1,11 @@ title: $:/snippets/paletteswitcher \whitespace trim -<$linkcatcher to="$:/palette"> +\procedure actions() +<$transclude $variable="actions-switch-colour-palette" paletteTitle=<>/> +\end actions + +<$linkcatcher actions=<>>
<$list filter="[all[shadows+tiddlers]tag[$:/tags/Palette]sort[name]]"> <$set name="cls" filter="[all[current]prefix{$:/palette}]" value="tc-chooser-item tc-chosen" emptyValue="tc-chooser-item"> diff --git a/core/wiki/startup-actions/set-palette.tid b/core/wiki/startup-actions/set-palette.tid new file mode 100644 index 000000000..d42012d9e --- /dev/null +++ b/core/wiki/startup-actions/set-palette.tid @@ -0,0 +1,5 @@ +title: $:/core/wiki/startup-actions/set-palette +tags: $:/tags/StartupAction + +\import [subfilter{$:/core/config/GlobalImportFilter}] +<$transclude $variable="actions-switch-colour-palette" paletteTitle={{$:/palette}}/>