Skip to content

Commit 0097a22

Browse files
committed
one way customizing styles could work, but verbose
1 parent 2a56cc2 commit 0097a22

File tree

2 files changed

+34
-21
lines changed

2 files changed

+34
-21
lines changed

example/app.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,13 @@ const steps = [
1313
{ title: 'Step 4', component: <StepFour /> }
1414
]
1515

16-
// custom styles
17-
const navButtonStyle = { background: 'gray', color: 'white' }
18-
// const customStyle = {
19-
// color: 'red',
20-
// background: 'orange',
21-
// border: 'black'
22-
// }
23-
// customStyle = { customStyle }
24-
// navButtonStyle = { navButtonStyle }
25-
// showButtonNav
16+
// todo: custom styles
17+
const customStyles = {
18+
background: 'gray',
19+
color: 'white'
20+
}
21+
22+
// todo: signal 'next' valid from Steps
2623

2724
const App = () => (
2825
<div className='container'>

src/MultiStep.jsx

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,18 @@ const Done = css`
6868
background-color: #33C3F0;
6969
}
7070
`
71-
const NavButton = styled('button')`
72-
background: #33C3F0;
73-
border-color: silver;
74-
color: white;
75-
76-
&:disabled {
77-
background: silver;
78-
border-color: gray;
79-
color: gray;
71+
72+
const NavButton = styled('button')((props) => ({
73+
borderRadius: props.borderRadius ? props.borderRadius + 'px' : '10px',
74+
background: props.background ? props.background : '#33C3F0',
75+
color: props.color ? props.color : 'white',
76+
'&:disabled': {
77+
background: props.disabledBackground ? props.disabledBackground : 'blue',
78+
color: props.disabledColor ? props.disabledColor : 'gray',
79+
cursor: props.disabledCursor ? props.disabledCursor : 'no-drop'
8080
}
81-
`
81+
}))
82+
8283

8384
const getStep = (newIndex, length) => {
8485
if (newIndex <= length && newIndex > 0) {
@@ -131,6 +132,21 @@ export default function MultiStep(props) {
131132
const showTitles = typeof props.showTitles === 'undefined' ? false : true
132133
const showNav = typeof props.showButtonNav === 'undefined' ? false : true
133134

135+
const extStyles =
136+
{
137+
nav: {
138+
background: '#3eC3Fe',
139+
border: 'red',
140+
color: 'red',
141+
disabled: {
142+
background: 'white',
143+
border: 'silver',
144+
color: 'gray',
145+
cursor: 'no-drop'
146+
}
147+
}
148+
}
149+
134150
const [activeStep, _] = useState(getStep(props.activeStep, props.steps.length));
135151
const [stylesState, setStyles] = useState(getTopNavStyles(activeStep, props.steps.length))
136152
const [compState, setComp] = useState(activeStep)
@@ -184,7 +200,7 @@ export default function MultiStep(props) {
184200
<>
185201
{
186202
buttonsState.showPrevious ?
187-
<NavButton onClick={previous}>Prev</NavButton> :
203+
<NavButton color={extStyles.nav.color} onClick={previous}>Prev</NavButton> :
188204
<NavButton disabled>Prev</NavButton>
189205
}
190206
{

0 commit comments

Comments
 (0)