Skip to content

Commit 873b8cf

Browse files
committed
buttonState :: ButtonState
1 parent 1a78e4e commit 873b8cf

File tree

6 files changed

+27
-31
lines changed

6 files changed

+27
-31
lines changed

docs/Examples/Button.example.purs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ docs =
2727

2828
, [ h2_ "Disabled"
2929
, example
30-
$ button defaults { title = "Button", buttonState = Just $ Disabled }
30+
$ button defaults { title = "Button", buttonState = Disabled }
3131
]
3232

3333
, [ h2_ "Size"
@@ -56,7 +56,7 @@ docs =
5656
]
5757
, [ h4_ "Primary + Disabled"
5858
, example
59-
$ button primary { title = "Button", buttonState = Just $ Disabled }
59+
$ button primary { title = "Button", buttonState = Disabled }
6060
]
6161
, [ h4_ "Secondary Medium (default)"
6262
, example
@@ -76,7 +76,7 @@ docs =
7676
]
7777
, [ h4_ "Secondary + Disabled"
7878
, example
79-
$ button secondary { title = "Button", buttonState = Just $ Disabled }
79+
$ button secondary { title = "Button", buttonState = Disabled }
8080
]
8181
, [ h4_ "Icon button"
8282
, example
@@ -100,19 +100,19 @@ docs =
100100
]
101101
, [ h4_ "Loading (Medium/default)"
102102
, example
103-
$ button primary { buttonState = Just $ Loading }
103+
$ button primary { buttonState = Loading }
104104
]
105105
, [ h4_ "Loading (Small) "
106106
, example
107-
$ button primary { buttonState = Just $ Loading, size = Small }
107+
$ button primary { buttonState = Loading, size = Small }
108108
]
109109
, [ h4_ "Loading (Large) "
110110
, example
111-
$ button primary { buttonState = Just $ Loading, size = Large }
111+
$ button primary { buttonState = Loading, size = Large }
112112
]
113113
, [ h4_ "Loading (ExtraLarge) "
114114
, example
115-
$ button primary { buttonState = Just $ Loading, size = ExtraLarge }
115+
$ button primary { buttonState = Loading, size = ExtraLarge }
116116
]
117117
]
118118

docs/Examples/InputGroup.example.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ docs =
2323
, addOnLeft:
2424
toNullable $ Just $ R.div
2525
{ children:
26-
[ button defaults { title = "Button", buttonState = Just $ Enabled }
26+
[ button defaults { title = "Button", buttonState = Enabled }
2727
]
2828
}
2929
, addOnRight:
3030
toNullable $ Just $ R.div
3131
{ children:
32-
[ button defaults { title = "Button", buttonState = Just $ Enabled }
32+
[ button defaults { title = "Button", buttonState = Enabled }
3333
]
3434
}
3535
, inputContent: toNullable $ Just $ input text_ { placeholder = "Placeholder..." }

docs/Examples/Wizard.example.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ docs = unit # make (createComponent "WizardExample") { initialState, render }
8787
in
8888
[ Button.button Button.secondary
8989
{ title = "Back"
90-
, buttonState = Just $ if isNothing previousStepM then Button.Disabled else Button.Enabled
90+
, buttonState = if isNothing previousStepM then Button.Disabled else Button.Enabled
9191
, onPress = maybe (mkEffectFn1 mempty) (capture identity <<< const <<< send self <<< SetWizardStep) previousStepM
9292
}
9393
, Button.button Button.primary

src/Lumi/Components/Button.purs

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type CommonButtonProps rest =
3333
, testId :: Nullable String
3434
, title :: String
3535
, type :: String
36-
, buttonState :: Maybe ButtonState
36+
, buttonState :: ButtonState
3737
| rest
3838
}
3939

@@ -69,16 +69,14 @@ button = makeStateless component render
6969
, "data-testid": props.testId
7070
, disabled:
7171
case props.buttonState of
72-
Just Enabled -> false
73-
Just Disabled -> true
74-
Just Loading -> false
75-
Nothing -> false
72+
Enabled -> false
73+
Disabled -> true
74+
Loading -> false
7675
, "data-loading":
7776
case props.buttonState of
78-
Just Enabled -> false
79-
Just Disabled -> false
80-
Just Loading -> true
81-
Nothing -> false
77+
Enabled -> false
78+
Disabled -> false
79+
Loading -> true
8280
, onClick: props.onPress
8381
, style: props.style
8482
, type: props.type
@@ -99,7 +97,7 @@ defaults =
9997
, testId: toNullable Nothing
10098
, title: invisibleSpace
10199
, type: ""
102-
, buttonState: Nothing
100+
, buttonState: Enabled
103101
}
104102

105103
primary :: ButtonProps
@@ -145,16 +143,14 @@ iconButton = makeStateless iconComponent render
145143
, type: props.type
146144
, disabled:
147145
case props.buttonState of
148-
Just Enabled -> false
149-
Just Disabled -> true
150-
Just Loading -> true
151-
Nothing -> false
146+
Enabled -> false
147+
Disabled -> true
148+
Loading -> true
152149
, "data-loading":
153150
case props.buttonState of
154-
Just Enabled -> false
155-
Just Disabled -> true
156-
Just Loading -> true
157-
Nothing -> false
151+
Enabled -> false
152+
Disabled -> true
153+
Loading -> true
158154
}
159155
where
160156
children =
@@ -184,7 +180,7 @@ iconButtonDefaults =
184180
, type: ""
185181
, iconLeft: Nothing
186182
, iconRight: Nothing
187-
, buttonState: Nothing
183+
, buttonState: Enabled
188184
}
189185

190186
styles :: JSS

src/Lumi/Components/Modal.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ modalPortal = toReactComponent identity modalPortalComponent
279279
, toMaybe props.onActionButtonClick # foldMap \actionFn ->
280280
Button.button Button.primary
281281
{ title = props.actionButtonTitle
282-
, buttonState = Just $ props.actionButtonDisabled
282+
, buttonState = props.actionButtonDisabled
283283
, onPress = mkEffectFn1 \_ -> actionFn
284284
, style = R.css { marginLeft: "1.2rem" }
285285
}

src/Lumi/Components/Pagination.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pagination = makeStateless (createComponent "Pagination") render
6161
[ Button.button Button.secondary
6262
{ title = show (i + 1)
6363
, onPress = handler_ $ props.onChange i
64-
, buttonState = Just $ if i == props.currentPage then Button.Disabled else Button.Enabled
64+
, buttonState = if i == props.currentPage then Button.Disabled else Button.Enabled
6565
}
6666
]
6767

0 commit comments

Comments
 (0)