mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
## Problem Knip reports many duplicate exports (both named and default). Besides, we're moving away from default exports and even have an eslint rule to enforce it on new code. ## Solution - Cleanup those exports - Update imports when necessary No functional changes. If it builds, it's fine
78 lines
2.1 KiB
TypeScript
78 lines
2.1 KiB
TypeScript
import { cn } from 'ui'
|
|
|
|
interface SparkBarProps {
|
|
value: number
|
|
max?: number
|
|
type?: 'horizontal' | 'vertical'
|
|
labelTop?: string
|
|
labelTopClass?: string
|
|
labelBottom?: string
|
|
labelBottomClass?: string
|
|
barClass?: string
|
|
bgClass?: string
|
|
borderClass?: string
|
|
}
|
|
|
|
export const SparkBar = ({
|
|
max = 100,
|
|
value = 0,
|
|
barClass = 'bg-foreground',
|
|
bgClass = '',
|
|
type = 'vertical',
|
|
borderClass = '',
|
|
labelBottom = '',
|
|
labelBottomClass = 'tabular-nums',
|
|
labelTop = '',
|
|
labelTopClass = '',
|
|
}: SparkBarProps) => {
|
|
if (type === 'horizontal') {
|
|
const width = Number((value / max) * 100)
|
|
const widthCss = `${width}%`
|
|
const hasLabels = labelBottom || labelTop
|
|
|
|
return (
|
|
<div className="flex flex-col w-full">
|
|
{hasLabels && (
|
|
<div className="flex align-baseline justify-between pb-1 space-x-8">
|
|
<p
|
|
className={cn(
|
|
'text-foreground text-sm truncate capitalize-sentence',
|
|
labelTop.length > 0 && 'max-w-[75%]',
|
|
labelBottomClass
|
|
)}
|
|
>
|
|
{labelBottom}
|
|
</p>
|
|
<p className={cn('text-foreground-light text-sm', labelTopClass)}>{labelTop}</p>
|
|
</div>
|
|
)}
|
|
<div
|
|
className={`relative rounded-sm h-1 overflow-hidden w-full border p-0 ${
|
|
bgClass ? bgClass : 'bg-surface-400'
|
|
} ${borderClass ? borderClass : 'border-none'}`}
|
|
>
|
|
<div
|
|
className={`absolute rounded-sm inset-x-0 bottom-0 h-1 ${barClass} transition-all`}
|
|
style={{ width: widthCss }}
|
|
></div>
|
|
</div>
|
|
</div>
|
|
)
|
|
} else {
|
|
const totalHeight = 35
|
|
let height = Number((value / max) * totalHeight)
|
|
if (height < 2) height = 2
|
|
|
|
return (
|
|
<div
|
|
className={`relative rounded-sm w-5 overflow-hidden border p-1 ${
|
|
bgClass ? bgClass : 'bg-gray-400'
|
|
} ${borderClass ? borderClass : 'border-none'}`}
|
|
style={{ height: totalHeight }}
|
|
>
|
|
<div className={`absolute inset-x-0 bottom-0 w-5 ${barClass}`} style={{ height }}></div>
|
|
</div>
|
|
)
|
|
}
|
|
}
|