From 386d499a61e0cb49bdd33b1dca2e24711b6902fe Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Wed, 22 Jun 2016 20:58:42 +0000 Subject: [PATCH] Define colors in dedicated Vervis.Palette module --- src/Vervis/Palette.hs | 68 +++++++++++++++++++++++++++++++++++++++++++ src/Vervis/Style.hs | 40 +++++++++++++------------ vervis.cabal | 1 + 3 files changed, 90 insertions(+), 19 deletions(-) create mode 100644 src/Vervis/Palette.hs diff --git a/src/Vervis/Palette.hs b/src/Vervis/Palette.hs new file mode 100644 index 0000000..57f2576 --- /dev/null +++ b/src/Vervis/Palette.hs @@ -0,0 +1,68 @@ +{- This file is part of Vervis. + - + - Written in 2016 by fr33domlover . + - + - ♡ Copying is an act of love. Please copy, reuse and share. + - + - The author(s) have dedicated all copyright and related and neighboring + - rights to this software to the public domain worldwide. This software is + - distributed without any warranty. + - + - You should have received a copy of the CC0 Public Domain Dedication along + - with this software. If not, see + - . + -} + +-- | Colors to use in UI. Syntax highlighting, diagrams, CSS and so on. +-- Currently the 16 Tango colors are being used here. +module Vervis.Palette + ( black + , white + , plain + , darkRed + , darkGreen + , darkYellow + , darkBlue + , darkMagenta + , darkCyan + , darkGray + , lightRed + , lightGreen + , lightYellow + , lightBlue + , lightMagenta + , lightCyan + , lightGray + ) +where + +import Prelude + +import Data.Word (Word8) + +type RGB = (Word8, Word8, Word8) + +black, white, plain :: RGB +black = (0x00, 0x00, 0x00) +white = (0xEE, 0xEE, 0xEC) +plain = (0xCC, 0xCC, 0xCC) + +darkRed, darkGreen, darkYellow, darkBlue, darkMagenta, darkCyan, darkGray + :: RGB +darkRed = (0xCC, 0x00, 0x00) +darkGreen = (0x4E, 0x9A, 0x06) +darkYellow = (0xC4, 0xA0, 0x00) +darkBlue = (0x34, 0x65, 0xA4) +darkMagenta = (0x75, 0x50, 0x7B) +darkCyan = (0x06, 0x98, 0x9A) +darkGray = (0x55, 0x57, 0x53) + +lightRed, lightGreen, lightYellow, lightBlue :: RGB +lightMagenta, lightCyan, lightGray :: RGB +lightRed = (0xEF, 0x29, 0x29) +lightGreen = (0x8A, 0xE2, 0x34) +lightYellow = (0xFC, 0xE9, 0x4F) +lightBlue = (0x73, 0x9F, 0xCF) +lightMagenta = (0xAD, 0x7F, 0xA8) +lightCyan = (0x34, 0xE2, 0xE2) +lightGray = (0xD3, 0xD7, 0xCF) diff --git a/src/Vervis/Style.hs b/src/Vervis/Style.hs index 2d5dba7..c657a2c 100644 --- a/src/Vervis/Style.hs +++ b/src/Vervis/Style.hs @@ -43,6 +43,8 @@ import Text.Cassius (ToCss (..)) import qualified Text.Cassius as C (Color (Color)) +import qualified Vervis.Palette as P + data Lightness = Light | Dark data Color @@ -59,25 +61,25 @@ data Color instance ToCss Color where toCss col = - let c r g b = toCss $ C.Color r g b - in case col of - Black -> c 0x00 0x00 0x00 - Red Dark -> c 0xCC 0x00 0x00 - Red Light -> c 0xEF 0x29 0x29 - Green Dark -> c 0x4E 0x9A 0x06 - Green Light -> c 0x8A 0xE2 0x34 - Yellow Dark -> c 0xC4 0xA0 0x00 - Yellow Light -> c 0xFC 0xE9 0x4F - Blue Dark -> c 0x34 0x65 0xA4 - Blue Light -> c 0x73 0x9F 0xCF - Magenta Dark -> c 0x75 0x50 0x7B - Magenta Light -> c 0xAD 0x7F 0xA8 - Cyan Dark -> c 0x06 0x98 0x9A - Cyan Light -> c 0x34 0xE2 0xE2 - Gray Dark -> c 0x55 0x57 0x53 - Gray Light -> c 0xD3 0xD7 0xCF - White -> c 0xEE 0xEE 0xEC - PlainText -> c 0xCC 0xCC 0xCC + let c (r, g, b) = toCss $ C.Color r g b + in c $ case col of + Black -> P.black + Red Dark -> P.darkRed + Red Light -> P.lightRed + Green Dark -> P.darkGreen + Green Light -> P.lightGreen + Yellow Dark -> P.darkYellow + Yellow Light -> P.lightYellow + Blue Dark -> P.darkBlue + Blue Light -> P.lightBlue + Magenta Dark -> P.darkMagenta + Magenta Light -> P.lightMagenta + Cyan Dark -> P.darkCyan + Cyan Light -> P.lightCyan + Gray Dark -> P.darkGray + Gray Light -> P.lightGray + White -> P.white + PlainText -> P.plain newtype Hue = Hue (Lightness -> Color) diff --git a/vervis.cabal b/vervis.cabal index ac256c3..c7f984b 100644 --- a/vervis.cabal +++ b/vervis.cabal @@ -131,6 +131,7 @@ library Vervis.Model.Repo Vervis.Model.Role Vervis.Paginate + Vervis.Palette Vervis.Path Vervis.Query Vervis.Readme