Skip to content

Commit 91354de

Browse files
committed
field inputs wip
1 parent 78be20c commit 91354de

File tree

2 files changed

+56
-37
lines changed

2 files changed

+56
-37
lines changed

ghcjs/miso-functora/lib/miso-functora/post-theme.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,13 @@ nav {
2424
position: initial !important;
2525
}
2626

27+
input,
28+
select,
2729
button {
2830
margin: 0.25rem 0.125rem;
31+
}
32+
33+
button {
2934
padding-left: 1rem;
3035
padding-right: 1rem;
3136
}

ghcjs/miso-functora/src/Functora/Miso/Widgets/Field.hs

Lines changed: 51 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ field ::
124124
Full model action t Unique ->
125125
Opts model action ->
126126
[View action]
127-
field Full {fullArgs = args, fullParser = parser, fullViewer = viewer} opts =
127+
field full@Full {fullArgs = args, fullParser = parser, fullViewer = viewer} opts =
128128
( do
129129
x0 <-
130130
catMaybes
@@ -143,42 +143,56 @@ field Full {fullArgs = args, fullParser = parser, fullViewer = viewer} opts =
143143
_ -> mempty
144144
fieldModal args x1
145145
)
146-
<> [ maybe
147-
id
148-
( \x ->
149-
label_ mempty
150-
. (text x :)
151-
. (br_ mempty :)
152-
. singleton
153-
)
154-
(optsLabel opts)
155-
. input_
156-
$ ( catMaybes
157-
[ fmap
158-
(type_ . htmlFieldType)
159-
(st ^? cloneTraversal optic . #fieldType),
160-
fmap
161-
(textProp "defaultValue")
162-
(st ^? cloneTraversal optic . #fieldInput . #uniqueValue),
163-
Just $ onInput onInputAction,
164-
Just . disabled_ $ opts ^. #optsDisabled,
165-
fmap placeholder_
166-
$ if null placeholder
167-
then optsLabel opts
168-
else Just placeholder,
169-
Just
170-
. id_
171-
. either impureThrow id
172-
. decodeUtf8Strict
173-
. unTagged
174-
$ htmlUid uid,
175-
Just . onKeyDown $ action . optsOnKeyDownAction opts uid,
176-
Just $ onBlur onBlurAction
177-
]
178-
)
179-
<> ( opts ^. #optsExtraAttributes
180-
)
181-
]
146+
<> maybe
147+
id
148+
( \x ->
149+
singleton
150+
. label_ mempty
151+
. (text x :)
152+
. (br_ mempty :)
153+
)
154+
(optsLabel opts)
155+
( [ input_
156+
$ ( catMaybes
157+
[ fmap
158+
(type_ . htmlFieldType)
159+
(st ^? cloneTraversal optic . #fieldType),
160+
fmap
161+
(textProp "defaultValue")
162+
(st ^? cloneTraversal optic . #fieldInput . #uniqueValue),
163+
Just $ onInput onInputAction,
164+
Just . disabled_ $ opts ^. #optsDisabled,
165+
fmap placeholder_
166+
$ if null placeholder
167+
then optsLabel opts
168+
else Just placeholder,
169+
Just
170+
. id_
171+
. either impureThrow id
172+
. decodeUtf8Strict
173+
. unTagged
174+
$ htmlUid uid,
175+
Just . onKeyDown $ action . optsOnKeyDownAction opts uid,
176+
Just $ onBlur onBlurAction
177+
]
178+
)
179+
<> ( opts ^. #optsExtraAttributes
180+
)
181+
]
182+
--
183+
-- TODO : with new semantic layout separate leading/trailing
184+
-- widgets do not make a lot of sense, should be a single option
185+
-- which is just a list widgets.
186+
--
187+
<> catMaybes
188+
[ fmap
189+
(fieldIcon full opts)
190+
(opts ^? #optsLeadingWidget . _Just . cloneTraversal widgetOptic),
191+
fmap
192+
(fieldIcon full opts)
193+
(opts ^? #optsTrailingWidget . _Just . cloneTraversal widgetOptic)
194+
]
195+
)
182196
where
183197
--
184198
-- TODO : implement

0 commit comments

Comments
 (0)