Skip to content

Commit fa94bf5

Browse files
committed
wip
1 parent 90aad89 commit fa94bf5

File tree

3 files changed

+50
-32
lines changed

3 files changed

+50
-32
lines changed
Lines changed: 46 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
module Functora.Miso.Capa.Dialog
22
( Args (..),
3+
Opts (..),
4+
defOpts,
35
dialog,
46
)
57
where
68

7-
import qualified Functora.Miso.Capa.Grid as Grid
8-
import qualified Functora.Miso.Css as Css
99
import Functora.Miso.Prelude
1010
import Functora.Miso.Types
11-
import qualified Material.Button as Button
12-
import qualified Material.Dialog as Dialog
1311

1412
data Args model action = Args
1513
{ argsModel :: model,
@@ -19,37 +17,53 @@ data Args model action = Args
1917
}
2018
deriving stock (Generic)
2119

22-
dialog :: forall model action. Args model action -> [View action]
23-
dialog args =
20+
data Opts = Opts
21+
{ optsTitle :: Maybe Unicode
22+
}
23+
deriving stock (Generic)
24+
25+
defOpts :: Opts
26+
defOpts =
27+
Opts
28+
{ optsTitle = Nothing
29+
}
30+
31+
dialog :: forall model action. Opts -> Args model action -> [View action]
32+
dialog opts args =
2433
if args ^? #argsModel . cloneTraversal optic /= Just Opened
2534
then mempty
2635
else
27-
[ Dialog.dialog
28-
( Dialog.config
29-
& Dialog.setOpen True
30-
& action Dialog.setOnClose
31-
)
32-
( Dialog.dialogContent
33-
Nothing
34-
[ Grid.grid
35-
mempty
36-
$ (args ^. #argsContent)
37-
<> [ Grid.bigCell
38-
[ Button.raised
39-
( Button.config
40-
& action Button.setOnClick
41-
& Button.setIcon (Just "arrow_back")
42-
& Button.setAttributes [Css.fullWidth]
43-
)
44-
"Back"
45-
]
46-
]
47-
]
48-
mempty
49-
)
50-
]
36+
singleton
37+
$ div_
38+
[class_ "window"]
39+
[ div_
40+
[class_ "title-bar"]
41+
$ catMaybes
42+
[ fmap
43+
( \title ->
44+
div_
45+
[class_ "title-bar-text"]
46+
[text title]
47+
)
48+
( opts ^. #optsTitle
49+
),
50+
Just
51+
$ div_
52+
[class_ "title-bar-controls"]
53+
[ button_
54+
[ onClick close,
55+
textProp "aria-label" "Close"
56+
]
57+
mempty
58+
]
59+
],
60+
div_
61+
[class_ "window-body"]
62+
$ (args ^. #argsContent)
63+
<> [button_ [onClick close] [text "Back"]]
64+
]
5165
where
5266
optic :: ATraversal' model OpenedOrClosed
5367
optic = args ^. #argsOptic
54-
action :: (action -> f action -> f action) -> f action -> f action
55-
action = ($ args ^. #argsAction $ PureUpdate $ cloneTraversal optic .~ Closed)
68+
close :: action
69+
close = args ^. #argsAction $ PureUpdate $ cloneTraversal optic .~ Closed

ghcjs/miso-capa/src/Functora/Miso/Capa/Field.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ fieldIconSimple lot txt attrs action =
415415
fieldModal :: Args model action t f -> ModalWidget' model -> [View action]
416416
fieldModal args@Args {argsAction = action} (ModalItemWidget opt idx fps lbl ooc) =
417417
Dialog.dialog
418+
Dialog.defOpts
418419
Dialog.Args
419420
{ Dialog.argsModel = args ^. #argsModel,
420421
Dialog.argsOptic = cloneTraversal opt . ix idx . cloneTraversal ooc,
@@ -527,6 +528,7 @@ fieldModal args (ModalFieldWidget opt idx access sod) = do
527528
let action =
528529
args ^. #argsAction
529530
Dialog.dialog
531+
Dialog.defOpts
530532
Dialog.Args
531533
{ Dialog.argsModel = args ^. #argsModel,
532534
Dialog.argsOptic = cloneTraversal optic . #fieldModalState,
@@ -651,6 +653,7 @@ fieldModal args (ModalFieldWidget opt idx access sod) = do
651653
}
652654
fieldModal args (ModalMiniWidget opt) =
653655
Dialog.dialog
656+
Dialog.defOpts
654657
Dialog.Args
655658
{ Dialog.argsModel = args ^. #argsModel,
656659
Dialog.argsOptic = cloneTraversal opt . #fieldModalState,

ghcjs/miso-capa/src/Functora/Miso/Prelude.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import Miso as X hiding
1616
Text,
1717
URI,
1818
at,
19+
close,
1920
consoleLog,
2021
for_,
2122
view,

0 commit comments

Comments
 (0)