-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCardGrid.example.purs
109 lines (102 loc) · 3.7 KB
/
CardGrid.example.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
module Lumi.Components.Examples.CardGrid where
import Prelude
import Data.Array (mapWithIndex, take)
import Data.Foldable (foldMap)
import Data.Maybe (Maybe(..))
import Data.Newtype (un)
import Effect.Console (log)
import Lumi.Components.CardGrid (cardGrid)
import Lumi.Components.Column (column_)
import Lumi.Components.Text (h2_, p_)
import Lumi.Components.Example (example)
import React.Basic.Classic (JSX, createComponent, make)
import React.Basic.DOM as R
import Web.HTML.History (URL(..))
docs :: JSX
docs = unit # make (createComponent "CardGridExample")
{ initialState
, render
}
where
initialState =
{ selected: []
}
render self =
column_
[ h2_ "Responsive item grid"
, p_ "* Resize the window to see how the component responds."
, example $
cardGrid
{ items: items # mapWithIndex \index { title, subtitle, href, image } ->
{ key: show index
, title
, subtitle
, href
, children: image # foldMap \src -> [ R.img { src } ]
}
, onNavigate: log <<< un URL
, selection: Nothing
}
, h2_ "Item grid with few items"
, example $
cardGrid
{ items: take 2 items # mapWithIndex \index { title, subtitle, href, image } ->
{ key: show index
, title
, subtitle
, href
, children: image # foldMap \src -> [ R.img { src } ]
}
, onNavigate: log <<< un URL
, selection: Nothing
}
, h2_ "Responsive, selectable item grid"
, p_ "* Resize the window to see how the component responds. Selection boxes are always visible on small screens."
, example $
cardGrid
{ items: items # mapWithIndex \index { title, subtitle, href, image } ->
{ key: show index
, title
, subtitle
, href
, children: image # foldMap \src -> [ R.img { src } ]
}
, onNavigate: log <<< un URL
, selection: Just
{ selectedKeys: self.state.selected
, onSelect: self.setState <<< flip _{ selected = _ }
}
}
]
items =
[ { title: "Poly Mailers"
, subtitle: "14.50\" × 19.00\""
, href: Just $ URL "lumi.com"
, image: Just "https://s3.amazonaws.com/lumi-flapjack-production/mockups/4985252ac5ba4c79e2ecbc6d3438e4ca.jpg"
}
, { title: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec rhoncus neque in consequat fermentum"
, subtitle: "9.00\" × 5.00\""
, href: Just $ URL "lumi.com/items"
, image: Just "https://s3.amazonaws.com/lumi-flapjack-production/mockups/4985252ac5ba4c79e2ecbc6d3438e4ca.jpg"
}
, { title: "Poly Mailers (no image)"
, subtitle: "14.50\" × 19.00\""
, href: Nothing
, image: Nothing
}
, { title: "Random product"
, subtitle: "4.50\" × 12.30\""
, href: Just $ URL "lumi.com"
, image: Nothing
}
, { title: "This text is so large it doesn't fit in a single line."
, subtitle: "11.00\" × 7.00\""
, href: Nothing
, image: Just "https://s3.amazonaws.com/lumi-flapjack-production/mockups/4985252ac5ba4c79e2ecbc6d3438e4ca.jpg"
}
, { title: "Random product 2"
, subtitle: "This is a very long subtitle. I wonder what will happen to it?"
, href: Nothing
, image: Nothing
}
]