Skip to content

Commit 7447f95

Browse files
committed
miso-capa wip
1 parent 88c8628 commit 7447f95

File tree

7 files changed

+8
-215
lines changed

7 files changed

+8
-215
lines changed

ghcjs/miso-capa/miso-capa.cabal

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ library
107107
Functora.Miso.Capa.Frame
108108
Functora.Miso.Capa.Grid
109109
Functora.Miso.Capa.Header
110-
Functora.Miso.Capa.IconToggles
111110
Functora.Miso.Capa.Money
112111
Functora.Miso.Capa.Qr
113112
Functora.Miso.Capa.Switch
@@ -142,7 +141,6 @@ test-suite miso-capa-test
142141
Functora.Miso.Capa.Frame
143142
Functora.Miso.Capa.Grid
144143
Functora.Miso.Capa.Header
145-
Functora.Miso.Capa.IconToggles
146144
Functora.Miso.Capa.Money
147145
Functora.Miso.Capa.Qr
148146
Functora.Miso.Capa.Switch

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ data Opts model action = Opts
6060
optsLeadingWidget :: Maybe (OptsWidgetPair model action),
6161
optsTrailingWidget :: Maybe (OptsWidgetPair model action),
6262
optsOnKeyDownAction :: Uid -> KeyCode -> model -> JSM model,
63-
optsExtraAttributes :: [Attribute action],
64-
optsFilledOrOutlined :: FilledOrOutlined
63+
optsExtraAttributes :: [Attribute action]
6564
}
6665
deriving stock (Generic)
6766

@@ -81,8 +80,7 @@ defOpts =
8180
optsLeadingWidget = Just $ OptsWidgetPair PasteWidget PasteWidget,
8281
optsTrailingWidget = Just $ OptsWidgetPair ClearWidget ClearWidget,
8382
optsOnKeyDownAction = Jsm.enterOrEscapeBlur,
84-
optsExtraAttributes = mempty,
85-
optsFilledOrOutlined = Filled
83+
optsExtraAttributes = mempty
8684
}
8785

8886
data OptsWidget model action
@@ -148,10 +146,9 @@ field full@Full {fullArgs = args, fullParser = parser, fullViewer = viewer} opts
148146
_ -> mempty
149147
fieldModal args x1
150148
)
151-
<> [ keyed uid
152-
$ case opts ^. #optsFilledOrOutlined of
153-
Filled -> TextField.filled
154-
Outlined -> TextField.outlined
149+
<> [ keyed
150+
uid
151+
$ TextField.outlined
155152
$ TextField.config
156153
& TextField.setType
157154
( fmap htmlFieldType (st ^? cloneTraversal optic . #fieldType)
@@ -717,9 +714,7 @@ constTextField ::
717714
constTextField txt opts action =
718715
cell
719716
opts
720-
[ case opts ^. #optsFilledOrOutlined of
721-
Filled -> TextField.filled
722-
Outlined -> TextField.outlined
717+
[ TextField.outlined
723718
$ TextField.config
724719
& TextField.setDisabled True
725720
& TextField.setValue (Just txt)

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,7 @@ headerEditor args opts =
2525
("justify-content", "center")
2626
]
2727
]
28-
[ Field.dynamicField
29-
args
30-
( opts
31-
& #optsFilledOrOutlined
32-
.~ Outlined
33-
)
28+
[ Field.dynamicField args opts
3429
]
3530
]
3631
]

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

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

ghcjs/miso-capa/src/Functora/Miso/Jsm/Specific.hs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
module Functora.Miso.Jsm.Specific
22
( addFieldPair,
3-
addAsset,
4-
addPaymentMethod,
53
duplicateAt,
64
)
75
where
@@ -10,7 +8,6 @@ import qualified Data.Generics as Syb
108
import qualified Functora.Miso.Jsm.Generic as Jsm
119
import Functora.Miso.Prelude
1210
import Functora.Miso.Types
13-
import Functora.Money (CurrencyCode (..), CurrencyInfo (..))
1411

1512
addFieldPair ::
1613
ATraversal' model [FieldPair DynamicField Unique] -> model -> JSM model
@@ -19,21 +16,6 @@ addFieldPair optic st = do
1916
Jsm.popupText @Unicode "Added note!"
2017
pure $ st & cloneTraversal optic %~ (<> [item])
2118

22-
addAsset :: ATraversal' model [Asset Unique] -> model -> JSM model
23-
addAsset optic st = do
24-
let cur = CurrencyInfo (CurrencyCode "usd") mempty
25-
item <- newAsset "Price" 0 cur
26-
Jsm.popupText @Unicode "Added asset!"
27-
pure $ st & cloneTraversal optic %~ (<> [item])
28-
29-
addPaymentMethod ::
30-
ATraversal' model [PaymentMethod Unique] -> model -> JSM model
31-
addPaymentMethod optic st = do
32-
let cur = CurrencyInfo (CurrencyCode "btc") mempty
33-
item <- newPaymentMethod cur $ Just mempty
34-
Jsm.popupText @Unicode "Added payment!"
35-
pure $ st & cloneTraversal optic %~ (<> [item])
36-
3719
duplicateAt ::
3820
forall model item.
3921
( Data item

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ import Miso as X hiding
2323
import qualified Miso
2424

2525
consoleLog :: (Show a, Data a) => a -> JSM ()
26-
consoleLog = Miso.consoleLog . inspect
26+
consoleLog = Miso.consoleLog . inspect @Unicode

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

Lines changed: 0 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ module Functora.Miso.Types
3434
newCurrency,
3535
Money (..),
3636
newMoney,
37-
Asset (..),
38-
newAsset,
39-
PaymentMethod (..),
40-
newPaymentMethod,
4137
Fav (..),
4238
InstantOrDelayed (..),
4339
instantOrDelayedTime,
@@ -48,13 +44,10 @@ module Functora.Miso.Types
4844
identityToUnique,
4945
keyed,
5046
TopOrBottom (..),
51-
HeaderOrFooter (..),
5247
OnlineOrOffline (..),
5348
StaticOrDynamic (..),
5449
LeadingOrTrailing (..),
55-
FilledOrOutlined (..),
5650
OpenedOrClosed (..),
57-
AssetsAndPaymentsLayout (..),
5851
)
5952
where
6053

@@ -428,92 +421,6 @@ newMoney amt cur =
428421
<$> newRatioField amt
429422
<*> newCurrency cur
430423

431-
data Asset f = Asset
432-
{ assetPrice :: Money f,
433-
assetPriceLabel :: Field Unicode f,
434-
assetFieldPairs :: [FieldPair DynamicField f],
435-
assetModalState :: OpenedOrClosed
436-
}
437-
deriving stock (Generic)
438-
439-
deriving stock instance (Hkt f) => Eq (Asset f)
440-
441-
deriving stock instance (Hkt f) => Ord (Asset f)
442-
443-
deriving stock instance (Hkt f) => Show (Asset f)
444-
445-
deriving stock instance (Hkt f) => Data (Asset f)
446-
447-
instance FunctorB Asset
448-
449-
instance TraversableB Asset
450-
451-
deriving via GenericType (Asset Identity) instance Binary (Asset Identity)
452-
453-
newAsset ::
454-
( MonadIO m
455-
) =>
456-
Unicode ->
457-
Rational ->
458-
CurrencyInfo ->
459-
m (Asset Unique)
460-
newAsset label amt cur = do
461-
lbl <- newTextField label
462-
Asset
463-
<$> newMoney amt cur
464-
<*> pure lbl
465-
<*> pure mempty
466-
<*> pure Closed
467-
468-
data PaymentMethod f = PaymentMethod
469-
{ paymentMethodMoney :: Money f,
470-
paymentMethodMoneyLabel :: Field Unicode f,
471-
paymentMethodFieldPairs :: [FieldPair DynamicField f],
472-
paymentMethodModalState :: OpenedOrClosed
473-
}
474-
deriving stock (Generic)
475-
476-
deriving stock instance (Hkt f) => Eq (PaymentMethod f)
477-
478-
deriving stock instance (Hkt f) => Ord (PaymentMethod f)
479-
480-
deriving stock instance (Hkt f) => Show (PaymentMethod f)
481-
482-
deriving stock instance (Hkt f) => Data (PaymentMethod f)
483-
484-
instance FunctorB PaymentMethod
485-
486-
instance TraversableB PaymentMethod
487-
488-
deriving via
489-
GenericType (PaymentMethod Identity)
490-
instance
491-
Binary (PaymentMethod Identity)
492-
493-
newPaymentMethod ::
494-
( MonadIO m
495-
) =>
496-
CurrencyInfo ->
497-
Maybe Unicode ->
498-
m (PaymentMethod Unique)
499-
newPaymentMethod cur addr0 = do
500-
lbl <-
501-
newTextField $ inspectCurrencyInfo cur <> " total"
502-
addr1 <-
503-
maybe
504-
( pure Nothing
505-
)
506-
( fmap (Just . (& #fieldPairValue . #fieldType .~ FieldTypeQrCode))
507-
. newFieldPair (inspectCurrencyInfo cur <> " address")
508-
. DynamicFieldText
509-
)
510-
addr0
511-
PaymentMethod
512-
<$> newMoney 0 cur
513-
<*> pure lbl
514-
<*> pure (maybeToList addr1)
515-
<*> pure Closed
516-
517424
data Fav = Fav
518425
{ favUri :: URI,
519426
favCreatedAt :: UTCTime
@@ -595,12 +502,6 @@ data TopOrBottom
595502
deriving stock (Eq, Ord, Show, Enum, Bounded, Data, Generic)
596503
deriving (Binary) via GenericType TopOrBottom
597504

598-
data HeaderOrFooter
599-
= Header
600-
| Footer
601-
deriving stock (Eq, Ord, Show, Enum, Bounded, Data, Generic)
602-
deriving (Binary) via GenericType HeaderOrFooter
603-
604505
data OnlineOrOffline
605506
= Online
606507
| Offline
@@ -619,20 +520,8 @@ data LeadingOrTrailing
619520
deriving stock (Eq, Ord, Show, Enum, Bounded, Data, Generic)
620521
deriving (Binary) via GenericType LeadingOrTrailing
621522

622-
data FilledOrOutlined
623-
= Filled
624-
| Outlined
625-
deriving stock (Eq, Ord, Show, Enum, Bounded, Data, Generic)
626-
deriving (Binary) via GenericType FilledOrOutlined
627-
628523
data OpenedOrClosed
629524
= Opened
630525
| Closed
631526
deriving stock (Eq, Ord, Show, Enum, Bounded, Data, Generic)
632527
deriving (Binary) via GenericType OpenedOrClosed
633-
634-
data AssetsAndPaymentsLayout
635-
= AssetsBeforePayments
636-
| PaymentsBeforeAssets
637-
deriving stock (Eq, Ord, Show, Enum, Bounded, Data, Generic)
638-
deriving (Binary) via GenericType AssetsAndPaymentsLayout

0 commit comments

Comments
 (0)