-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathLabeledField.example.purs
103 lines (91 loc) · 3.05 KB
/
LabeledField.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
module Lumi.Components.Examples.LabeledField where
import Prelude
import Data.Foldable (intercalate)
import Data.Maybe (Maybe(..))
import Lumi.Components.Column (column, column_)
import Lumi.Components.Divider (divider)
import Lumi.Components.Input as Input
import Lumi.Components.LabeledField (RequiredField(..), ValidationMessage(..), defaults, labeledField)
import Lumi.Components.Text (h2_)
import Lumi.Components.Example (example)
import React.Basic.Classic (JSX)
import React.Basic.DOM (css)
import React.Basic.DOM as R
docs :: JSX
docs =
column_
[ h2_ "Standard Form"
, example
$ column
{ style: css { alignSelf: "stretch" }
, children: [ intercalate simpleDivider labeledFieldExamples ]
}
, h2_ "Forced Top Labels Form"
, example
$ column
{ style: css { alignSelf: "stretch" }
, children: [ intercalate simpleDivider labeledFieldTopLabelExamples ]
}
, h2_ "Inline Table Form"
, example
$ column
{ style: css { alignSelf: "stretch" }
, children:
[ inlineTableDivider
, intercalate inlineTableDivider labeledFieldExamples
, inlineTableDivider
]
}
, h2_ "Inline Table Form (Nested)"
, example
$ column
{ style: css { alignSelf: "stretch" }
, children:
[ inlineTableDivider
, intercalate inlineTableDivider inlineTableNestedExample
, inlineTableDivider
]
}
]
where
simpleDivider = divider { style: css { margin: "6px 0", visibility: "hidden" } }
inlineTableDivider = divider { style: css { margin: "6px 0" } }
makeLabeledFieldExamples forceTopLabel =
[ labeledField defaults
{ label = R.text "First Name"
, forceTopLabel = forceTopLabel
, value = Input.input Input.text_ { value = "Asdf" }
}
, labeledField defaults
{ label = R.text "Last Name"
, validationError = Just $ Error "Example validation error."
, forceTopLabel = forceTopLabel
}
, labeledField defaults
{ label = R.text "Username"
, forceTopLabel = forceTopLabel
, required = Optional
}
, labeledField defaults
{ label = R.text "Password"
, forceTopLabel = forceTopLabel
, required = Required
}
, labeledField defaults
{ label = R.text "Admin?"
, value = Input.input Input.switch
, forceTopLabel = forceTopLabel
}
]
labeledFieldExamples = makeLabeledFieldExamples false
labeledFieldTopLabelExamples = makeLabeledFieldExamples true
inlineTableNestedExample =
[ labeledField defaults
{ label = R.text "User Info"
, value = intercalate inlineTableDivider labeledFieldExamples
}
, labeledField defaults
{ label = R.text "How many?"
, value = Input.input Input.range
}
]