clay 0.0.1 → 0.1
raw patch · 7 files changed
+54/−30 lines, 7 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Clay.Geometry: maxHeight :: Size a -> Css
+ Clay.Geometry: maxWidth :: Size a -> Css
+ Clay.Selector: instance Show (f (Fix f)) => Show (Fix f)
+ Clay.Selector: instance Show Refinement
+ Clay.Selector: instance Show a => Show (SelectorF a)
+ Clay.Selector: instance Show f => Show (Path f)
+ Clay.Stylesheet: instance Show App
+ Clay.Stylesheet: instance Show Feature
+ Clay.Stylesheet: instance Show MediaQuery
+ Clay.Stylesheet: instance Show MediaType
+ Clay.Stylesheet: instance Show NotOrOnly
+ Clay.Stylesheet: instance Show Rule
- Clay.Font: Required :: (Size a) -> (Maybe (Size a)) -> [Literal] -> Required a
+ Clay.Font: Required :: (Size a) -> (Maybe (Size a)) -> [Text] -> [Text] -> Required a
- Clay.Font: fontFamily :: [Literal] -> Css
+ Clay.Font: fontFamily :: [Text] -> [Text] -> Css
- Clay.Font: monospace :: Literal
+ Clay.Font: monospace :: Text
- Clay.Font: sansSerif :: Literal
+ Clay.Font: sansSerif :: Text
- Clay.Font: serif :: Literal
+ Clay.Font: serif :: Text
Files
- clay.cabal +11/−5
- src/Clay/Display.hs +2/−2
- src/Clay/Font.hs +11/−8
- src/Clay/Geometry.hs +4/−2
- src/Clay/Render.hs +8/−11
- src/Clay/Selector.hs +8/−0
- src/Clay/Stylesheet.hs +10/−2
clay.cabal view
@@ -1,19 +1,25 @@ Name: clay-Version: 0.0.1+Version: 0.1 Synopsis: CSS preprocessor as embedded Haskell. Description: Clay is a CSS preprocessor like LESS and Sass, but implemented as an embedded domain specific language (EDSL) in Haskell. This means that all CSS selectors and style rules are first class Haskell functions, which makes reuse and composability easy.- .- The project is described on <http://sebastiaanvisser.github.com/clay>.- .- The API documentation can be found in the top level module "Clay".+ .+ > 0.0.1 -> 0.1+ > - Fixed bug in combined selector rendering.+ > - Fixed bug in font familty fallback category rendering.+ > - Added maxWidth and maxHeight.+ > - Fixed example code.+ > - Fixed overflowX/overflowY bug.+ > - Added some show instance for debugging purposes.+ > - Don't print the star (*) selector in the case of refinements.+ > - Refinements applied to the top level magically introduce star selector. Author: Sebastiaan Visser Maintainer: Sebastiaan Visser <code@fvisser.nl>
src/Clay/Display.hs view
@@ -147,8 +147,8 @@ overflow, overflowX, overflowY :: Overflow -> Css overflow = key "overflow"-overflowX = key "overflow-y"-overflowY = key "overflow-x"+overflowX = key "overflow-x"+overflowY = key "overflow-y" -------------------------------------------------------------------------------
src/Clay/Font.hs view
@@ -61,9 +61,11 @@ ) where +import Control.Applicative import Data.Text (pack) import Data.Monoid import Prelude hiding (Left, Right)+import Data.Text (Text) import Clay.Color import Clay.Common@@ -93,11 +95,12 @@ Required (Size a) (Maybe (Size a))- [Literal]+ [Text]+ [Text] instance Val (Required a) where- value (Required a Nothing c) = value (a ! c)- value (Required a (Just b) c) = value ((value a <> "/" <> value b) ! c)+ value (Required a Nothing c d) = value (a ! (Literal <$> c) ! d)+ value (Required a (Just b) c d) = value ((value a <> "/" <> value b) ! (Literal <$> c) ! d) instance Font ( Required a) instance Font (Optional, Required a)@@ -114,16 +117,16 @@ ------------------------------------------------------------------------------- -fontFamily :: [Literal] -> Css-fontFamily = key "font-family"+fontFamily :: [Text] -> [Text] -> Css+fontFamily a b = key "font-family" (value (Literal <$> a) ! value b) -sansSerif :: Literal+sansSerif :: Text sansSerif = "sans-serif" -serif :: Literal+serif :: Text serif = "serif" -monospace :: Literal+monospace :: Text monospace = "fixed" -------------------------------------------------------------------------------
src/Clay/Geometry.hs view
@@ -5,7 +5,7 @@ size, top, left, bottom, right -- * Sizing.-, width, height, minWidth, minHeight+, width, height, minWidth, minHeight, maxWidth, maxHeight -- * Padding. , padding@@ -33,12 +33,14 @@ bottom = key "bottom" right = key "right" -width, height, minWidth, minHeight :: Size a -> Css+width, height, minWidth, minHeight, maxWidth, maxHeight :: Size a -> Css width = key "width" height = key "height" minWidth = key "min-width" minHeight = key "min-height"+maxWidth = key "max-width"+maxHeight = key "max-height" -------------------------------------------------------------------------------
src/Clay/Render.hs view
@@ -17,7 +17,7 @@ import Data.Maybe import Data.Text (Text) import Data.Text.Lazy.Builder-import Prelude hiding (filter, (**))+import Prelude hiding ((**)) import qualified Data.Text as Text import qualified Data.Text.Lazy as Lazy@@ -141,10 +141,10 @@ merger (x:xs) = case x of Rule.Child s -> case xs of [] -> s; _ -> merger xs |> s- Sub s -> case xs of [] -> s; _ -> merger xs ** s- Root s -> s ** merger xs- Pop i -> merger (drop i (x:xs))- Self f -> merger xs `with` f+ Sub s -> case xs of [] -> s; _ -> merger xs ** s+ Root s -> s ** merger xs+ Pop i -> merger (drop i (x:xs))+ Self f -> case xs of [] -> star `with` f; _ -> merger xs `with` f collect :: (Key (), Value) -> [Either Text (Text, Text)] collect (Key ky, Value vl) =@@ -169,14 +169,14 @@ selector :: Config -> Selector -> Builder selector cfg = intersperse ("," <> newline cfg) . rec- where rec (In (SelectorF ft p)) = (<> filter ft) <$>+ where rec (In (SelectorF (Refinement ft) p)) = (<> foldMap predicate (sort ft)) <$> case p of- Star -> ["*"]+ Star -> if length ft == 0 then ["*"] else [""] Elem t -> [fromText t] Child a b -> ins " > " <$> rec a <*> rec b Deep a b -> ins " " <$> rec a <*> rec b Adjacent a b -> ins " + " <$> rec a <*> rec b- Combined a b -> join ((:) <$> rec a <*> (pure <$> rec b))+ Combined a b -> rec a ++ rec b where ins s a b = (a <> s <> b) predicate :: Predicate -> Builder@@ -191,7 +191,4 @@ AttrHyph a v -> [ "[", fromText a, "|='", fromText v, "']" ] Pseudo a -> [ ":", fromText a ] PseudoFunc a p -> [ ":", fromText a, "(", intersperse "," (map fromText p), ")" ]--filter :: Refinement -> Builder-filter = foldMap predicate . sort . unFilter
src/Clay/Selector.hs view
@@ -1,7 +1,10 @@ {-# LANGUAGE OverloadedStrings , FlexibleInstances+ , FlexibleContexts , GeneralizedNewtypeDeriving+ , StandaloneDeriving+ , UndecidableInstances #-} module Clay.Selector where @@ -132,6 +135,7 @@ deriving (Eq, Ord, Show) newtype Refinement = Refinement { unFilter :: [Predicate] }+ deriving Show instance IsString Refinement where fromString = filterFromText . fromString@@ -154,10 +158,14 @@ | Deep f f | Adjacent f f | Combined f f+ deriving Show newtype Fix f = In { out :: f (Fix f) } +deriving instance Show (f (Fix f)) => Show (Fix f)+ data SelectorF a = SelectorF Refinement (Path a)+ deriving Show type Selector = Fix SelectorF
src/Clay/Stylesheet.hs view
@@ -8,15 +8,21 @@ import Clay.Property import Clay.Common +-------------------------------------------------------------------------------+ newtype MediaType = MediaType Value- deriving (Val, Other)+ deriving (Val, Other, Show) data NotOrOnly = Not | Only+ deriving Show+ data MediaQuery = MediaQuery (Maybe NotOrOnly) MediaType [Feature]+ deriving Show data Feature = Feature Text (Maybe Value)+ deriving Show -----------------------------------------------------+------------------------------------------------------------------------------- data App = Self Refinement@@ -24,11 +30,13 @@ | Pop Int | Child Selector | Sub Selector+ deriving Show data Rule = Property (Key ()) Value | Nested App [Rule] | Query MediaQuery [Rule]+ deriving Show newtype StyleM a = S (Writer [Rule] a) deriving Monad