diff --git a/core/palette-templates/TwentyTwenties.tid b/core/palette-templates/TwentyTwenties.tid index 1bc7735c3..18558b4ff 100644 --- a/core/palette-templates/TwentyTwenties.tid +++ b/core/palette-templates/TwentyTwenties.tid @@ -18,7 +18,9 @@ base-secondary: rgb(236, 212, 58) base-tertiary: rgb(135, 239, 70) # Contrast tests -?background-foreground-contrast: [function[colour],[background]] [function[colour],[base-background]] +[colour-contrast:DeltaPhi[]compare:number:gt[25]then[ok]else[Foreground/background contrast is too low]] +?background-foreground-contrast: [tf.check-colour-contrast[background],[foreground],[125]] +?alert-contrast: [tf.check-colour-contrast[alert-background],[foreground],[25]] +?code-contrast: [tf.check-colour-contrast[code-background],[code-foreground],[25]] # Colour definitions alert-background: [function[colour],[base-secondary]colour-oklch:l[0.9]] diff --git a/core/wiki/macros/CSS.tid b/core/wiki/macros/CSS.tid index f367d11f8..59826452d 100644 --- a/core/wiki/macros/CSS.tid +++ b/core/wiki/macros/CSS.tid @@ -2,6 +2,8 @@ title: $:/core/macros/CSS tags: $:/tags/Macro \procedure actions-compile-palette-filtered(tempPalette,outputTitle) + +\function colour(name) [getindex] :else[get[palette-import]getindex] :map[subfilterjoin[ ]] <$let tv-palette-name=<> @@ -77,6 +79,10 @@ tags: $:/tags/Macro [function[colour],] \end color +\function tf.check-colour-contrast(paletteEntryA,paletteEntryB,threshold) +[function[colour],] [function[colour],] +[colour-contrast:DeltaPhi[]compare:number:gtthen[ok]] :else[addsuffix[/]addsuffixaddsuffix[ contrast is too low]] +\end tf.check-colour-contrast + \define box-shadow(shadow) `` -webkit-box-shadow: $shadow$; diff --git a/core/wiki/paletteswitcher.tid b/core/wiki/paletteswitcher.tid index bdde81e4b..ced304b7b 100644 --- a/core/wiki/paletteswitcher.tid +++ b/core/wiki/paletteswitcher.tid @@ -24,3 +24,5 @@ title: $:/snippets/paletteswitcher + +{{$:/snippets/palettetests}} diff --git a/core/wiki/palettetests.tid b/core/wiki/palettetests.tid new file mode 100644 index 000000000..b7bd24d69 --- /dev/null +++ b/core/wiki/palettetests.tid @@ -0,0 +1,19 @@ +title: $:/snippets/palettetests + +<$let failureCount={{{ [[$:/temp/palette-colours]indexes[]prefix[?]] :filter[[$:/temp/palette-colours]getindex!match[ok]] +[count[]] }}}> + +<%if [compare:number:gt[0]] %> + +Palette test failures: <$text text=<>/> + +<$list filter="[[$:/temp/palette-colours]indexes[]prefix[?]sort[]]" variable="name"> + <%if [[$:/temp/palette-colours]getindex!match[ok]] %> +
+ ''<$text text={{{ [removeprefix[?]] }}}/>'': <$text text={{{ [[$:/temp/palette-colours]getindex] }}}/> +
+ <%endif%> + + +<%endif%> + + diff --git a/editions/prerelease/tiddlers/palette.tid b/editions/prerelease/tiddlers/palette.tid index afd78912b..9cd6f441c 100644 --- a/editions/prerelease/tiddlers/palette.tid +++ b/editions/prerelease/tiddlers/palette.tid @@ -1,3 +1,3 @@ title: $:/palette -$:/palettes/Vanilla \ No newline at end of file +$:/palettes/TwentyTwenties \ No newline at end of file