-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: switch to gauge for topology metrics
Closes #1477
- Loading branch information
1 parent
6addf52
commit a160298
Showing
4 changed files
with
90 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React, { ComponentProps } from "react"; | ||
import { Story, Meta } from "@storybook/react"; | ||
import ProgressBar from "./ProgressBar"; | ||
|
||
export default { | ||
title: "ProgressBar", | ||
component: ProgressBar | ||
} as Meta; | ||
|
||
const Template: Story<ComponentProps<typeof ProgressBar>> = (args) => ( | ||
<div className="flex flex-col space-y-4"> | ||
<ProgressBar {...args} /> | ||
</div> | ||
); | ||
|
||
export const FivePercent = Template.bind({}); | ||
FivePercent.args = { | ||
value: 5 | ||
}; | ||
|
||
export const FiftyPercent = Template.bind({}); | ||
FiftyPercent.args = { | ||
value: 50 | ||
}; | ||
|
||
export const EightyPercent = Template.bind({}); | ||
EightyPercent.args = { | ||
value: 80 | ||
}; |
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,29 @@ | ||
import React, { CSSProperties } from "react"; | ||
|
||
interface Props { | ||
value: number; | ||
className?: string; | ||
} | ||
|
||
export default function ProgressBar({ value, className = "h-3" }: Props) { | ||
const barStyle: CSSProperties = { | ||
width: `${value}%`, | ||
backgroundColor: value > 70 ? "red" : "green" | ||
}; | ||
|
||
const roundingClassName = | ||
value < 25 | ||
? "rounded-l-2xl" | ||
: value > 50 | ||
? "rounded-full" | ||
: "rounded-l-xl rounded-r-xl"; | ||
|
||
return ( | ||
<div className={`relative rounded-full bg-gray-400 ${className}`}> | ||
<div | ||
className={`absolute top-0 left-0 h-full ${roundingClassName}`} | ||
style={barStyle} | ||
></div> | ||
</div> | ||
); | ||
} |