From a23ee165d8ac66eb24242a22ef99ba848e8a7eaf Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Tue, 22 Oct 2024 17:26:04 +0100 Subject: [PATCH] Rewrite colour macro as a function Using the new wikify operator. Currently has a bug whereby redirected colours (like "tiddler-background") do not work. Direct colours like "background" do work. Note the hacks needed to makeFakeWidgetWithVariables work --- core/modules/widgets/widget.js | 6 +++++- core/wiki/macros/CSS.tid | 15 ++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/core/modules/widgets/widget.js b/core/modules/widgets/widget.js index b73294654..b38397749 100755 --- a/core/modules/widgets/widget.js +++ b/core/modules/widgets/widget.js @@ -341,7 +341,11 @@ Widget.prototype.makeFakeWidgetWithVariables = function(variables) { }, makeFakeWidgetWithVariables: self.makeFakeWidgetWithVariables, resolveVariableParameters: self.resolveVariableParameters, - wiki: self.wiki + wiki: self.wiki, + variables: variables, + getAncestorCount: function() { + return 0; + } }; }; diff --git a/core/wiki/macros/CSS.tid b/core/wiki/macros/CSS.tid index 3d7dfcdb2..3702b1ff1 100644 --- a/core/wiki/macros/CSS.tid +++ b/core/wiki/macros/CSS.tid @@ -2,16 +2,13 @@ title: $:/core/macros/CSS tags: $:/tags/Macro $:/tags/Global -\define colour(name) -\whitespace trim -<$transclude tiddler={{$:/palette}} index="$name$"> - <$transclude tiddler="$:/palettes/Vanilla" index="$name$"> - <$transclude tiddler="$:/config/DefaultColourMappings/$name$"/> - - -\end +\function colour(name) +[{$:/palette}getindex] :else[{$:/palettes/Vanilla}getindex] :else[[$:/config/DefaultColourMappings/]addsuffixget[text]] :and[wikify[text],[inline]] +\end colour -\define color(name) <> +\function color(name) +[function[colour],] +\end function \function box-shadow(shadow) [[ -webkit-box-shadow: $(shadow)$;