web/dreamstop.openfp.net · commit
Print each code's colour class from the one layer table
parents: d751da8635
Print each code's colour class from the one layer table The front page now marks each code with its own class and the stylesheet printed from the layer table in nix/site.nix colours it, so the page keeps no second copy of the code-to-layer table.
2 files changed
Diff
dreamstop-openfp-net-web/src/Site/View.hs | 20 +++----------------- nix/site.nix | 9 +++++++-- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/dreamstop-openfp-net-web/src/Site/View.hs b/dreamstop-openfp-net-web/src/Site/View.hs index 905d322..848b6e9 100644 @@ -174,8 +174,8 @@ view _ = | l <- ["Force", "Mood", "Aspect", "Phase", "Modality", "Negation", "Bound", "Evidence", "Nominalisation"] ] +-- | A reading's codes, each in its own class, which codepoints.css colours by +-- the code's layer, with brackets, separators and positions in neutral grey. codepoints :: MisoString -> View model action codepoints s = code_ [] (map token (groupBy sameCase (fromMisoString s :: String))) @@ -184,22 +184,8 @@ codepoints s = sameCase a b = isUpper a == isUpper b token :: String -> View model action - token w = span_ [classList [maybe "cp-mark" layerClass (layer w)]] [text (toMisoString w)] + token w = span_ [classList [if length w == 3 && all isUpper w then "cp-" <> toMisoString w else "cp-mark"]] [text (toMisoString w)] -- | The CSS class of a layer. layerClass :: MisoString -> MisoString layerClass l = "cp-" <> l - -layer :: String -> Maybe MisoString -layer = \case - w | w `elem` ["ASR", "DIR", "IRG", "DEC", "ADM", "CMS"] -> Just "Force" - | w `elem` ["FAC", "HYP", "COU"] -> Just "Mood" - | w `elem` ["PFV", "PRF", "PRG", "HAB"] -> Just "Aspect" - | w `elem` ["INC", "CSS", "CNT", "EXP"] -> Just "Phase" - | w `elem` ["DEO", "ABL", "TEL", "NEC", "WNC", "POS"] -> Just "Modality" - | w == "NEG" -> Just "Negation" - | w == "ONE" -> Just "Bound" - | w `elem` ["OBS", "PUP", "RPR", "INF", "REC"] -> Just "Evidence" - | w `elem` ["BSC", "OBJ"] -> Just "Nominalisation" - | otherwise -> Nothing diff --git a/nix/site.nix b/nix/site.nix index 6879b58..c1b4228 100644 @@ -113,9 +113,14 @@ local: mark = "#52525b"; }; layerNames = builtins.attrNames codepoints.layers; - # Each layer's colour as a class, for the front page and the manual. + # Each layer's colour as a class, and each code's class in its layer's + # colour, for the front page and the manual. codepointsCss = pkgs.writeText "codepoints.css" ( - lib.concatMapStrings (l: ".cp-${l} { color: ${codepoints.layers.${l}.colour}; }\n") layerNames + lib.concatMapStrings ( + l: + lib.concatMapStrings (code: ".cp-${code}, ") codepoints.layers.${l}.codes + + ".cp-${l} { color: ${codepoints.layers.${l}.colour}; }\n" + ) layerNames + ".cp-mark { color: ${codepoints.mark}; }\n" ); # Show rules that colour every code in the manual: a class in HTML,