11module Lumi.Components.Examples.Input where
22
33import Prelude
4-
54import Data.Maybe (Maybe (Just))
65import Data.Nullable (toNullable )
7- import Lumi.Components.Size (Size (..))
86import 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_ )
127import 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 )
1312import React.Basic (JSX )
1413import React.Basic.DOM as R
1514
@@ -19,171 +18,101 @@ docs =
1918 [ h4_ " Simple text input"
2019 , example
2120 $ input text_ { placeholder = " Placeholder..." }
22-
23-
2421 , h4_ " Text input with a placeholder"
2522 , 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+ }
3228 , h4_ " Invalid input value"
3329 , 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+ }
4136 , h4_ " Disabled input"
4237 , example
43- $ input text_
44- { placeholder = " Placeholder..."
45- , disabled = true
46- }
47-
48-
38+ $ input
39+ text_
40+ { placeholder = " Placeholder..."
41+ , disabled = true
42+ }
4943 , h4_ " Disabled input with a value"
5044 , 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+ }
5851 , h4_ " Aligning components with input text"
5952 , p_ " `AlignToInput` applies the padding values inputs use to any child component. Use this to align elements with inputs instead of manually specifying padding."
6053 , example
6154 $ 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+ }
6766 ]
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-
10167 , h2_ " Checkbox"
102-
10368 , 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 }
11672 , 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+ }
13891 , h2_ " Radio"
139-
14092 , 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 }
14995 , 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+ }
163108 , 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 }
172111 , 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 }
183114 , h2_ " Range"
184-
185- , example
186- $ input range
187-
188-
115+ , exampleRow $ input range
189116 ]
117+ where
118+ exampleRow child = example $ row_ [ child ]
0 commit comments