Skip to content

Commit

Permalink
feat(ProgressBar): add ProgressBar component
Browse files Browse the repository at this point in the history
  • Loading branch information
akdetrick committed Jan 24, 2024
1 parent e715cee commit d30d3ff
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/ProgressBar/index.js
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;
15 changes: 15 additions & 0 deletions src/ProgressBar/index.scss
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;
}
14 changes: 14 additions & 0 deletions src/ProgressBar/index.stories.js
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,
};
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import LoadingSkeleton from "./LoadingSkeleton";
import MenuButton from "./MenuButton";
import Pagination from "./Pagination";
import PlainButton from "./PlainButton";
import ProgressBar from "./Pagination";
import Popover from "./Popover";
import RadioButtons from "./RadioButtons";
import ResponsiveFlex from "./ResponsiveFlex";
Expand Down Expand Up @@ -59,6 +60,7 @@ export {
MenuButton,
Pagination,
PlainButton,
ProgressBar,
Popover,
RadioButtons,
ResponsiveFlex,
Expand Down
1 change: 1 addition & 0 deletions src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
@import "TruncatedAccount/";
@import "Row/";
@import "Pagination/";
@import "ProgressBar/";
@import "Select/";
@import "SeparatorList/";
@import "Sidebar/";
Expand Down

0 comments on commit d30d3ff

Please sign in to comment.