From 3f37803c34f3e7da4d62278ff179a4b0e651d7d3 Mon Sep 17 00:00:00 2001 From: Jesse McDonald Date: Mon, 4 May 2020 00:18:10 -0500 Subject: [PATCH] use view boxes instead of CSS :target to allow theme preview --- scripts/gen-theme-views.hs | 29 ++++++++++++++ svg/pacosako-theme.svg | 79 ++++++++++++++++++++++++-------------- svg/traditional-theme.svg | 79 ++++++++++++++++++++++++-------------- webpack.config.js | 9 +---- 4 files changed, 130 insertions(+), 66 deletions(-) create mode 100644 scripts/gen-theme-views.hs diff --git a/scripts/gen-theme-views.hs b/scripts/gen-theme-views.hs new file mode 100644 index 0000000..be3e2b7 --- /dev/null +++ b/scripts/gen-theme-views.hs @@ -0,0 +1,29 @@ +import Text.Printf + +edge = 28.223 :: Double +spacing = 32 :: Double +gap = spacing - edge +across = [("light", "left"), ("dark", "right"), ("dark", "left"), ("light", "right")] +down = ["king", "queen", "bishop", "knight", "rook", "pawn"] + +useElement :: Double -> Double -> String -> String -> String -> String +useElement x y side kind place = printf format name x y edge edge x y name + where + format = + "\n" ++ + "" + name = side ++ "_" ++ kind ++ "_" ++ place + +main = do + putStr $ unlines $ concat $ + flip map (zip [5*spacing,4*spacing..] down) $ \(y, kind) -> + flip map (zip [0,spacing..] across) $ \(x, (side, place)) -> + useElement x y side kind place + putStr " + printf "M%0.3f %0.3fH%0.3f" (0 - gap/2) (row*spacing-(gap/2)) (4*spacing - gap/2) + putStr $ flip concatMap [0..4] $ \col -> + printf "M%0.3f %0.3fV%0.3f" (col*spacing-(gap/2)) (0 - gap/2) (6*spacing - gap/2) + putStrLn "\"/>" + printf "viewBox=\"%.3f %0.3f %.3f %.3f\"\n" + (0-spacing) (0-gap) (6*spacing + 2*gap) (6*spacing + 2*gap) diff --git a/svg/pacosako-theme.svg b/svg/pacosako-theme.svg index 6abaf7b..d01df82 100644 --- a/svg/pacosako-theme.svg +++ b/svg/pacosako-theme.svg @@ -1,9 +1,5 @@ - - + @@ -190,28 +186,53 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/svg/traditional-theme.svg b/svg/traditional-theme.svg index dafeaca..59dc450 100644 --- a/svg/traditional-theme.svg +++ b/svg/traditional-theme.svg @@ -1,9 +1,5 @@ - - + @@ -186,28 +182,53 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/webpack.config.js b/webpack.config.js index 65976f6..9651d5f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -52,14 +52,7 @@ module.exports = { loader: "svgo-loader", options: { plugins: [ - { - cleanupIDs: { - preserve_prefix: [ - "light_", - "dark_" - ] - } - } + { cleanupIDs: false } ] } }