-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🚀 feat(stepper): add custom color for stepper #673
Changes from 5 commits
68f9039
959c939
f49350f
89fa10a
dea9d9f
3c74d99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,9 +1,9 @@ | ||||||
import { arrayOf, bool, number, string } from 'prop-types'; | ||||||
import React from 'react'; | ||||||
import { number, arrayOf, string } from 'prop-types'; | ||||||
import styled from 'styled-components'; | ||||||
import styled, { css } from 'styled-components'; | ||||||
|
||||||
import activeDot from '../activeDot'; | ||||||
import Text from '../../Text'; | ||||||
import activeDot from '../activeDot'; | ||||||
|
||||||
const Wrapper = styled.View` | ||||||
flex-direction: row; | ||||||
|
@@ -17,67 +17,78 @@ const DotWrapper = styled.View` | |||||
const Dot = styled.View( | ||||||
({ | ||||||
active, | ||||||
secondary, | ||||||
theme: { | ||||||
yoga: { | ||||||
components: { stepper }, | ||||||
}, | ||||||
}, | ||||||
}) => ` | ||||||
width: 15px; | ||||||
height: 15px; | ||||||
}) => { | ||||||
const state = secondary ? 'secondary' : 'active'; | ||||||
|
||||||
margin-top: -6px; | ||||||
return css` | ||||||
width: 15px; | ||||||
height: 15px; | ||||||
margin-top: -6px; | ||||||
border-radius: ${stepper.dot.radius}px; | ||||||
background-color: ${ | ||||||
active | ||||||
? stepper.dot.backgroundColor.active | ||||||
: stepper.dot.backgroundColor.inactive | ||||||
}; | ||||||
`, | ||||||
border-radius: ${stepper.dot.radius}px; | ||||||
background-color: ${active | ||||||
? stepper.dot.backgroundColor[state] | ||||||
: stepper.dot.backgroundColor.inactive}; | ||||||
`; | ||||||
}, | ||||||
); | ||||||
|
||||||
const Label = styled(Text.Bold)( | ||||||
({ | ||||||
active, | ||||||
secondary, | ||||||
theme: { | ||||||
yoga: { | ||||||
components: { stepper }, | ||||||
}, | ||||||
}, | ||||||
}) => ` | ||||||
width: 95px; | ||||||
margin-top: 10px; | ||||||
margin-left: -40px; | ||||||
}) => { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Codacy has a fix for the issue: Delete
Suggested change
|
||||||
const state = secondary ? 'secondary' : 'active'; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Codacy has a fix for the issue: Delete
Suggested change
|
||||||
|
||||||
color: ${ | ||||||
active ? stepper.label.color.active : stepper.label.color.inactive | ||||||
}; | ||||||
font-size: ${stepper.label.font.size}px; | ||||||
text-align: center; | ||||||
`, | ||||||
return css` | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Codacy has a fix for the issue: Delete
Suggested change
|
||||||
width: 95px; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Codacy has a fix for the issue: Delete
Suggested change
|
||||||
margin-top: 10px; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Codacy has a fix for the issue: Delete
Suggested change
|
||||||
margin-left: -40px; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Codacy has a fix for the issue: Delete
Suggested change
|
||||||
color: ${active | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Codacy has a fix for the issue: Delete
Suggested change
|
||||||
? stepper.label.color[state] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Codacy has a fix for the issue: Delete
Suggested change
|
||||||
: stepper.label.color.inactive}; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Codacy has a fix for the issue: Replace
Suggested change
|
||||||
font-size: ${stepper.label.font.size}px; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Codacy has a fix for the issue: Delete
Suggested change
|
||||||
text-align: center; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Codacy has a fix for the issue: Delete
Suggested change
|
||||||
`; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Codacy has a fix for the issue: Replace
Suggested change
|
||||||
}, | ||||||
); | ||||||
|
||||||
const Dots = ({ activeStep, labels }) => ( | ||||||
<Wrapper> | ||||||
{labels.map((label, index) => ( | ||||||
<DotWrapper key={label}> | ||||||
<Dot active={activeDot(index, activeStep)} /> | ||||||
<Label active={activeDot(index, activeStep)}>{label}</Label> | ||||||
</DotWrapper> | ||||||
))} | ||||||
</Wrapper> | ||||||
); | ||||||
function Dots({ activeStep, labels, secondary }) { | ||||||
return ( | ||||||
<Wrapper> | ||||||
{labels.map((label, index) => ( | ||||||
<DotWrapper key={label}> | ||||||
<Dot active={activeDot(index, activeStep)} secondary={secondary} /> | ||||||
<Label active={activeDot(index, activeStep)} secondary={secondary}> | ||||||
{label} | ||||||
</Label> | ||||||
</DotWrapper> | ||||||
))} | ||||||
</Wrapper> | ||||||
); | ||||||
} | ||||||
|
||||||
Dots.propTypes = { | ||||||
activeStep: number, | ||||||
labels: arrayOf(string), | ||||||
secondary: bool, | ||||||
}; | ||||||
|
||||||
Dots.defaultProps = { | ||||||
activeStep: 0, | ||||||
labels: [], | ||||||
secondary: false, | ||||||
}; | ||||||
|
||||||
export default Dots; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy has a fix for the issue: Replace
····
with··