-
Notifications
You must be signed in to change notification settings - Fork 9
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
Update Steps #301
Merged
Merged
Update Steps #301
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,52 +4,82 @@ import classNames from 'classnames'; | |
import Icon from './Icon.js'; | ||
import styles from './Steps.scss'; | ||
|
||
const Steps = ({ complete, step, steps }) => { | ||
const className = `${styles.steps} ${complete ? styles.complete : ''}`; | ||
const Steps = ({ collapse, complete, step, steps }) => { | ||
const className = classNames({ | ||
[styles.complete]: complete, | ||
[styles.steps]: true, | ||
'm-0': true | ||
}); | ||
const activeStep = steps[step]; | ||
const activeStepClasses = classNames({ | ||
'text-gray-dark': !complete, | ||
'text-success': complete, | ||
'hidden-sm-up': collapse !== true, | ||
'text-center': true | ||
}); | ||
|
||
return ( | ||
<ol className={className}> | ||
{steps.map((name, index) => { | ||
const stepComplete = !complete && index < step; | ||
const stepActive = !complete && index === step; | ||
|
||
const liClasses = classNames({ | ||
[styles.step]: true, | ||
[styles.complete]: stepComplete, | ||
[styles.active]: stepActive, | ||
}); | ||
|
||
const bubbleClasses = classNames({ | ||
[styles.bubble]: true, | ||
'text-success': complete, | ||
'bg-primary': stepActive, | ||
'text-primary': stepComplete, | ||
'text-white': stepActive, | ||
}); | ||
|
||
const textClasses = classNames({ | ||
[styles.text]: true, | ||
'text-primary': stepComplete, | ||
'text-muted': !complete && index > step, | ||
'text-success': complete, | ||
}); | ||
|
||
return ( | ||
<li key={index} className={liClasses}> | ||
<div className={bubbleClasses}> | ||
{complete || stepComplete ? <Icon name="check" /> : index + 1} | ||
</div> | ||
<div className={textClasses}>{name}</div> | ||
</li> | ||
); | ||
})} | ||
</ol> | ||
<div className="mb-3"> | ||
<ol className={className}> | ||
{steps.map((name, index) => { | ||
const stepComplete = !complete && index < step; | ||
const stepActive = !complete && index === step; | ||
|
||
const liClasses = classNames({ | ||
[styles.step]: true, | ||
[styles.complete]: stepComplete, | ||
[styles.active]: stepActive, | ||
'text-success': complete, | ||
'text-primary': !complete && (stepComplete || stepActive), | ||
'text-muted': !(stepComplete || stepActive || complete) | ||
}); | ||
|
||
const bubbleClasses = classNames({ | ||
[styles.bubble]: true, | ||
'text-success': complete, | ||
'bg-primary': stepActive, | ||
'text-primary': stepActive || stepComplete, | ||
'text-muted': !stepComplete && !stepActive | ||
}); | ||
|
||
const iconClasses = classNames({ | ||
'text-primary': stepComplete, | ||
'text-white': stepActive, | ||
'text-gray-dark': !(complete || stepComplete || stepActive), | ||
'text-success': complete | ||
}); | ||
|
||
const textClasses = classNames({ | ||
'hidden-xs-down': collapse !== false, | ||
'text-primary': stepComplete, | ||
'text-muted': !complete && index > step, | ||
'text-success': complete, | ||
'text-gray-dark': stepActive, | ||
}); | ||
|
||
return ( | ||
<li key={index} className={liClasses}> | ||
<div className={bubbleClasses}> | ||
<span className={iconClasses}>{complete || stepComplete ? <Icon name="check" /> : index + 1}</span> | ||
</div> | ||
{collapse !== true ? <label className={textClasses}>{name}</label> : null} | ||
</li> | ||
); | ||
})} | ||
</ol> | ||
{collapse !== false ? | ||
<div className={activeStepClasses}> | ||
<label>{activeStep}</label> | ||
</div> : null} | ||
</div> | ||
); | ||
}; | ||
|
||
Steps.propTypes = { | ||
collapse: PropTypes.bool, | ||
complete: PropTypes.bool, | ||
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. any reason why 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. Complete is only required if done, but good point on step... maybe that should required. Thanks |
||
step: PropTypes.number, | ||
steps: PropTypes.array.isRequired, | ||
complete: PropTypes.bool | ||
steps: PropTypes.array.isRequired | ||
}; | ||
|
||
export default Steps; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
should we give
collapse
a default value?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.
Thanks for noticing, Paulus and I discussed that we could default to responsive behavior (collapse on < sm) if this prop is not present. True or false would force collapse or expanded labels respectively.