simple-css 0.0.2 → 0.0.3
raw patch · 4 files changed
+50/−32 lines, 4 filesdep ~blaze-html
Dependency ranges changed: blaze-html
Files
- example/Main.hs +41/−28
- simple-css.cabal +2/−2
- src/SimpleCss/Tricks/Shortcuts/Css.hs +6/−1
- src/SimpleCss/Tricks/Shortcuts/Html.hs +1/−1
example/Main.hs view
@@ -13,7 +13,7 @@ -- generates litle blog-site in current directory ----- css.css - css file+-- css.css - style sheets -- -- Home.html, Blog.html, About.html, Contact.html - pages @@ -23,16 +23,19 @@ -- colors -globalBkgCol = white -- cword "#b6ceff"-homeCol = black -- cword "#1936ca"-blogCol = blue -- cword "#4d67d8"-aboutCol = red -- cword "#9db1ec"-contactCol = green -- cword "#e2f1fe"+menuCol = cword "#4370b5"+menuBorderCol = cword "#3c5b88"++globalBkgCol = cword "#b7cff3"+homeCol = menuCol +blogCol = menuCol +aboutCol = menuCol +contactCol = menuCol menuTextCol = white -- borders -bttnBordWidth = px 25+bttnBorderWidth = px 25 ----------------------------------------------------@@ -44,9 +47,9 @@ pageColor :: Page -> Expr pageColor x = case x of- Home -> homeCol- Blog -> blogCol- About -> aboutCol+ Home -> homeCol+ Blog -> blogCol+ About -> aboutCol Contact -> contactCol pageLink :: Page -> String@@ -61,30 +64,39 @@ -- menu menus :: [Page] -> [Css Html]-menus = tabs vmenu <$> map (box . activeBttn) - <*> map (box . passiveBttn) - <*> map menuLinks - +menus = (tabs vmenu <$> map (box . (uncurry activeBttn) )+ <*> map (box . (uncurry passiveBttn) )+ <*> map (menuLinks . snd))+ . zip rads++-- different border-radius values for menu+rads = [(20, 0), (0, 0), (0, 0), (0, 20)]+ menuLinks :: Page -> Css Html menuLinks = a <$> pageLink <*> map toLower . show -activeBttn :: Page -> [Decl]-activeBttn x = border [left] C.solid bttnBordWidth (pageColor x) - ++ bttn (pageColor x) x+activeBttn :: (Int, Int) -> Page -> [Decl]+activeBttn r x = + padding [left] bttnBorderWidth+ ++ bttn r (pageColor x) x -passiveBttn :: Page -> [Decl]-passiveBttn = bttn globalBkgCol+passiveBttn :: (Int, Int) -> Page -> [Decl]+passiveBttn r = bttn r globalBkgCol -bttn :: Expr -> Page -> [Decl]-bttn col x = border [right] C.solid bttnBordWidth col - ++ padding sides (px 10)+bttn :: (Int, Int) -> Expr -> Page -> [Decl]+bttn (tr, br) col x = border [top, bottom, right] C.solid (px 1) menuBorderCol + ++ border [left] C.solid (px 5) menuCol+ ++ margin [bottom] (px 3) + ++ margin [right] (px 40)+ ++ padding [top, bottom] (px 10)+ ++ borderRadius [int 0, px tr, px br, int 0] ++ brick menuTextCol (pageColor x) -- header pageHeader :: Page -> Css Html pageHeader x = dot ([C.textAlign <:> C.center] - ++ (color $ pageColor x)) $ h1 $ show x+ ++ (color menuBorderCol)) $ h1 $ show x -- content @@ -99,11 +111,12 @@ Contact -> text 10000 blogItem d n = vcat [st $ h3 d, text n]- where st = dot $ (padding sides $ px 5 ) - ++ (brick menuTextCol $ pageColor Blog) + where st = dot $ borderRadius [px 5, int 0, int 0, px 5]+ ++ (padding sides $ px 5 ) + ++ (brick menuTextCol $ pageColor Blog) text :: Int -> Css Html-text n = dot (padding [bottom] (pct 5) +text n = dot ((padding [bottom] (pct 5)) ++ margin sides (pct 5)) $ p $ take n $ cycle "once upon a text " @@ -118,7 +131,7 @@ footer x = dot ( borderNone sides ++ margin sides (int 0) - ++ brick menuTextCol (pageColor x)+ ++ brick menuTextCol (menuBorderCol) ++ (padding sides $ px 10)) $ p "simple-css : example" @@ -129,7 +142,7 @@ htmls m p = vcat [ footer p, dot ((margin sides $ int 0) ++ borderNone sides) $- leftContent pct 20 m $ addBorder $ vcat [pageHeader p, pageContent p]]+ leftContent pct 20 (dot (margin [top] $ px 25) m) $ addBorder $ vcat [pageHeader p, pageContent p]] where addBorder = dot $ (margin [left] (px 20)) -------------------------------------------------------------------
simple-css.cabal view
@@ -1,5 +1,5 @@ Name: simple-css-Version: 0.0.2+Version: 0.0.3 Cabal-Version: >= 1.6 License: BSD3 License-file: LICENSE@@ -24,7 +24,7 @@ Library Build-Depends:- base >= 4, base < 5, containers == 0.*, language-css == 0.0.1, blaze-html >= 0.2 && <= 0.3 + base >= 4, base < 5, containers == 0.*, language-css == 0.0.1, blaze-html >= 0.3.0.1 Hs-Source-Dirs: src/ Exposed-Modules: SimpleCss
src/SimpleCss/Tricks/Shortcuts/Css.hs view
@@ -27,7 +27,7 @@ -- ** border BorderStyle, BorderWidth, BorderColor,- border, borderNone,+ border, borderNone, borderRadius, -- ** margin margin,@@ -175,6 +175,11 @@ borderNone :: [Dir] -> [Decl] borderNone dirs = map fromDir dirs where fromDir x = (ident $ "border" ++ show x) <:> int 0++-- | sets @border-radius@ property+borderRadius :: [Expr] -> [Decl]+borderRadius rs = map ((<:> spaces rs) . ident)+ ["border-radius", "-webkit-border-radius", "-moz-border-radius"] -- | sets @margin@ width margin :: [Dir] -> Expr -> [Decl]
src/SimpleCss/Tricks/Shortcuts/Html.hs view
@@ -126,7 +126,7 @@ encoding :: String -> H.Html-encoding str = H.meta H.! HA.http_equiv (H.stringValue "Content-Type")+encoding str = H.meta H.! HA.httpEquiv (H.stringValue "Content-Type") H.! HA.content (H.stringValue "text/html") H.! HA.charset (H.stringValue str)