Skip to content

Commit 3e66042

Browse files
committed
wip
1 parent e8a1693 commit 3e66042

File tree

13 files changed

+174
-108
lines changed

13 files changed

+174
-108
lines changed

ghcjs/delivery-calculator/src/App/Types.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ data St f = St
9292
stFavName :: Field Unicode f,
9393
stPreview :: Field Unicode f,
9494
stScreen :: Screen,
95+
stEnableTheme :: Bool,
9596
stTheme :: Theme
9697
}
9798
deriving stock (Generic)
@@ -133,6 +134,7 @@ newSt = do
133134
stFavName = fav,
134135
stPreview = pre & #fieldType .~ FieldTypeTitle,
135136
stScreen = Main,
137+
stEnableTheme = True,
136138
stTheme = Theme.Paper
137139
}
138140

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

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import qualified Functora.Miso.Widgets.Dialog as Dialog
1616
import qualified Functora.Miso.Widgets.Field as Field
1717
import qualified Functora.Miso.Widgets.Icon as Icon
1818
import qualified Functora.Miso.Widgets.Select as Select
19+
import qualified Functora.Miso.Widgets.Switch as Switch
1920
import qualified Functora.Money as Money
2021
import qualified Text.URI as URI
2122

@@ -274,18 +275,34 @@ menu st =
274275
& #optsLabel
275276
.~ Just ("QR title" :: Unicode)
276277
)
277-
<> [ Select.select
278-
( Select.defOpts
278+
<> [ Switch.switch
279+
( Switch.defOpts
279280
& #optsLabel
280-
.~ Just "Theme"
281+
.~ Just "Enable theme"
281282
)
282-
Select.Args
283-
{ Select.argsModel = st,
284-
Select.argsOptic = #modelState . #stTheme,
285-
Select.argsAction = PushUpdate . Instant,
286-
Select.argsOptions = constTraversal $ enumerate @Theme
283+
Switch.Args
284+
{ Switch.argsModel = st,
285+
Switch.argsOptic = #modelState . #stEnableTheme,
286+
Switch.argsAction = PushUpdate . Instant
287287
}
288288
]
289+
<> ( if not (st ^. #modelState . #stEnableTheme)
290+
then mempty
291+
else
292+
[ Select.select
293+
( Select.defOpts
294+
& #optsLabel
295+
.~ Just "Theme"
296+
)
297+
Select.Args
298+
{ Select.argsModel = st,
299+
Select.argsOptic = #modelState . #stTheme,
300+
Select.argsAction = PushUpdate . Instant,
301+
Select.argsOptions =
302+
constTraversal $ enumerate @Theme
303+
}
304+
]
305+
)
289306
}
290307

291308
qrButton :: Model -> View Action

ghcjs/delivery-calculator/src/Main.hs

Lines changed: 53 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,13 @@ runApp app = do
8484
where
8585
router js req =
8686
case Wai.pathInfo req of
87-
("static" : "css" : path) ->
88-
staticApp
89-
(defaultWebAppSettings "../miso-functora/dist/css")
90-
req {Wai.pathInfo = path}
91-
("node_modules" : _) ->
87+
("themes" : _) ->
88+
staticApp (defaultWebAppSettings "../miso-functora/dist") req
89+
("fa" : _) ->
90+
staticApp (defaultWebAppSettings "../miso-functora/lib") req
91+
("miso-functora" : _) ->
92+
staticApp (defaultWebAppSettings "../miso-functora/lib") req
93+
("static" : _) ->
9294
staticApp (defaultWebAppSettings ".") req
9395
("favicon.ico" : _) ->
9496
staticApp (defaultWebAppSettings "static") req
@@ -233,33 +235,58 @@ updateModel (PushUpdate updater) st = do
233235
pure Noop
234236
]
235237

238+
--
239+
-- TODO : !!!
240+
--
241+
-- href_ "https://unpkg.com/[email protected]/css/nes.min.css"
242+
-- href_ "node_modules/@lowlighter/matcha/dist/matcha.css"
243+
-- href_ "https://unpkg.com/@sakun/system.css"
244+
-- href_ "https://unpkg.com/[email protected]/dist/terminal.min.css"
245+
-- href_ "https://vinibiavatti1.github.io/TuiCss/dist/tuicss.min.css"
246+
-- href_ "https://fieber.hack.re/fieber.css"
236247
viewModel :: Model -> View Action
237248
#if defined(__GHCJS__) || defined(ghcjs_HOST_OS) || defined(wasi_HOST_OS)
238249
viewModel st =
239-
mainWidget st
250+
prependViews
251+
(
252+
( if not (st ^. #modelState . #stEnableTheme)
253+
then mempty
254+
else
255+
[ link_
256+
[ rel_ "stylesheet",
257+
href_ $ "themes/" <> themeCssFile (st ^. #modelState . #stTheme)
258+
]
259+
]
260+
) <>
261+
[ link_
262+
[ rel_ "stylesheet",
263+
href_ $ "miso-functora/miso-functora.min.css"
264+
]
265+
]
266+
)
267+
$ mainWidget st
240268
#else
241269
viewModel st =
270+
--
271+
-- NOTE : using non-optimized css for dev purposes only
272+
--
242273
prependViews
243-
[ link_
244-
[ rel_ "stylesheet",
245-
href_ "static/css/fontawesome.min.css"
246-
],
247-
-- href_ "https://unpkg.com/[email protected]/css/nes.min.css"
248-
-- href_ "node_modules/@lowlighter/matcha/dist/matcha.css"
249-
-- href_ "https://unpkg.com/@sakun/system.css"
250-
-- href_ "https://unpkg.com/papercss/dist/paper.min.css"
251-
-- href_ "https://unpkg.com/[email protected]/dist/terminal.min.css"
252-
-- href_ "https://vinibiavatti1.github.io/TuiCss/dist/tuicss.min.css"
253-
-- href_ "https://fieber.hack.re/fieber.css"
254-
link_
255-
[ rel_ "stylesheet",
256-
href_ $ "static/css/" <> themeCssFile (st ^. #modelState . #stTheme)
257-
],
258-
link_
259-
[ rel_ "stylesheet",
260-
href_ "static/css/app.css"
261-
]
262-
]
274+
(
275+
( if not (st ^. #modelState . #stEnableTheme)
276+
then mempty
277+
else
278+
[ link_
279+
[ rel_ "stylesheet",
280+
href_ $ "themes/" <> themeCssFile (st ^. #modelState . #stTheme)
281+
]
282+
]
283+
) <>
284+
[ link_
285+
[ rel_ "stylesheet",
286+
href_ $ "miso-functora/miso-functora.css"
287+
]
288+
]
289+
)
263290
$ mainWidget st
264291
#endif
265292

ghcjs/miso-functora/.ignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ package-lock.json
55
webpack.lock
66
*\.min\.*
77
dist/*
8-
css/*
8+
lib/*

ghcjs/miso-functora/Setup.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ codeGenHook _ = do
7777
prog <- getProgName
7878
runGhc (Just libdir) $ do
7979
dflags <- getDynFlags
80-
cssRaw <- liftIO $ Directory.listDirectory "dist/css/"
80+
cssRaw <- liftIO $ Directory.listDirectory "dist/themes/"
8181
let cssKebab =
8282
sort . fmap (dropEnd 8) $ filter (isSuffixOf ".min.css") cssRaw
8383
let cssPascal =

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

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,24 @@ body {
2323

2424
header,
2525
footer {
26-
margin-left: 0;
27-
margin-right: 0;
28-
padding-left: 0;
29-
padding-right: 0;
26+
width: 100% !important;
27+
margin-left: 0 !important;
28+
margin-right: 0 !important;
29+
padding-left: 0 !important;
30+
padding-right: 0 !important;
31+
}
32+
33+
footer:before,
34+
footer:after {
35+
width: 100%;
3036
}
3137

3238
nav {
39+
padding-left: 0 !important;
40+
padding-right: 0 !important;
3341
margin-bottom: 1rem;
42+
z-index: initial !important;
43+
position: initial !important;
3444
}
3545

3646
textarea {
@@ -40,18 +50,20 @@ textarea {
4050

4151
dialog {
4252
width: 100%;
43-
height: fit-content;
44-
max-height: calc(100% - 4rem);
45-
max-width: min(calc(100% - 4rem), 640px);
53+
height: fit-content !important;
54+
max-height: calc(100% - 4rem) !important;
55+
max-width: min(calc(100% - 4rem), 640px) !important;
4656
overflow: auto;
57+
margin: auto !important;
4758
padding: 1rem;
48-
z-index: 9999;
59+
z-index: 9999 !important;
60+
display: initial;
4961
position: initial;
5062
transform: initial;
5163
}
5264

5365
button {
54-
margin: 0.25rem 0.125rem;
66+
margin: 0.25rem 0.125rem !important;
5567
padding-top: 4px;
5668
padding-bottom: 4px;
5769
padding-left: 12px;

ghcjs/miso-functora/miso-functora.cabal

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,6 @@ common pkg
102102
build-depends: ghcjs-base
103103
js-sources: js/main.min.js
104104

105-
data-files:
106-
css/*.css
107-
dist/**/*.css
108-
dist/**/*.eot
109-
dist/**/*.png
110-
dist/**/*.svg
111-
dist/**/*.ttf
112-
dist/**/*.woff
113-
dist/**/*.woff2
114-
115105
library
116106
import: pkg
117107
hs-source-dirs: src

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

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@ selectCurrency
5656
} =
5757
[ maybe
5858
id
59-
(\x -> label_ mempty . (text x :) . singleton)
59+
( \x ->
60+
label_ mempty
61+
. (text x :)
62+
. (br_ mempty :)
63+
. singleton
64+
)
6065
(optsButtonLabel opts)
6166
$ input_
6267
[ type_ "button",
@@ -72,22 +77,7 @@ selectCurrency
7277
Dialog.defOpts
7378
{ Dialog.optsTitle = Just "Currency",
7479
Dialog.optsTitleIcon = Just Icon.IconCoins,
75-
Dialog.optsHeaderRight =
76-
( <>
77-
Field.textField
78-
Field.Args
79-
{ Field.argsModel = st,
80-
Field.argsOptic = cloneTraversal optic . #currencyInput,
81-
Field.argsAction = action,
82-
Field.argsEmitter = emitter
83-
}
84-
( Field.defOpts @model @action
85-
& #optsPlaceholder
86-
.~ ("Search" :: Unicode)
87-
& #optsExtraAttributes
88-
.~ [autofocus_ True]
89-
)
90-
),
80+
Dialog.optsFlexContent = False,
9181
Dialog.optsExtraOnClose =
9282
cloneTraversal optic
9383
. #currencyInput
@@ -99,7 +89,21 @@ selectCurrency
9989
{ Dialog.argsModel = st,
10090
Dialog.argsOptic = cloneTraversal optic . #currencyModalState,
10191
Dialog.argsAction = action,
102-
Dialog.argsContent = currencyListWidget opts args
92+
Dialog.argsContent =
93+
Field.textField
94+
Field.Args
95+
{ Field.argsModel = st,
96+
Field.argsOptic = cloneTraversal optic . #currencyInput,
97+
Field.argsAction = action,
98+
Field.argsEmitter = emitter
99+
}
100+
( Field.defOpts @model @action
101+
& #optsPlaceholder
102+
.~ ("Search" :: Unicode)
103+
& #optsExtraAttributes
104+
.~ [autofocus_ True]
105+
)
106+
<> currencyListWidget opts args
103107
}
104108
where
105109
open =

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ data Opts model action = Opts
2828
optsFooterLeft :: [View action] -> [View action],
2929
optsFooterRight :: [View action] -> [View action],
3030
optsExtraOnClose :: model -> model,
31+
optsFlexContent :: Bool,
3132
optsIcon :: Icon.Icon -> View action
3233
}
3334
deriving stock (Generic)
@@ -42,6 +43,7 @@ defOpts =
4243
optsFooterLeft = id,
4344
optsFooterRight = id,
4445
optsExtraOnClose = id,
46+
optsFlexContent = True,
4547
optsIcon = Icon.icon @Icon.Fa
4648
}
4749

@@ -66,7 +68,10 @@ dialog opts args =
6668
id
6769
(optsHeaderLeft opts defHeaderLeft)
6870
(optsHeaderRight opts defHeaderRight)
69-
<> argsContent args
71+
<> ( if optsFlexContent opts
72+
then [Flex.flexCol main_ id (argsContent args)]
73+
else argsContent args
74+
)
7075
<> Flex.flexLeftRight
7176
footer_
7277
id

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,12 @@ field Full {fullArgs = args, fullParser = parser, fullViewer = viewer} opts =
145145
)
146146
<> [ maybe
147147
id
148-
(\x -> label_ mempty . (text x :) . singleton)
148+
( \x ->
149+
label_ mempty
150+
. (text x :)
151+
. (br_ mempty :)
152+
. singleton
153+
)
149154
(optsLabel opts)
150155
. input_
151156
$ ( catMaybes

0 commit comments

Comments
 (0)