atomic-css 0.1.0 → 0.2.0
raw patch · 11 files changed
+66/−31 lines, 11 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Web.Atomic.CSS: ($dmstyle) :: (ToStyle a, Show a) => a -> Style
- Web.Atomic.CSS: instance GHC.Internal.Show.Show Web.Atomic.CSS.ListType
- Web.Atomic.CSS: style :: ToStyle a => a -> Style
- Web.Atomic.CSS.Box: instance GHC.Internal.Show.Show Web.Atomic.CSS.Box.BorderStyle
- Web.Atomic.CSS.Box: instance GHC.Internal.Show.Show Web.Atomic.CSS.Box.Inner
- Web.Atomic.CSS.Layout: instance GHC.Internal.Show.Show Web.Atomic.CSS.Layout.Display
- Web.Atomic.CSS.Layout: instance GHC.Internal.Show.Show Web.Atomic.CSS.Layout.FlexDirection
- Web.Atomic.CSS.Layout: instance GHC.Internal.Show.Show Web.Atomic.CSS.Layout.FlexWrap
- Web.Atomic.CSS.Layout: instance GHC.Internal.Show.Show Web.Atomic.CSS.Layout.Overflow
- Web.Atomic.CSS.Layout: instance GHC.Internal.Show.Show Web.Atomic.CSS.Layout.Position
- Web.Atomic.CSS.Layout: instance GHC.Internal.Show.Show Web.Atomic.CSS.Layout.Visibility
- Web.Atomic.CSS.Text: instance GHC.Internal.Show.Show Web.Atomic.CSS.Text.Align
- Web.Atomic.CSS.Text: instance GHC.Internal.Show.Show Web.Atomic.CSS.Text.WhiteSpace
- Web.Atomic.CSS.Transition: instance GHC.Internal.Show.Show Web.Atomic.CSS.Transition.TransitionProperty
- Web.Atomic.Html: instance GHC.Internal.Base.Applicative Web.Atomic.Html.Html
- Web.Atomic.Html: instance GHC.Internal.Base.Functor Web.Atomic.Html.Html
- Web.Atomic.Html: instance GHC.Internal.Base.Monad Web.Atomic.Html.Html
- Web.Atomic.Html: instance GHC.Internal.Data.String.IsString (Web.Atomic.Html.Html ())
- Web.Atomic.Html: instance GHC.Internal.Data.String.IsString Web.Atomic.Html.Node
- Web.Atomic.Html: instance GHC.Internal.IsList.IsList (Web.Atomic.Html.Html ())
- Web.Atomic.Render: instance GHC.Internal.Data.String.IsString Web.Atomic.Render.Line
- Web.Atomic.Render: instance GHC.Internal.Show.Show Web.Atomic.Render.Line
- Web.Atomic.Render: instance GHC.Internal.Show.Show Web.Atomic.Render.LineEnd
- Web.Atomic.Types.Attributable: instance (Web.Atomic.Types.Attributable.Attributable a, Web.Atomic.Types.Attributable.Attributable b) => Web.Atomic.Types.Attributable.Attributable (a -> b)
- Web.Atomic.Types.Attributable: instance forall k (h :: k). GHC.Internal.Base.Monoid (Web.Atomic.Types.Attributable.Attributes h)
- Web.Atomic.Types.Attributable: instance forall k (h :: k). GHC.Internal.Base.Semigroup (Web.Atomic.Types.Attributable.Attributes h)
- Web.Atomic.Types.ClassName: instance GHC.Internal.Base.Monoid Web.Atomic.Types.ClassName.ClassName
- Web.Atomic.Types.ClassName: instance GHC.Internal.Base.Semigroup Web.Atomic.Types.ClassName.ClassName
- Web.Atomic.Types.ClassName: instance GHC.Internal.Data.String.IsString Web.Atomic.Types.ClassName.ClassName
- Web.Atomic.Types.ClassName: instance GHC.Internal.Show.Show Web.Atomic.Types.ClassName.ClassName
- Web.Atomic.Types.Rule: instance GHC.Internal.Base.Monoid Web.Atomic.Types.Rule.RuleSelector
- Web.Atomic.Types.Rule: instance GHC.Internal.Base.Semigroup Web.Atomic.Types.Rule.RuleSelector
- Web.Atomic.Types.Rule: instance GHC.Internal.Data.String.IsString Web.Atomic.Types.Rule.Rule
- Web.Atomic.Types.Selector: instance GHC.Internal.Base.Monoid Web.Atomic.Types.Selector.MediaQuery
- Web.Atomic.Types.Selector: instance GHC.Internal.Base.Monoid Web.Atomic.Types.Selector.Selector
- Web.Atomic.Types.Selector: instance GHC.Internal.Base.Semigroup Web.Atomic.Types.Selector.MediaQuery
- Web.Atomic.Types.Selector: instance GHC.Internal.Base.Semigroup Web.Atomic.Types.Selector.Selector
- Web.Atomic.Types.Selector: instance GHC.Internal.Data.String.IsString Web.Atomic.Types.Selector.MediaQuery
- Web.Atomic.Types.Selector: instance GHC.Internal.Data.String.IsString Web.Atomic.Types.Selector.Pseudo
- Web.Atomic.Types.Selector: instance GHC.Internal.Data.String.IsString Web.Atomic.Types.Selector.Selector
- Web.Atomic.Types.Selector: instance GHC.Internal.IsList.IsList Web.Atomic.Types.Selector.MediaQuery
- Web.Atomic.Types.Selector: instance GHC.Internal.Show.Show Web.Atomic.Types.Selector.Media
- Web.Atomic.Types.Selector: instance GHC.Internal.Show.Show Web.Atomic.Types.Selector.MediaQuery
- Web.Atomic.Types.Selector: instance GHC.Internal.Show.Show Web.Atomic.Types.Selector.Pseudo
- Web.Atomic.Types.Selector: instance GHC.Internal.Show.Show Web.Atomic.Types.Selector.Selector
- Web.Atomic.Types.Style: instance GHC.Internal.Base.Monoid Web.Atomic.Types.Style.Style
- Web.Atomic.Types.Style: instance GHC.Internal.Base.Semigroup Web.Atomic.Types.Style.Property
- Web.Atomic.Types.Style: instance GHC.Internal.Base.Semigroup Web.Atomic.Types.Style.Style
- Web.Atomic.Types.Style: instance GHC.Internal.Data.String.IsString Web.Atomic.Types.Style.HexColor
- Web.Atomic.Types.Style: instance GHC.Internal.Data.String.IsString Web.Atomic.Types.Style.Property
- Web.Atomic.Types.Style: instance GHC.Internal.Data.String.IsString Web.Atomic.Types.Style.Style
- Web.Atomic.Types.Style: instance GHC.Internal.Enum.Enum Web.Atomic.Types.Style.PxRem
- Web.Atomic.Types.Style: instance GHC.Internal.Num.Num Web.Atomic.Types.Style.Length
- Web.Atomic.Types.Style: instance GHC.Internal.Num.Num Web.Atomic.Types.Style.Ms
- Web.Atomic.Types.Style: instance GHC.Internal.Num.Num Web.Atomic.Types.Style.PxRem
- Web.Atomic.Types.Style: instance GHC.Internal.Num.Num a => GHC.Internal.Num.Num (Web.Atomic.Types.Style.Sides a)
- Web.Atomic.Types.Style: instance GHC.Internal.Real.Integral Web.Atomic.Types.Style.PxRem
- Web.Atomic.Types.Style: instance GHC.Internal.Real.Real Web.Atomic.Types.Style.PxRem
- Web.Atomic.Types.Style: instance GHC.Internal.Show.Show Web.Atomic.Types.Style.Auto
- Web.Atomic.Types.Style: instance GHC.Internal.Show.Show Web.Atomic.Types.Style.Declaration
- Web.Atomic.Types.Style: instance GHC.Internal.Show.Show Web.Atomic.Types.Style.HexColor
- Web.Atomic.Types.Style: instance GHC.Internal.Show.Show Web.Atomic.Types.Style.Length
- Web.Atomic.Types.Style: instance GHC.Internal.Show.Show Web.Atomic.Types.Style.Ms
- Web.Atomic.Types.Style: instance GHC.Internal.Show.Show Web.Atomic.Types.Style.None
- Web.Atomic.Types.Style: instance GHC.Internal.Show.Show Web.Atomic.Types.Style.Normal
- Web.Atomic.Types.Style: instance GHC.Internal.Show.Show Web.Atomic.Types.Style.Property
- Web.Atomic.Types.Style: instance GHC.Internal.Show.Show Web.Atomic.Types.Style.PxRem
- Web.Atomic.Types.Style: instance GHC.Internal.Show.Show Web.Atomic.Types.Style.Style
- Web.Atomic.Types.Style: instance GHC.Internal.Show.Show Web.Atomic.Types.Style.Wrap
- Web.Atomic.Types.Style: instance Web.Atomic.Types.Style.ToStyle GHC.Internal.Base.String
- Web.Atomic.Types.Styleable: instance (Web.Atomic.Types.Styleable.Styleable a, Web.Atomic.Types.Styleable.Styleable b) => Web.Atomic.Types.Styleable.Styleable (a -> b)
- Web.Atomic.Types.Styleable: instance forall k (h :: k). GHC.Internal.Base.Monoid (Web.Atomic.Types.Styleable.CSS h)
- Web.Atomic.Types.Styleable: instance forall k (h :: k). GHC.Internal.Base.Semigroup (Web.Atomic.Types.Styleable.CSS h)
+ Web.Atomic: tag' :: Bool -> Text -> Html () -> Html ()
+ Web.Atomic.CSS: Clip :: Overflow
+ Web.Atomic.CSS: Scroll :: Overflow
+ Web.Atomic.CSS: data Overflow
+ Web.Atomic.CSS: instance GHC.Show.Show Web.Atomic.CSS.ListType
+ Web.Atomic.CSS.Box: instance GHC.Show.Show Web.Atomic.CSS.Box.BorderStyle
+ Web.Atomic.CSS.Box: instance GHC.Show.Show Web.Atomic.CSS.Box.Inner
+ Web.Atomic.CSS.Layout: instance GHC.Show.Show Web.Atomic.CSS.Layout.Display
+ Web.Atomic.CSS.Layout: instance GHC.Show.Show Web.Atomic.CSS.Layout.FlexDirection
+ Web.Atomic.CSS.Layout: instance GHC.Show.Show Web.Atomic.CSS.Layout.FlexWrap
+ Web.Atomic.CSS.Layout: instance GHC.Show.Show Web.Atomic.CSS.Layout.Overflow
+ Web.Atomic.CSS.Layout: instance GHC.Show.Show Web.Atomic.CSS.Layout.Position
+ Web.Atomic.CSS.Layout: instance GHC.Show.Show Web.Atomic.CSS.Layout.Visibility
+ Web.Atomic.CSS.Layout: maxHeight :: Styleable h => Length -> CSS h -> CSS h
+ Web.Atomic.CSS.Layout: maxWidth :: Styleable h => Length -> CSS h -> CSS h
+ Web.Atomic.CSS.Text: instance GHC.Show.Show Web.Atomic.CSS.Text.Align
+ Web.Atomic.CSS.Text: instance GHC.Show.Show Web.Atomic.CSS.Text.WhiteSpace
+ Web.Atomic.CSS.Transition: instance GHC.Show.Show Web.Atomic.CSS.Transition.TransitionProperty
+ Web.Atomic.Html: fromElement :: Element -> Html ()
+ Web.Atomic.Html: instance Data.String.IsString (Web.Atomic.Html.Html ())
+ Web.Atomic.Html: instance Data.String.IsString Web.Atomic.Html.Node
+ Web.Atomic.Html: instance GHC.Base.Applicative Web.Atomic.Html.Html
+ Web.Atomic.Html: instance GHC.Base.Functor Web.Atomic.Html.Html
+ Web.Atomic.Html: instance GHC.Base.Monad Web.Atomic.Html.Html
+ Web.Atomic.Html: instance GHC.IsList.IsList (Web.Atomic.Html.Html ())
+ Web.Atomic.Html: tag' :: Bool -> Text -> Html () -> Html ()
+ Web.Atomic.Render: instance Data.String.IsString Web.Atomic.Render.Line
+ Web.Atomic.Render: instance GHC.Show.Show Web.Atomic.Render.Line
+ Web.Atomic.Render: instance GHC.Show.Show Web.Atomic.Render.LineEnd
+ Web.Atomic.Types.Attributable: instance Web.Atomic.Types.Attributable.Attributable b => Web.Atomic.Types.Attributable.Attributable (a -> b)
+ Web.Atomic.Types.Attributable: instance forall k (h :: k). GHC.Base.Monoid (Web.Atomic.Types.Attributable.Attributes h)
+ Web.Atomic.Types.Attributable: instance forall k (h :: k). GHC.Base.Semigroup (Web.Atomic.Types.Attributable.Attributes h)
+ Web.Atomic.Types.ClassName: instance Data.String.IsString Web.Atomic.Types.ClassName.ClassName
+ Web.Atomic.Types.ClassName: instance GHC.Base.Monoid Web.Atomic.Types.ClassName.ClassName
+ Web.Atomic.Types.ClassName: instance GHC.Base.Semigroup Web.Atomic.Types.ClassName.ClassName
+ Web.Atomic.Types.ClassName: instance GHC.Show.Show Web.Atomic.Types.ClassName.ClassName
+ Web.Atomic.Types.Rule: instance Data.String.IsString Web.Atomic.Types.Rule.Rule
+ Web.Atomic.Types.Rule: instance GHC.Base.Monoid Web.Atomic.Types.Rule.RuleSelector
+ Web.Atomic.Types.Rule: instance GHC.Base.Semigroup Web.Atomic.Types.Rule.RuleSelector
+ Web.Atomic.Types.Selector: instance Data.String.IsString Web.Atomic.Types.Selector.MediaQuery
+ Web.Atomic.Types.Selector: instance Data.String.IsString Web.Atomic.Types.Selector.Pseudo
+ Web.Atomic.Types.Selector: instance Data.String.IsString Web.Atomic.Types.Selector.Selector
+ Web.Atomic.Types.Selector: instance GHC.Base.Monoid Web.Atomic.Types.Selector.MediaQuery
+ Web.Atomic.Types.Selector: instance GHC.Base.Monoid Web.Atomic.Types.Selector.Selector
+ Web.Atomic.Types.Selector: instance GHC.Base.Semigroup Web.Atomic.Types.Selector.MediaQuery
+ Web.Atomic.Types.Selector: instance GHC.Base.Semigroup Web.Atomic.Types.Selector.Selector
+ Web.Atomic.Types.Selector: instance GHC.IsList.IsList Web.Atomic.Types.Selector.MediaQuery
+ Web.Atomic.Types.Selector: instance GHC.Show.Show Web.Atomic.Types.Selector.Media
+ Web.Atomic.Types.Selector: instance GHC.Show.Show Web.Atomic.Types.Selector.MediaQuery
+ Web.Atomic.Types.Selector: instance GHC.Show.Show Web.Atomic.Types.Selector.Pseudo
+ Web.Atomic.Types.Selector: instance GHC.Show.Show Web.Atomic.Types.Selector.Selector
+ Web.Atomic.Types.Style: instance Data.String.IsString Web.Atomic.Types.Style.HexColor
+ Web.Atomic.Types.Style: instance Data.String.IsString Web.Atomic.Types.Style.Property
+ Web.Atomic.Types.Style: instance Data.String.IsString Web.Atomic.Types.Style.Style
+ Web.Atomic.Types.Style: instance GHC.Base.Monoid Web.Atomic.Types.Style.Style
+ Web.Atomic.Types.Style: instance GHC.Base.Semigroup Web.Atomic.Types.Style.Property
+ Web.Atomic.Types.Style: instance GHC.Base.Semigroup Web.Atomic.Types.Style.Style
+ Web.Atomic.Types.Style: instance GHC.Enum.Enum Web.Atomic.Types.Style.PxRem
+ Web.Atomic.Types.Style: instance GHC.Num.Num Web.Atomic.Types.Style.Length
+ Web.Atomic.Types.Style: instance GHC.Num.Num Web.Atomic.Types.Style.Ms
+ Web.Atomic.Types.Style: instance GHC.Num.Num Web.Atomic.Types.Style.PxRem
+ Web.Atomic.Types.Style: instance GHC.Num.Num a => GHC.Num.Num (Web.Atomic.Types.Style.Sides a)
+ Web.Atomic.Types.Style: instance GHC.Real.Integral Web.Atomic.Types.Style.PxRem
+ Web.Atomic.Types.Style: instance GHC.Real.Real Web.Atomic.Types.Style.PxRem
+ Web.Atomic.Types.Style: instance GHC.Show.Show Web.Atomic.Types.Style.Auto
+ Web.Atomic.Types.Style: instance GHC.Show.Show Web.Atomic.Types.Style.Declaration
+ Web.Atomic.Types.Style: instance GHC.Show.Show Web.Atomic.Types.Style.HexColor
+ Web.Atomic.Types.Style: instance GHC.Show.Show Web.Atomic.Types.Style.Length
+ Web.Atomic.Types.Style: instance GHC.Show.Show Web.Atomic.Types.Style.Ms
+ Web.Atomic.Types.Style: instance GHC.Show.Show Web.Atomic.Types.Style.None
+ Web.Atomic.Types.Style: instance GHC.Show.Show Web.Atomic.Types.Style.Normal
+ Web.Atomic.Types.Style: instance GHC.Show.Show Web.Atomic.Types.Style.Property
+ Web.Atomic.Types.Style: instance GHC.Show.Show Web.Atomic.Types.Style.PxRem
+ Web.Atomic.Types.Style: instance GHC.Show.Show Web.Atomic.Types.Style.Style
+ Web.Atomic.Types.Style: instance GHC.Show.Show Web.Atomic.Types.Style.Wrap
+ Web.Atomic.Types.Style: instance Web.Atomic.Types.Style.ToStyle GHC.Base.String
+ Web.Atomic.Types.Styleable: instance Web.Atomic.Types.Styleable.Styleable b => Web.Atomic.Types.Styleable.Styleable (a -> b)
+ Web.Atomic.Types.Styleable: instance forall k (h :: k). GHC.Base.Monoid (Web.Atomic.Types.Styleable.CSS h)
+ Web.Atomic.Types.Styleable: instance forall k (h :: k). GHC.Base.Semigroup (Web.Atomic.Types.Styleable.CSS h)
Files
- CHANGELOG.md +11/−3
- atomic-css.cabal +1/−1
- src/Web/Atomic.hs +4/−3
- src/Web/Atomic/CSS.hs +3/−2
- src/Web/Atomic/CSS/Layout.hs +17/−9
- src/Web/Atomic/Html.hs +11/−1
- src/Web/Atomic/Html/Tag.hs +1/−1
- src/Web/Atomic/Render.hs +7/−9
- src/Web/Atomic/Types/Attributable.hs +1/−1
- src/Web/Atomic/Types/Styleable.hs +1/−1
- test/Test/RenderSpec.hs +9/−0
CHANGELOG.md view
@@ -1,11 +1,20 @@ # Revision history for atomic-css +## atomic-css 0.2.0++* Added Html.Tag+* refactored overflow, whiteSpace, instead of clip and scroll+* maxWidth, maxHeight+* raw is inline+* change default exports+ ## atomic-css 0.1.0 -This package renamed to atomic-css with a focus on css utilities. View, Url and other Hyperbole-specific types moved to Hyperbole. Still provides an Html monad+Renamed library to atomic-css with a focus on css utilities. View, Url and other Hyperbole-specific types moved to Hyperbole. Still provides an Html monad+ Major rewrite of Library and API * New interface with operators: (@) for attributes, (~) to utilities- * Defining custom CSS and new utilities is more intuitive+ * Defining custom CSS selectors and new utilities is more intuitive ## web-view 0.7.0 @@ -28,7 +37,6 @@ * extClass to add external css class * inline elements * Url: no longer lowercases automatically. Show/Read instance-* ## web-view 0.4.0
atomic-css.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: atomic-css-version: 0.1.0+version: 0.2.0 synopsis: Type-safe, composable CSS utility functions. Inspired by Tailwindcss and Elm-UI description: Type-safe, composable CSS utility functions. Inspired by Tailwindcss and Elm-UI . See documentation for the @Web.Atomic@ module below category: Web
src/Web/Atomic.hs view
@@ -22,14 +22,15 @@ , Html , el , tag+ , tag' , none , raw , text - -- ** Layout+ -- ** Layout , module Web.Atomic.Html.Tag - -- ** Rendering+ -- ** Rendering , renderText , renderLazyText , renderLazyByteString@@ -37,9 +38,9 @@ import Web.Atomic.CSS import Web.Atomic.Html+import Web.Atomic.Html.Tag import Web.Atomic.Render import Web.Atomic.Types-import Web.Atomic.Html.Tag -- TODO: update readme
src/Web/Atomic/CSS.hs view
@@ -45,6 +45,7 @@ , right , left , overflow+ , Overflow (..) -- ** Flexbox -- $flexbox@@ -119,7 +120,7 @@ , Property , Declaration (..) , Style- , ToStyle (..)+ , ToStyle , PropertyStyle (..) , None (..) , Auto (..)@@ -188,7 +189,7 @@ {- $flexbox -We can intuitively create layouts by combining of 'flexRow', 'flexCol', 'grow', and 'stack'+We can intuitively create layouts by combining 'flexRow', 'flexCol', 'grow', and 'stack' @ holygrail = do
src/Web/Atomic/CSS/Layout.hs view
@@ -9,7 +9,7 @@ Stability: experimental Portability: portable -We can intuitively create layouts by combining of 'flexRow', 'flexCol', 'grow', and 'stack'+We can intuitively create layouts by combining 'flexRow', 'flexCol', 'grow', and 'stack' @@@ -38,8 +38,6 @@ > el " - " ~ grow > el "Bottom" -}-- flexCol :: (Styleable h) => CSS h -> CSS h flexCol = utility@@ -48,6 +46,7 @@ , "flex-direction" :. style Column ] + {- | Lay out children in a row. See 'Web.Atomic.Html.Tag.row' > el ~ flexRow $ do@@ -64,8 +63,6 @@ ] -- -- | Grow to fill the available space in the parent 'flexRow' or 'flexCol' grow :: (Styleable h) => CSS h -> CSS h grow = utility "grow" ["flex-grow" :. "1"]@@ -226,9 +223,10 @@ deriving (Show, ToClassName, ToStyle) -visibility :: Styleable h => Visibility -> CSS h -> CSS h+visibility :: (Styleable h) => Visibility -> CSS h -> CSS h visibility v = utility ("vis" -. v) ["visibility" :. style v] + {- | Set to specific width > el ~ width 100 $ "100px"@@ -236,11 +234,11 @@ > el ~ width (Pct 50) $ "50pct" -} width :: (Styleable h) => Length -> CSS h -> CSS h-width n = utility ("w" -. n) [ "width" :. style n ]+width n = utility ("w" -. n) ["width" :. style n] height :: (Styleable h) => Length -> CSS h -> CSS h-height n = utility ("h" -. n) [ "height" :. style n ]+height n = utility ("h" -. n) ["height" :. style n] -- | Allow width to grow to contents but not shrink any smaller than value@@ -249,12 +247,22 @@ utility ("mw" -. n) ["min-width" :. style n] +maxWidth :: (Styleable h) => Length -> CSS h -> CSS h+maxWidth n =+ utility ("mxw" -. n) ["max-width" :. style n]++ -- | Allow height to grow to contents but not shrink any smaller than value minHeight :: (Styleable h) => Length -> CSS h -> CSS h minHeight n = utility ("mh" -. n) ["min-height" :. style n] +maxHeight :: (Styleable h) => Length -> CSS h -> CSS h+maxHeight n =+ utility ("mxh" -. n) ["max-height" :. style n]++ data Overflow = Scroll | Clip@@ -264,6 +272,6 @@ instance PropertyStyle Overflow Visibility --- | Control how an element clips content that exceeds its bounds +-- | Control how an element clips content that exceeds its bounds overflow :: (PropertyStyle Overflow o, ToClassName o, Styleable h) => o -> CSS h -> CSS h overflow o = utility ("over" -. o) ["overflow" :. propertyStyle @Overflow o]
src/Web/Atomic/Html.hs view
@@ -65,7 +65,17 @@ tag :: Text -> Html () -> Html () tag nm (Html _ content) = do- Html () [Elem $ (element nm){content}]+ fromElement $ (element nm){content}+++tag' :: Bool -> Text -> Html () -> Html ()+tag' inline nm (Html _ content) =+ fromElement $ (element nm){content, inline}+++fromElement :: Element -> Html ()+fromElement elm =+ Html () [Elem elm] text :: Text -> Html ()
src/Web/Atomic/Html/Tag.hs view
@@ -6,7 +6,7 @@ Stability: experimental Portability: portable -We can intuitively create layouts by combining of 'row', 'col', 'space', and 'stack'+We can intuitively create layouts by combining 'row', 'col', 'space', and 'stack' @ holygrail = do
src/Web/Atomic/Render.hs view
@@ -47,7 +47,7 @@ nodeLines :: Int -> Node -> [Line] nodeLines ind (Elem e) = elementLines ind e nodeLines _ (Text t) = [Line Inline 0 $ HE.text t]-nodeLines _ (Raw t) = [Line Newline 0 t]+nodeLines _ (Raw t) = [Line Inline 0 t] elementLines :: Int -> Element -> [Line]@@ -174,16 +174,14 @@ -- | Render lines to text renderLines :: [Line] -> Text-renderLines = snd . L.foldl' nextLine (False, "")+renderLines = snd . L.foldl' nextLine (Inline, "") where- nextLine :: (Bool, Text) -> Line -> (Bool, Text)- nextLine (newline, t) l = (nextNewline l, t <> currentLine newline l)+ nextLine :: (LineEnd, Text) -> Line -> (LineEnd, Text)+ nextLine (end, t) l = (l.end, t <> currentLine end l) - currentLine :: Bool -> Line -> Text- currentLine newline l- | newline = "\n" <> spaces l.indent <> l.text+ currentLine :: LineEnd -> Line -> Text+ currentLine end l+ | end == Newline = "\n" <> spaces l.indent <> l.text | otherwise = l.text-- nextNewline l = l.end == Newline spaces n = T.replicate n " "
src/Web/Atomic/Types/Attributable.hs view
@@ -33,7 +33,7 @@ infixl 5 @ -instance {-# OVERLAPPABLE #-} (Attributable a, Attributable b) => Attributable (a -> b) where+instance {-# OVERLAPPABLE #-} (Attributable b) => Attributable (a -> b) where (@) :: (a -> b) -> (Attributes (a -> b) -> Attributes (a -> b)) -> (a -> b) hh @ f = \content -> hh content @ \(Attributes m) ->
src/Web/Atomic/Types/Styleable.hs view
@@ -25,7 +25,7 @@ infixl 5 ~ -instance {-# OVERLAPPABLE #-} (Styleable a, Styleable b) => Styleable (a -> b) where+instance {-# OVERLAPPABLE #-} (Styleable b) => Styleable (a -> b) where (~) :: (a -> b) -> (CSS (a -> b) -> CSS (a -> b)) -> (a -> b) hh ~ f = \content -> hh content ~ \(CSS m) ->
test/Test/RenderSpec.hs view
@@ -140,7 +140,10 @@ it "renders inline" $ do renderLines [Line Inline 0 "one", Line Inline 0 "two"] `shouldBe` "onetwo" + it "renders inline" $ do+ renderLines [Line Inline 0 "one", Line Inline 0 "two"] `shouldBe` "onetwo" + htmlSpec :: Spec htmlSpec = do describe "lines" $ do@@ -174,6 +177,9 @@ it "renders pseudo class" $ do htmlLines 0 (tag "div" ~ hover bold $ none) `shouldBe` ["<div class='hover:bold'></div>"] + it "renders raw" $ do+ htmlLines 0 (tag "div" $ raw "hello") `shouldBe` [Line Newline 0 "<div>", Line Inline 0 "hello", Line Newline 0 "</div>"]+ describe "renderText" $ do it "renders simple output" $ do renderText (tag "div" "hi") `shouldBe` "<div>hi</div>"@@ -208,6 +214,9 @@ it "renders external classes" $ do renderText (el ~ cls "woot" $ none) `shouldBe` "<div class='woot'></div>"++ it "renders raw without leading spaces" $ do+ renderText (tag' True "div" $ raw "hello") `shouldBe` "<div>hello</div>" -- it "matches tooltips big example" $ do -- golden <- T.readFile "test/resources/tooltips.txt"