@@ -2,6 +2,7 @@ module Lumi.Components.Examples.Form where
2
2
3
3
import Prelude
4
4
5
+ import Color (cssStringHSLA )
5
6
import Control.Coroutine.Aff (close , emit , produceAff )
6
7
import Control.MonadZero (guard )
7
8
import Data.Array as Array
@@ -22,6 +23,7 @@ import Effect.Class (liftEffect)
22
23
import Effect.Random (randomRange )
23
24
import Effect.Unsafe (unsafePerformEffect )
24
25
import Lumi.Components.Button as Button
26
+ import Lumi.Components.Color (colors )
25
27
import Lumi.Components.Column (column , column_ )
26
28
import Lumi.Components.Example (example )
27
29
import Lumi.Components.Form (FormBuilder , Validated )
@@ -33,6 +35,8 @@ import Lumi.Components.LabeledField (RequiredField(..))
33
35
import Lumi.Components.Modal (dialog )
34
36
import Lumi.Components.Row (row )
35
37
import Lumi.Components.Size (Size (..))
38
+ import Lumi.Components.Text as T
39
+ import Lumi.Components.Textarea as Textarea
36
40
import Lumi.Components.Upload (FileId (..))
37
41
import Lumi.Components.Upload as Upload
38
42
import React.Basic.DOM (css )
@@ -193,6 +197,8 @@ type User =
193
197
, password2 :: Validated String
194
198
}
195
199
, admin :: Boolean
200
+ , checkbox :: Boolean
201
+ , descriptiveCheckbox :: Boolean
196
202
, height :: Validated String
197
203
, addresses :: Validated (Array Address )
198
204
, pets :: Validated (Array Pet )
@@ -206,6 +212,8 @@ type ValidatedUser =
206
212
, lastName :: NonEmptyString
207
213
, password :: NonEmptyString
208
214
, admin :: Boolean
215
+ , checkbox :: Boolean
216
+ , descriptiveCheckbox :: Boolean
209
217
, height :: Maybe Number
210
218
, addresses :: Array ValidatedAddress
211
219
, pets :: Array ValidatedPet
@@ -248,7 +256,7 @@ userForm = ado
248
256
(pure " First name should be longer than two characters (but it doesn't have to be)." )
249
257
)
250
258
$ F .validated (F .nonEmpty " First name" )
251
- $ F .textbox
259
+ $ F .inputBox $ Input .text_ { placeholder = " First name " }
252
260
lastName <-
253
261
F .indent " Last Name" Required
254
262
$ F .focus (prop (SProxy :: SProxy " lastName" ))
@@ -272,6 +280,23 @@ userForm = ado
272
280
F .indent " Admin?" Neither
273
281
$ F .focus (prop (SProxy :: SProxy " admin" ))
274
282
$ F .switch
283
+ checkbox <-
284
+ F .indent " Checked?" Neither
285
+ $ F .focus (prop (SProxy :: SProxy " checkbox" ))
286
+ $ F .checkbox
287
+ descriptiveCheckbox <-
288
+ F .focus (prop (SProxy :: SProxy " descriptiveCheckbox" ))
289
+ $ F .labeledCheckbox
290
+ $ column
291
+ { style: R .css { maxWidth: " 300px" }
292
+ , children:
293
+ [ T .body_ " This is a right aligned description"
294
+ , T .text T .subtext
295
+ { style = R .css { color: cssStringHSLA colors.black1 }
296
+ , children = [ R .text " with a sublabel that reads \" Lorem ipsum dolor sit amet, consectetur adipiscing elit.\" " ]
297
+ }
298
+ ]
299
+ }
275
300
276
301
F .section " Personal data"
277
302
height <-
@@ -306,6 +331,10 @@ userForm = ado
306
331
F .indent " Notes" Optional
307
332
$ F .focus (prop (SProxy :: SProxy " notes" ))
308
333
$ F .textarea
334
+ notes <-
335
+ F .indent " Notes (with placeholder)" Optional
336
+ $ F .focus (prop (SProxy :: SProxy " notes" ))
337
+ $ F .textarea_ $ Textarea .defaults { placeholder = " Placeholder text..." }
309
338
310
339
F .section " Pets"
311
340
pets <-
@@ -418,6 +447,8 @@ userForm = ado
418
447
, lastName
419
448
, password
420
449
, admin
450
+ , checkbox
451
+ , descriptiveCheckbox
421
452
, height
422
453
, pets
423
454
, leastFavoriteColors
@@ -523,4 +554,3 @@ addressForm = ado
523
554
{ label: un State state
524
555
, value: state
525
556
}
526
-
0 commit comments