Add space allocation component
This commit is contained in:
parent
b31a0b9383
commit
d24b7ba636
|
@ -0,0 +1,40 @@
|
|||
import { PrettyBytes } from "../../utils/bytes";
|
||||
import "./spaceAllocation.css";
|
||||
import React from "react";
|
||||
|
||||
type Props = {
|
||||
data: {
|
||||
title: string;
|
||||
percent: number;
|
||||
size: number;
|
||||
}[];
|
||||
};
|
||||
|
||||
export function SpaceAllocation({ data }: Props) {
|
||||
return (
|
||||
<>
|
||||
<div className="nodeSpaceAllocation-bar">
|
||||
{data.map((d, index) => (
|
||||
<span
|
||||
className={`nodeSpaceAllocation-barItem nodeSpaceAllocation-barQuota nodeSpaceAllocation-quota-${index}`}
|
||||
style={{ width: d.percent + "%" }}
|
||||
></span>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="nodeSpaceAllocation-legend">
|
||||
{data.map((d, index) => (
|
||||
<div className="nodeSpaceAllocation-legendRow">
|
||||
<div className="nodeSpaceAllocation-legendLeft">
|
||||
<div
|
||||
className={`nodeSpaceAllocation-legendItem nodeSpaceAllocation-quota nodeSpaceAllocation-quota-${index}`}
|
||||
></div>
|
||||
<span>{d.title}</span>
|
||||
</div>
|
||||
<small>{PrettyBytes(d.size)}</small>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
.nodeSpaceAllocation-bar {
|
||||
height: 10px;
|
||||
display: flex;
|
||||
gap: 0.75rem;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.nodeSpaceAllocation-barQuota {
|
||||
width: 10%;
|
||||
}
|
||||
|
||||
.nodeSpaceAllocation-barItem {
|
||||
display: inline-block;
|
||||
height: 100%;
|
||||
border-radius: var(--codex-border-radius);
|
||||
}
|
||||
|
||||
.nodeSpaceAllocation-barQuota-used {
|
||||
border-top-left-radius: var(--codex-border-radius);
|
||||
border-bottom-left-radius: var(--codex-border-radius);
|
||||
border-radius: var(--codex-border-radius);
|
||||
}
|
||||
|
||||
.nodeSpaceAllocation-quota-0 {
|
||||
background-color: var(--codex-color);
|
||||
}
|
||||
|
||||
.nodeSpaceAllocation-quota-1 {
|
||||
background-color: var(--codex-color-primary);
|
||||
}
|
||||
|
||||
.nodeSpaceAllocation-quota-2 {
|
||||
background-color: #f9fa93;
|
||||
}
|
||||
|
||||
.nodeSpaceAllocation-legend {
|
||||
margin-top: 0.75rem;
|
||||
}
|
||||
|
||||
.nodeSpaceAllocation-legendItem {
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
border-radius: var(--codex-border-radius);
|
||||
}
|
||||
|
||||
.nodeSpaceAllocation-legendRow {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 0.75rem;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.nodeSpaceAllocation-legendLeft {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
import { SpaceAllocation } from "../components/SpaceAllocation/SpaceAllocation";
|
||||
|
||||
const meta = {
|
||||
title: "Advanced/SpaceAllocation",
|
||||
component: SpaceAllocation,
|
||||
parameters: {
|
||||
layout: "centered",
|
||||
},
|
||||
tags: ["autodocs"],
|
||||
argTypes: {},
|
||||
} satisfies Meta<typeof SpaceAllocation>;
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof meta>;
|
||||
|
||||
export const Default: Story = {
|
||||
args: {
|
||||
data: [
|
||||
{
|
||||
title: "Maximum storage space used by the node",
|
||||
percent: 60,
|
||||
size: 10000000,
|
||||
},
|
||||
{
|
||||
title: "Amount of storage space currently in use",
|
||||
percent: 20,
|
||||
size: 10000000 * 0.2,
|
||||
},
|
||||
{
|
||||
title: "Amount of storage space reserved",
|
||||
percent: 20,
|
||||
size: 10000000 * 0.2,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
Loading…
Reference in New Issue