-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ProgressBar): add ProgressBar component
- Loading branch information
Showing
5 changed files
with
66 additions
and
0 deletions.
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
|
||
const ProgressBar = ({ totalWidth = 120, percentComplete = 0 }) => { | ||
return ( | ||
<div | ||
className="nds-progressbar" | ||
style={{ width: `${totalWidth}px`, height: "18px" }} | ||
> | ||
<svg xmlns="http://www.w3.org/2000/svg"> | ||
<line | ||
x1="0%" | ||
y1="50%" | ||
x2={`${percentComplete}%`} | ||
y2="50%" | ||
strokeWidth="100%" | ||
/> | ||
</svg> | ||
</div> | ||
); | ||
}; | ||
|
||
ProgressBar.propTypes = { | ||
/** | ||
* Total width of progress bar | ||
*/ | ||
totalWidth: PropTypes.number, | ||
/** | ||
* Percent complete | ||
*/ | ||
percentComplete: PropTypes.number.isRequired, | ||
}; | ||
|
||
export default ProgressBar; |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.nds-progressbar { | ||
border: 1px solid var(--theme-primary); | ||
border-radius: var(--border-radius-default); | ||
//overflow: hidden; | ||
} | ||
|
||
.nds-progressbar svg { | ||
height: 100%; | ||
width: 100%; | ||
} | ||
|
||
.nds-progressbar line { | ||
stroke: var(--theme-primary); | ||
transition: all 0.5s ease-in-out; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from "react"; | ||
import ProgressBar from "./"; | ||
|
||
const Template = (args) => <ProgressBar {...args} />; | ||
|
||
export const Overview = Template.bind({}); | ||
Overview.args = { | ||
percentComplete: 25, | ||
}; | ||
|
||
export default { | ||
title: "Components/ProgressBar", | ||
component: ProgressBar, | ||
}; |
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