@@ -2,6 +2,7 @@ module Lumi.Components.Examples.Form where
22
33import Prelude
44
5+ import Color (cssStringHSLA )
56import Control.Coroutine.Aff (close , emit , produceAff )
67import Control.MonadZero (guard )
78import Data.Array as Array
@@ -22,6 +23,7 @@ import Effect.Class (liftEffect)
2223import Effect.Random (randomRange )
2324import Effect.Unsafe (unsafePerformEffect )
2425import Lumi.Components.Button as Button
26+ import Lumi.Components.Color (colors )
2527import Lumi.Components.Column (column , column_ )
2628import Lumi.Components.Example (example )
2729import Lumi.Components.Form (FormBuilder , Validated )
@@ -33,6 +35,8 @@ import Lumi.Components.LabeledField (RequiredField(..))
3335import Lumi.Components.Modal (dialog )
3436import Lumi.Components.Row (row )
3537import Lumi.Components.Size (Size (..))
38+ import Lumi.Components.Text as T
39+ import Lumi.Components.Textarea as Textarea
3640import Lumi.Components.Upload (FileId (..))
3741import Lumi.Components.Upload as Upload
3842import React.Basic.DOM (css )
@@ -193,6 +197,8 @@ type User =
193197 , password2 :: Validated String
194198 }
195199 , admin :: Boolean
200+ , checkbox :: Boolean
201+ , descriptiveCheckbox :: Boolean
196202 , height :: Validated String
197203 , addresses :: Validated (Array Address )
198204 , pets :: Validated (Array Pet )
@@ -206,6 +212,8 @@ type ValidatedUser =
206212 , lastName :: NonEmptyString
207213 , password :: NonEmptyString
208214 , admin :: Boolean
215+ , checkbox :: Boolean
216+ , descriptiveCheckbox :: Boolean
209217 , height :: Maybe Number
210218 , addresses :: Array ValidatedAddress
211219 , pets :: Array ValidatedPet
@@ -248,7 +256,7 @@ userForm = ado
248256 (pure " First name should be longer than two characters (but it doesn't have to be)." )
249257 )
250258 $ F .validated (F .nonEmpty " First name" )
251- $ F .textbox
259+ $ F .inputBox $ Input .text_ { placeholder = " First name " }
252260 lastName <-
253261 F .indent " Last Name" Required
254262 $ F .focus (prop (SProxy :: SProxy " lastName" ))
@@ -272,6 +280,23 @@ userForm = ado
272280 F .indent " Admin?" Neither
273281 $ F .focus (prop (SProxy :: SProxy " admin" ))
274282 $ 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+ }
275300
276301 F .section " Personal data"
277302 height <-
@@ -306,6 +331,10 @@ userForm = ado
306331 F .indent " Notes" Optional
307332 $ F .focus (prop (SProxy :: SProxy " notes" ))
308333 $ 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..." }
309338
310339 F .section " Pets"
311340 pets <-
@@ -418,6 +447,8 @@ userForm = ado
418447 , lastName
419448 , password
420449 , admin
450+ , checkbox
451+ , descriptiveCheckbox
421452 , height
422453 , pets
423454 , leastFavoriteColors
@@ -523,4 +554,3 @@ addressForm = ado
523554 { label: un State state
524555 , value: state
525556 }
526-
0 commit comments