Skip to content

Commit c4fd9f3

Browse files
committed
dialogs wip
1 parent c01f0a8 commit c4fd9f3

File tree

3 files changed

+64
-30
lines changed

3 files changed

+64
-30
lines changed

ghcjs/delivery-calculator/src/App/Widgets/Menu.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@ menu st =
119119
]
120120
<> Fav.fav st
121121
<> Dialog.dialog
122-
Dialog.defOpts
122+
( Dialog.defOpts
123+
& #optsTitle
124+
.~ Just "Settings"
125+
)
123126
Dialog.Args
124127
{ Dialog.argsModel = st,
125128
Dialog.argsOptic = #modelMenu,

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

Lines changed: 49 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,29 @@ selectCurrency
8686
}
8787
where
8888
open =
89-
action . PureUpdate $ \prev ->
90-
prev
91-
& cloneTraversal optic
92-
. #currencyModalState
93-
. #uniqueValue
94-
.~ Opened
95-
& cloneTraversal optic
96-
. #currencyInput
97-
. #fieldInput
98-
. #uniqueValue
99-
.~ mempty
100-
& extraOnClick
89+
action
90+
$ PureAndImpureUpdate
91+
( \prev ->
92+
prev
93+
& cloneTraversal optic
94+
. #currencyModalState
95+
. #uniqueValue
96+
.~ Opened
97+
& cloneTraversal optic
98+
. #currencyInput
99+
. #fieldInput
100+
. #uniqueValue
101+
.~ mempty
102+
& cloneTraversal optic
103+
. #currencyInput
104+
. #fieldOutput
105+
.~ mempty
106+
& extraOnClick
107+
)
108+
( do
109+
Dialog.openDialog st (cloneTraversal optic . #currencyModalState)
110+
pure id
111+
)
101112

102113
currencyListWidget :: Opts model -> Args model action -> View action
103114
currencyListWidget
@@ -155,28 +166,38 @@ currencyListItemWidget
155166
Opts
156167
{ optsExtraOnClick = extraOnClick
157168
}
158-
Args
169+
args@Args
159170
{ argsOptic = optic,
160171
argsAction = action
161172
}
162173
current
163174
fuzz =
164175
li_
165-
[ onClick . action . PureUpdate $ \st ->
166-
st
167-
& cloneTraversal optic
168-
. #currencyModalState
169-
. #uniqueValue
170-
.~ Closed
171-
& cloneTraversal optic
172-
. #currencyInput
173-
. #fieldInput
174-
. #uniqueValue
175-
.~ mempty
176-
& cloneTraversal optic
177-
. #currencyOutput
178-
.~ item
179-
& extraOnClick
176+
[ onClick
177+
. action
178+
$ PureAndImpureUpdate
179+
( \st ->
180+
st
181+
& cloneTraversal optic
182+
. #currencyModalState
183+
. #uniqueValue
184+
.~ Closed
185+
& cloneTraversal optic
186+
. #currencyInput
187+
. #fieldInput
188+
. #uniqueValue
189+
.~ mempty
190+
& cloneTraversal optic
191+
. #currencyOutput
192+
.~ item
193+
& extraOnClick
194+
)
195+
( do
196+
Dialog.closeDialog
197+
(argsModel args)
198+
(cloneTraversal optic . #currencyModalState)
199+
pure id
200+
)
180201
]
181202
[ ( if current == item
182203
then strong_ mempty

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,17 @@ dialog opts args =
7676
where
7777
defHeaderLeft =
7878
maybeToList
79-
. fmap (h2_ [style_ [("margin", "0")]] . singleton . text)
79+
. fmap
80+
( h2_
81+
[ style_
82+
[ ("margin", "0"),
83+
("display", "flex"),
84+
("align-items", "center")
85+
]
86+
]
87+
. singleton
88+
. text
89+
)
8090
$ optsTitle opts
8191
defHeaderRight =
8292
[ button_

0 commit comments

Comments
 (0)