mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-29 21:09:56 +00:00
Display test results at the bottom of the palette switcher
This commit is contained in:
parent
cd5bbcda8d
commit
9efcad9360
@ -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]]
|
||||
|
@ -2,6 +2,8 @@ title: $:/core/macros/CSS
|
||||
tags: $:/tags/Macro
|
||||
|
||||
\procedure actions-compile-palette-filtered(tempPalette,outputTitle)
|
||||
<!-- Note the join, needed to cope with palette entries containing spaces -->
|
||||
\function colour(name) [<tv-palette-name>getindex<name>] :else[<tv-palette-name>get[palette-import]getindex<name>] :map[subfilter<currentTiddler>join[ ]]
|
||||
<!-- Make the colour function use the input palette -->
|
||||
<$let
|
||||
tv-palette-name=<<tempPalette>>
|
||||
@ -77,6 +79,10 @@ tags: $:/tags/Macro
|
||||
[function[colour],<name>]
|
||||
\end color
|
||||
|
||||
\function tf.check-colour-contrast(paletteEntryA,paletteEntryB,threshold)
|
||||
[function[colour],<paletteEntryA>] [function[colour],<paletteEntryB>] +[colour-contrast:DeltaPhi[]compare:number:gt<threshold>then[ok]] :else[<paletteEntryA>addsuffix[/]addsuffix<paletteEntryB>addsuffix[ contrast is too low]]
|
||||
\end tf.check-colour-contrast
|
||||
|
||||
\define box-shadow(shadow)
|
||||
``
|
||||
-webkit-box-shadow: $shadow$;
|
||||
|
@ -24,3 +24,5 @@ title: $:/snippets/paletteswitcher
|
||||
</$list>
|
||||
</div>
|
||||
</$linkcatcher>
|
||||
|
||||
{{$:/snippets/palettetests}}
|
||||
|
19
core/wiki/palettetests.tid
Normal file
19
core/wiki/palettetests.tid
Normal file
@ -0,0 +1,19 @@
|
||||
title: $:/snippets/palettetests
|
||||
|
||||
<$let failureCount={{{ [[$:/temp/palette-colours]indexes[]prefix[?]] :filter[[$:/temp/palette-colours]getindex<currentTiddler>!match[ok]] +[count[]] }}}>
|
||||
|
||||
<%if [<failureCount>compare:number:gt[0]] %>
|
||||
|
||||
Palette test failures: <$text text=<<failureCount>>/>
|
||||
|
||||
<$list filter="[[$:/temp/palette-colours]indexes[]prefix[?]sort[]]" variable="name">
|
||||
<%if [[$:/temp/palette-colours]getindex<name>!match[ok]] %>
|
||||
<div>
|
||||
''<$text text={{{ [<name>removeprefix[?]] }}}/>'': <$text text={{{ [[$:/temp/palette-colours]getindex<name>] }}}/>
|
||||
</div>
|
||||
<%endif%>
|
||||
</$list>
|
||||
|
||||
<%endif%>
|
||||
|
||||
</$let>
|
@ -1,3 +1,3 @@
|
||||
title: $:/palette
|
||||
|
||||
$:/palettes/Vanilla
|
||||
$:/palettes/TwentyTwenties
|
Loading…
Reference in New Issue
Block a user