1
1
module Lumi.Components.Examples.Input where
2
2
3
3
import Prelude
4
-
5
4
import Data.Maybe (Maybe (Just))
6
5
import Data.Nullable (toNullable )
7
- import Lumi.Components.Size (Size (..))
8
6
import Lumi.Components.Column (column_ )
9
- import Lumi.Components.Input (CheckboxState (..), alignToInput , checkbox , input , inputRow , inputRow_ , radio , range , switch , text_ )
10
- import Lumi.Components.Row (row_ )
11
- import Lumi.Components.Text (body_ , h2_ , h4_ , p_ )
12
7
import Lumi.Components.Example (example )
8
+ import Lumi.Components.Input (CheckboxState (..), alignToInput , checkbox , input , radio , range , switch , text_ )
9
+ import Lumi.Components.Row (row_ )
10
+ import Lumi.Components.Size (Size (..))
11
+ import Lumi.Components.Text (body , h2_ , h4_ , p_ , text )
13
12
import React.Basic (JSX )
14
13
import React.Basic.DOM as R
15
14
@@ -19,171 +18,101 @@ docs =
19
18
[ h4_ " Simple text input"
20
19
, example
21
20
$ input text_ { placeholder = " Placeholder..." }
22
-
23
-
24
21
, h4_ " Text input with a placeholder"
25
22
, example
26
- $ input text_
27
- { placeholder = " Placeholder..."
28
- , value = " This input contains a value"
29
- }
30
-
31
-
23
+ $ input
24
+ text_
25
+ { placeholder = " Placeholder..."
26
+ , value = " This input contains a value"
27
+ }
32
28
, h4_ " Invalid input value"
33
29
, example
34
- $ input text_
35
- { placeholder = " Placeholder..."
36
- , pattern = toNullable $ Just " d+"
37
- , value = " An invalid value"
38
- }
39
-
40
-
30
+ $ input
31
+ text_
32
+ { placeholder = " Placeholder..."
33
+ , pattern = toNullable $ Just " d+"
34
+ , value = " An invalid value"
35
+ }
41
36
, h4_ " Disabled input"
42
37
, example
43
- $ input text_
44
- { placeholder = " Placeholder..."
45
- , disabled = true
46
- }
47
-
48
-
38
+ $ input
39
+ text_
40
+ { placeholder = " Placeholder..."
41
+ , disabled = true
42
+ }
49
43
, h4_ " Disabled input with a value"
50
44
, example
51
- $ input text_
52
- { placeholder = " Placeholder..."
53
- , value = " Disabled with a value"
54
- , disabled = true
55
- }
56
-
57
-
45
+ $ input
46
+ text_
47
+ { placeholder = " Placeholder..."
48
+ , value = " Disabled with a value"
49
+ , disabled = true
50
+ }
58
51
, h4_ " Aligning components with input text"
59
52
, p_ " `AlignToInput` applies the padding values inputs use to any child component. Use this to align elements with inputs instead of manually specifying padding."
60
53
, example
61
54
$ row_
62
- [ alignToInput $ body_ " Some aligned text"
63
- , input text_
64
- { placeholder = " Placeholder..."
65
- , value = " Input value"
66
- }
55
+ [ alignToInput
56
+ $ text
57
+ body
58
+ { children = [ R .text " Some aligned text" ]
59
+ , style = R .css { whiteSpace: " nowrap" }
60
+ }
61
+ , input
62
+ text_
63
+ { placeholder = " Placeholder..."
64
+ , value = " Input value"
65
+ }
67
66
]
68
-
69
-
70
- , h2_ " Input Row"
71
-
72
- , h4_ " Padded"
73
-
74
- , example
75
- $ inputRow_ " Field label" checkbox { checked = Off }
76
-
77
- , example
78
- $ inputRow_ " Field label" checkbox
79
- { size = Small
80
- , checked = Off
81
- }
82
-
83
- , example
84
- $ inputRow_ " Field label" radio { checked = Off }
85
-
86
- , h4_ " Left aligned"
87
-
88
- , example
89
- $ inputRow { labelText: " Field label" , leftAligned: true , style: R .css {} } checkbox { checked = Off }
90
-
91
- , example
92
- $ inputRow { labelText: " Field label" , leftAligned: true , style: R .css {} } checkbox
93
- { size = Small
94
- , checked = Off
95
- }
96
-
97
- , example
98
- $ inputRow { labelText: " Field label" , leftAligned: true , style: R .css {} } radio { checked = Off }
99
-
100
-
101
67
, h2_ " Checkbox"
102
-
103
68
, h4_ " Medium"
104
- , example
105
- $ inputRow_ " Field label" checkbox { checked = Off }
106
-
107
-
108
- , example
109
- $ inputRow_ " Field label" checkbox { checked = On }
110
-
111
-
112
- , example
113
- $ inputRow_ " Field label" checkbox { checked = Indeterminate }
114
-
115
-
69
+ , exampleRow $ input checkbox { checked = Off }
70
+ , exampleRow $ input checkbox { checked = On }
71
+ , exampleRow $ input checkbox { checked = Indeterminate }
116
72
, h4_ " Small"
117
- , example
118
- $ inputRow_ " Field label" checkbox
119
- { size = Small
120
- , checked = Off
121
- }
122
-
123
-
124
- , example
125
- $ inputRow_ " Field label" checkbox
126
- { size = Small
127
- , checked = On
128
- }
129
-
130
-
131
- , example
132
- $ inputRow_ " Field label" checkbox
133
- { size = Small
134
- , checked = Indeterminate
135
- }
136
-
137
-
73
+ , exampleRow
74
+ $ input
75
+ checkbox
76
+ { size = Small
77
+ , checked = Off
78
+ }
79
+ , exampleRow
80
+ $ input
81
+ checkbox
82
+ { size = Small
83
+ , checked = On
84
+ }
85
+ , exampleRow
86
+ $ input
87
+ checkbox
88
+ { size = Small
89
+ , checked = Indeterminate
90
+ }
138
91
, h2_ " Radio"
139
-
140
92
, h4_ " Medium"
141
- , example
142
- $ inputRow_ " Field label" radio { checked = Off }
143
-
144
-
145
- , example
146
- $ inputRow_ " Field Label" radio { checked = On }
147
-
148
-
93
+ , exampleRow $ input radio { checked = Off }
94
+ , exampleRow $ input radio { checked = On }
149
95
, h4_ " Small"
150
- , example
151
- $ inputRow_ " Field Label" radio
152
- { size = Small
153
- , checked = Off
154
- }
155
-
156
-
157
- , example
158
- $ inputRow_ " Field label" radio
159
- { size = Small
160
- , checked = On
161
- }
162
-
96
+ , exampleRow
97
+ $ input
98
+ radio
99
+ { size = Small
100
+ , checked = Off
101
+ }
102
+ , exampleRow
103
+ $ input
104
+ radio
105
+ { size = Small
106
+ , checked = On
107
+ }
163
108
, h2_ " Switch"
164
-
165
- , example
166
- $ input switch { checked = Off }
167
-
168
-
169
- , example
170
- $ input switch { checked = On }
171
-
109
+ , exampleRow $ input switch { checked = Off }
110
+ , exampleRow $ input switch { checked = On }
172
111
, h2_ " Switch (Large)"
173
-
174
- , example
175
- $ input switch { checked = Off , size = Large }
176
-
177
-
178
- , example
179
- $ input switch { checked = On , size = Large }
180
-
181
-
182
-
112
+ , exampleRow $ input switch { checked = Off , size = Large }
113
+ , exampleRow $ input switch { checked = On , size = Large }
183
114
, h2_ " Range"
184
-
185
- , example
186
- $ input range
187
-
188
-
115
+ , exampleRow $ input range
189
116
]
117
+ where
118
+ exampleRow child = example $ row_ [ child ]
0 commit comments