plane/apps/app/components/ui/linear-progress-indicator.tsx
Anmol Singh Bhatia 626aae696f
feat: favorite cycle and style: style improvements (#376)
* style: consistent btn

* style: caret direction for disclosure

* fix: progress tooltip value rounded

* chore: favorite cycle serivces

* chore: favorite cycle type and constant

* feat: favorite cycle feat added

* refactor: favorite services and type

* fix: build fix
2023-03-06 16:36:22 +05:30

33 lines
841 B
TypeScript

import React from "react";
import { Tooltip } from "./tooltip";
type Props = {
data: any;
};
export const LinearProgressIndicator: React.FC<Props> = ({ data }) => {
const total = data.reduce((acc: any, cur: any) => acc + cur.value, 0);
let progress = 0;
const bars = data.map((item: any) => {
const width = `${(item.value / total) * 100}%`;
const style = {
width,
backgroundColor: item.color,
};
progress += item.value;
return (
<Tooltip tooltipContent={`${item.name} ${Math.round(item.value)}%`}>
<div key={item.id} className="bar" style={style} />
</Tooltip>
);
});
return (
<div className="flex h-1 w-full items-center justify-between gap-1">
{total === 0 ? " - 0%" : <div className="flex h-full w-full gap-1 rounded-md">{bars}</div>}
</div>
);
};