Skip to content

Commit 41f0461

Browse files
committed
wip
1 parent 497b032 commit 41f0461

File tree

7 files changed

+84
-190
lines changed

7 files changed

+84
-190
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ mainWidget st =
3131
]
3232
<> [ main_
3333
[ style_
34-
[ ("max-width", "550px"),
35-
("align-self", "center"),
34+
[ ("align-self", "center"),
3635
("display", "flex"),
3736
("align-items", "center"),
3837
("flex-direction", "column")

ghcjs/miso-functora/miso-functora.cabal

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ library
113113
Functora.Miso.Widgets.FieldPairs
114114
Functora.Miso.Widgets.FixedOverlay
115115
Functora.Miso.Widgets.Flex
116-
Functora.Miso.Widgets.Grid
117116
Functora.Miso.Widgets.Icon
118117
Functora.Miso.Widgets.Money
119118
Functora.Miso.Widgets.Qr
@@ -150,7 +149,6 @@ test-suite miso-functora-test
150149
Functora.Miso.Widgets.FieldPairs
151150
Functora.Miso.Widgets.FixedOverlay
152151
Functora.Miso.Widgets.Flex
153-
Functora.Miso.Widgets.Grid
154152
Functora.Miso.Widgets.Icon
155153
Functora.Miso.Widgets.Money
156154
Functora.Miso.Widgets.Qr

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

Lines changed: 35 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import qualified Functora.Miso.Jsm as Jsm
2323
import Functora.Miso.Prelude
2424
import Functora.Miso.Types
2525
import qualified Functora.Miso.Widgets.Dialog as Dialog
26-
import qualified Functora.Miso.Widgets.Grid as Grid
2726
import qualified Functora.Miso.Widgets.Qr as Qr
2827
import qualified Functora.Miso.Widgets.Select as Select
2928
import qualified Language.Javascript.JSaddle as JS
@@ -416,50 +415,39 @@ fieldModal args@Args {argsAction = action} (ModalItemWidget opt idx fps lbl ooc)
416415
Dialog.argsOptic = cloneTraversal opt . ix idx . cloneTraversal ooc,
417416
Dialog.argsAction = args ^. #argsAction,
418417
Dialog.argsContent =
419-
[ Grid.mediumCell
420-
$ textField
421-
Args
422-
{ argsModel = args ^. #argsModel,
423-
argsOptic = cloneTraversal opt . ix idx . cloneTraversal lbl,
424-
argsAction = args ^. #argsAction,
425-
argsEmitter = args ^. #argsEmitter
426-
}
427-
( defOpts
428-
& #optsPlaceholder
429-
.~ "Label"
430-
),
431-
Grid.mediumCell
432-
[ button_
418+
textField
419+
Args
420+
{ argsModel = args ^. #argsModel,
421+
argsOptic = cloneTraversal opt . ix idx . cloneTraversal lbl,
422+
argsAction = args ^. #argsAction,
423+
argsEmitter = args ^. #argsEmitter
424+
}
425+
( defOpts
426+
& #optsPlaceholder
427+
.~ "Label"
428+
)
429+
<> [ button_
433430
[ onClick
434431
. action
435432
. Jsm.addFieldPair
436433
$ cloneTraversal opt
437434
. ix idx
438435
. cloneTraversal fps
439436
]
440-
[text "Add note"]
441-
],
442-
Grid.smallCell
443-
[ button_
437+
[text "Add note"],
438+
button_
444439
[onClick . action $ Jsm.moveDown opt idx]
445-
[text "Down"]
446-
],
447-
Grid.smallCell
448-
[ button_
440+
[text "Down"],
441+
button_
449442
[onClick . action $ Jsm.moveUp opt idx]
450-
[text "Up"]
451-
],
452-
Grid.smallCell
453-
[ button_
443+
[text "Up"],
444+
button_
454445
[onClick . action $ Jsm.duplicateAt opt idx]
455-
[text "Clone"]
456-
],
457-
Grid.smallCell
458-
[ button_
446+
[text "Clone"],
447+
button_
459448
[onClick . action $ Jsm.removeAt opt idx]
460449
[text "Delete"]
461-
]
462-
]
450+
]
463451
}
464452
fieldModal args (ModalFieldWidget opt idx access sod) = do
465453
let st = args ^. #argsModel
@@ -489,8 +477,7 @@ fieldModal args (ModalFieldWidget opt idx access sod) = do
489477
Select.argsOptions = constTraversal $ enumerate @FieldType
490478
}
491479
)
492-
<> [ -- Grid.mediumCell
493-
-- $ Switch.switch
480+
<> [ -- Switch.switch
494481
-- st
495482
-- ( Switch.defOpts
496483
-- & #optsIcon
@@ -501,26 +488,18 @@ fieldModal args (ModalFieldWidget opt idx access sod) = do
501488
-- ( cloneTraversal optic
502489
-- . #fieldAllowCopy
503490
-- ),
504-
Grid.smallCell
505-
[ button_
506-
[onClick . action $ Jsm.moveDown opt idx]
507-
[text "Down"]
508-
],
509-
Grid.smallCell
510-
[ button_
511-
[onClick . action $ Jsm.moveUp opt idx]
512-
[text "Up"]
513-
],
514-
Grid.smallCell
515-
[ button_
516-
[onClick . action $ Jsm.duplicateAt opt idx]
517-
[text "Clone"]
518-
],
519-
Grid.smallCell
520-
[ button_
521-
[onClick . action $ Jsm.removeAt opt idx]
522-
[text "Delete"]
523-
]
491+
button_
492+
[onClick . action $ Jsm.moveDown opt idx]
493+
[text "Down"],
494+
button_
495+
[onClick . action $ Jsm.moveUp opt idx]
496+
[text "Up"],
497+
button_
498+
[onClick . action $ Jsm.duplicateAt opt idx]
499+
[text "Clone"],
500+
button_
501+
[onClick . action $ Jsm.removeAt opt idx]
502+
[text "Delete"]
524503
]
525504
}
526505
fieldModal args (ModalMiniWidget opt) =
@@ -531,9 +510,7 @@ fieldModal args (ModalMiniWidget opt) =
531510
Dialog.argsOptic = cloneTraversal opt . #fieldModalState,
532511
Dialog.argsAction = args ^. #argsAction,
533512
Dialog.argsContent =
534-
[ Grid.bigCell
535-
[ selectTypeWidget args opt
536-
]
513+
[ selectTypeWidget args opt
537514
]
538515
}
539516

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

Lines changed: 28 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ where
1010
import Functora.Miso.Prelude
1111
import Functora.Miso.Types
1212
import qualified Functora.Miso.Widgets.Field as Field
13-
import qualified Functora.Miso.Widgets.Grid as Grid
1413

1514
data Args model action f = Args
1615
{ argsModel :: model,
@@ -32,13 +31,18 @@ defOpts =
3231
}
3332

3433
fieldPairsViewer :: (Foldable1 f) => Args model action f -> [View action]
35-
fieldPairsViewer args@Args {argsOptic = optic} = do
36-
item <-
37-
zip [0 ..] . fromMaybe mempty $ args ^? #argsModel . cloneTraversal optic
38-
uncurry
39-
( fieldPairViewer args
40-
)
41-
item
34+
fieldPairsViewer args@Args {argsOptic = optic} =
35+
if null content
36+
then mempty
37+
else [dl_ mempty content]
38+
where
39+
content = do
40+
item <-
41+
zip [0 ..] . fromMaybe mempty $ args ^? #argsModel . cloneTraversal optic
42+
uncurry
43+
( fieldPairViewer args
44+
)
45+
item
4246

4347
fieldPairViewer ::
4448
( Foldable1 f
@@ -51,49 +55,32 @@ fieldPairViewer args@Args {argsOptic = optic} idx pair =
5155
( if k == mempty
5256
then mempty
5357
else
54-
[ cell
55-
[ strong_
56-
[ style_
57-
[ ("align-items", "center"),
58-
("align-content", "center"),
59-
("word-break", "normal"),
60-
("overflow-wrap", "anywhere"),
61-
("min-height", "56px"),
62-
("height", "auto"),
63-
("padding-top", "8px"),
64-
("padding-bottom", "8px"),
65-
("line-height", "150%")
66-
]
67-
]
68-
[ text $ pair ^. #fieldPairKey . #fieldOutput
69-
]
58+
[ dt_
59+
mempty
60+
[ text $ pair ^. #fieldPairKey . #fieldOutput
7061
]
7162
]
7263
)
7364
<> ( if v == mempty
7465
then mempty
7566
else
76-
[ cell
77-
$ Field.fieldViewer
78-
Field.Args
79-
{ Field.argsModel =
80-
args ^. #argsModel,
81-
Field.argsOptic =
82-
cloneTraversal optic . ix idx . #fieldPairValue,
83-
Field.argsAction =
84-
args ^. #argsAction,
85-
Field.argsEmitter =
86-
args ^. #argsEmitter
87-
}
88-
]
67+
singleton
68+
. dd_ mempty
69+
$ Field.fieldViewer
70+
Field.Args
71+
{ Field.argsModel =
72+
args ^. #argsModel,
73+
Field.argsOptic =
74+
cloneTraversal optic . ix idx . #fieldPairValue,
75+
Field.argsAction =
76+
args ^. #argsAction,
77+
Field.argsEmitter =
78+
args ^. #argsEmitter
79+
}
8980
)
9081
where
9182
k = pair ^. #fieldPairKey . #fieldOutput
9283
v = inspectDynamicField $ pair ^. #fieldPairValue . #fieldOutput
93-
cell =
94-
if k == mempty || v == mempty
95-
then Grid.bigCell
96-
else Grid.mediumCell
9784

9885
fieldPairsEditor :: Args model action Unique -> Opts -> [View action]
9986
fieldPairsEditor args@Args {argsModel = st, argsOptic = optic} opts = do

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

Lines changed: 0 additions & 43 deletions
This file was deleted.

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

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ where
99
import Functora.Miso.Prelude
1010
import Functora.Miso.Types
1111
import qualified Functora.Miso.Widgets.Field as Field
12-
import qualified Functora.Miso.Widgets.Grid as Grid
1312
import Functora.Money hiding (Currency, Money, Text)
1413

1514
data Args model action = Args
@@ -40,40 +39,25 @@ moneyViewer Args {argsModel = st, argsOptic = optic, argsAction = action} opts =
4039
case st ^? cloneTraversal optic of
4140
Nothing -> mempty
4241
Just money ->
43-
catMaybes
44-
[ if label == mempty
45-
then Nothing
46-
else
47-
Just
48-
$ cell
49-
[ strong_ mempty [text label]
50-
],
51-
Just
52-
$ cell
53-
[ div_
54-
[ style_ [("text-align", "center")]
55-
]
56-
$ Field.ratioField
57-
Field.Args
58-
{ Field.argsModel = st,
59-
Field.argsOptic = cloneTraversal optic . #moneyAmount,
60-
Field.argsAction = action,
61-
Field.argsEmitter = error "TODO_MONEY_EMITTER"
62-
}
63-
( Field.defOpts
64-
& #optsDisabled
65-
.~ True
66-
& #optsPlaceholder
67-
.~ inspectCurrencyInfo
68-
( money ^. #moneyCurrency . #currencyOutput
69-
)
70-
)
71-
]
72-
]
42+
( if label == mempty
43+
then mempty
44+
else [strong_ mempty [text label]]
45+
)
46+
<> Field.ratioField
47+
Field.Args
48+
{ Field.argsModel = st,
49+
Field.argsOptic = cloneTraversal optic . #moneyAmount,
50+
Field.argsAction = action,
51+
Field.argsEmitter = error "TODO_MONEY_EMITTER"
52+
}
53+
( Field.defOpts
54+
& #optsDisabled
55+
.~ True
56+
& #optsPlaceholder
57+
.~ inspectCurrencyInfo
58+
( money ^. #moneyCurrency . #currencyOutput
59+
)
60+
)
7361
where
74-
cell =
75-
if label == mempty
76-
then Grid.bigCell
77-
else Grid.mediumCell
7862
label =
7963
opts ^. #optsLabel

0 commit comments

Comments
 (0)