slopus--happy
98e40dac97
CLI Smoke Test / smoke-test-linux (20) (push) Has been cancelled
CLI Smoke Test / smoke-test-linux (24) (push) Has been cancelled
CLI Smoke Test / smoke-test-windows (20) (push) Has been cancelled
CLI Smoke Test / smoke-test-windows (24) (push) Has been cancelled
Expo App TypeScript typecheck / typecheck (push) Has been cancelled
44 行
1.3 KiB
TypeScript
44 行
1.3 KiB
TypeScript
import './UsageLimitSection.css'
|
|
|
|
interface UsageLimitSectionProps {
|
|
title: string
|
|
description: string
|
|
percent: number
|
|
meta: string
|
|
action?: string
|
|
}
|
|
|
|
export function UsageLimitSection({
|
|
title,
|
|
description,
|
|
percent,
|
|
meta,
|
|
action = 'Manage',
|
|
}: UsageLimitSectionProps) {
|
|
const clamped = Math.max(0, Math.min(100, percent))
|
|
|
|
return (
|
|
<section className="usage-limit-section">
|
|
<div className="usage-limit-section__header">
|
|
<div>
|
|
<h3 className="usage-limit-section__title">{title}</h3>
|
|
<p className="usage-limit-section__description">{description}</p>
|
|
</div>
|
|
<button type="button" className="usage-limit-section__action">
|
|
{action}
|
|
</button>
|
|
</div>
|
|
<div className="usage-limit-section__meter" aria-label={`${title} ${clamped}% used`}>
|
|
<div
|
|
className="usage-limit-section__fill"
|
|
style={{ width: `${clamped}%` }}
|
|
/>
|
|
</div>
|
|
<div className="usage-limit-section__meta">
|
|
<span>{meta}</span>
|
|
<span>{clamped}%</span>
|
|
</div>
|
|
</section>
|
|
)
|
|
}
|