/
Text.purs
68 lines (50 loc) · 2.12 KB
/
Text.purs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
-- | See <https://materializecss.com/color.html>,
-- | <https://materializecss.com/typography.html>, and
-- | <https://materializecss.com/helpers.html>.
module Materialize.Text where
import Data.Maybe (Maybe(..))
import Data.Newtype (class Newtype, wrap)
import Data.Typelevel.Undefined (undefined)
import Prelude
import Materialize.Color (Hue, Shade, Color(..))
import Materialize.Markup (class Decorate, class Render, class Variadic, liftVariadic, render, (<$~), (<~), (~>))
newtype Text = Text { hue :: Maybe Hue
, shade :: Maybe Shade
, flow :: Maybe Flow
, truncate :: Maybe Truncate
}
data Flow
data Truncate
text :: forall a r. Decorate Text a => Variadic Text r => a -> r
text a = liftVariadic $ a ~> wrap { hue: Nothing
, shade: Nothing
, flow: Nothing
, truncate: Nothing
}
instance variadicReturnText :: Variadic Text Text where
liftVariadic = identity
flow :: Flow
flow = undefined
truncate :: Truncate
truncate = undefined
instance decorateTextFlow :: Decorate Text Flow where
decorate (Text t) f = wrap t { flow = pure f }
instance decorateTextHue :: Decorate Text Hue where
decorate (Text t) h = wrap t { hue = pure h }
instance decorateTextColor :: Decorate Text Color where
decorate (Text t) (Color h s) = wrap t { hue = pure h
, shade = s
}
instance decorateTextShade :: Decorate Text Shade where
decorate (Text t) s = wrap t { shade = pure s }
instance decorateTextTruncate :: Decorate Text Truncate where
decorate (Text t) t' = wrap t { truncate = pure t' }
instance renderText :: Render Text where
render (Text { hue: h, shade: s , flow: f, truncate: t }) =
render t
<> render ("flow-text" <$ f)
<> (render h <~ "text")
<> ("text" <$~ render s)
instance renderTruncate :: Render Truncate where
render _ = render "truncate"
derive instance newtypeText :: Newtype Text _