From 92c570f644a365e9c38ccbd88d950bc14d2e08a3 Mon Sep 17 00:00:00 2001 From: Alex <33497058+bexsoft@users.noreply.github.com> Date: Tue, 24 Oct 2023 16:25:33 -0600 Subject: [PATCH] Added improvements to ProgressBar component (#554) Signed-off-by: Benjamin Perez --- .../ProgressBar/ProgressBar.stories.tsx | 13 +++ src/components/ProgressBar/ProgressBar.tsx | 89 +++++++++++-------- .../ProgressBar/ProgressBar.types.ts | 2 + 3 files changed, 65 insertions(+), 39 deletions(-) diff --git a/src/components/ProgressBar/ProgressBar.stories.tsx b/src/components/ProgressBar/ProgressBar.stories.tsx index f53d8965..75c918c6 100644 --- a/src/components/ProgressBar/ProgressBar.stories.tsx +++ b/src/components/ProgressBar/ProgressBar.stories.tsx @@ -62,3 +62,16 @@ export const Indeterminate = Template.bind({}); Indeterminate.args = { variant: "indeterminate", }; + +export const CustomHeight = Template.bind({}); +CustomHeight.args = { + variant: "indeterminate", + barHeight: 3, +}; + +export const TransparentBackground = Template.bind({}); +TransparentBackground.args = { + variant: "indeterminate", + barHeight: 5, + transparentBG: true, +}; diff --git a/src/components/ProgressBar/ProgressBar.tsx b/src/components/ProgressBar/ProgressBar.tsx index 89e845fe..1d9c77c4 100644 --- a/src/components/ProgressBar/ProgressBar.tsx +++ b/src/components/ProgressBar/ProgressBar.tsx @@ -29,41 +29,45 @@ const colorItems = { grey: "disabled", }; -const ProgressBase = styled.div(({ theme, sx, color }) => ({ - "& .progBlock": { - display: "flex", - alignItems: "center", - gap: 10, - }, - "& .progressContainer": { - position: "relative", - width: "100%", - height: 8, - backgroundColor: get(theme, "boxBackground", lightColors.boxBackground), - borderRadius: 8, - overflow: "hidden", - }, - "& .notificationLabel": { - fontSize: 12, - color: get( - theme, - `signalColors.${colorItems[color || "blue"]}`, - lightColors.mainBlue, - ), - }, - "& .percentageBar": { - display: "block", - height: 8, - backgroundColor: get( - theme, - `signalColors.${colorItems[color || "blue"]}`, - lightColors.mainBlue, - ), - transitionDuration: "0.1s", - borderRadius: 8, - }, - ...sx, -})); +const ProgressBase = styled.div( + ({ theme, sx, color, barHeight, transparentBG }) => ({ + "& .progBlock": { + display: "flex", + alignItems: "center", + gap: 10, + }, + "& .progressContainer": { + position: "relative", + width: "100%", + height: barHeight, + backgroundColor: transparentBG + ? "transparent" + : get(theme, "boxBackground", lightColors.boxBackground), + borderRadius: barHeight, + overflow: "hidden", + }, + "& .notificationLabel": { + fontSize: 12, + color: get( + theme, + `signalColors.${colorItems[color || "blue"]}`, + lightColors.mainBlue, + ), + }, + "& .percentageBar": { + display: "block", + height: barHeight, + backgroundColor: get( + theme, + `signalColors.${colorItems[color || "blue"]}`, + lightColors.mainBlue, + ), + transitionDuration: "0.1s", + borderRadius: barHeight, + }, + ...sx, + }), +); export const innerAnimation = keyframes`0% { left: -100px; @@ -83,10 +87,10 @@ export const innerAnimation = keyframes`0% { const IndeterminateItem = styled.div` width: 100px; - height: 8px; + height: ${(props) => get(props, "barHeight", 8)}px; display: block; position: absolute; - border-radius: 8px; + border-radius: ${(props) => get(props, "barHeight", 8)}px; animation: ${innerAnimation} 1000ms linear infinite normal forwards; background-color: ${(props) => get( @@ -104,15 +108,22 @@ const ProgressBar: FC = ({ variant = "indeterminate", notificationLabel = "", color = "blue", + barHeight = 8, + transparentBG = false, }) => { const calcPerc = (value * 100) / maxValue; return ( - + {variant === "indeterminate" ? ( - + ) : (