From 8e840900a34a462f221f86aa7c0345ada46a1827 Mon Sep 17 00:00:00 2001 From: Adrian Cochrane Date: Sun, 4 Jun 2023 15:48:35 +1200 Subject: [PATCH] Handle initial colour values. --- lib/Graphics/Rendering/Rect/CSS/Colour.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Graphics/Rendering/Rect/CSS/Colour.hs b/lib/Graphics/Rendering/Rect/CSS/Colour.hs index 306b77c..852dba2 100644 --- a/lib/Graphics/Rendering/Rect/CSS/Colour.hs +++ b/lib/Graphics/Rendering/Rect/CSS/Colour.hs @@ -28,12 +28,15 @@ data ColourPallet = ColourPallet { } instance PropertyParser ColourPallet where - temp = ColourPallet { foreground = opaque blue, accent = opaque blue } + temp = ColourPallet { foreground = opaque black, accent = opaque blue } inherit = id priority _ = ["color", "accent"] + longhand _ self "color" [Ident "initial"]=Just self {foreground=opaque black} longhand _ self "color" toks | Just ([], val) <- parseColour self toks = Just self { foreground = val } + longhand _ self "accent-color" [Ident kw] + | kw `elem` ["initial", "auto"] = Just self {accent = opaque blue} longhand _ self "accent-color" t | Just ([], val) <- parseColour self t = Just self { accent = val } longhand _ _ _ _ = Nothing @@ -232,7 +235,7 @@ parseColour _ (Ident x:toks) | Txt.toLower x == "transparent" = Just (toks, transparent) -- FIXME: Add infrastructure to prioritize resolving `color` parseColour self (Ident x:toks) - | Txt.toLower x == "currentcolor" = Just (toks, foreground self) + | Txt.toLower x `elem` ["currentcolor","initial"]=Just (toks,foreground self) | Txt.toLower x == "accentcolor" = Just (toks, accent self) parseColour _ (Function "hsl":h':Comma: -- 2.30.2