1
1
module Functora.Miso.Capa.Dialog
2
2
( Args (.. ),
3
+ Opts (.. ),
4
+ defOpts ,
3
5
dialog ,
4
6
)
5
7
where
6
8
7
- import qualified Functora.Miso.Capa.Grid as Grid
8
- import qualified Functora.Miso.Css as Css
9
9
import Functora.Miso.Prelude
10
10
import Functora.Miso.Types
11
- import qualified Material.Button as Button
12
- import qualified Material.Dialog as Dialog
13
11
14
12
data Args model action = Args
15
13
{ argsModel :: model ,
@@ -19,37 +17,53 @@ data Args model action = Args
19
17
}
20
18
deriving stock (Generic )
21
19
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 =
24
33
if args ^? # argsModel . cloneTraversal optic /= Just Opened
25
34
then mempty
26
35
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
+ ]
51
65
where
52
66
optic :: ATraversal' model OpenedOrClosed
53
67
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
0 commit comments