Files
supabase/apps/studio/components/ui/SparkBar.tsx
T
Ivan VasilovandJordi Enric 56de26fe22 chore: Migrate the monorepo to use Tailwind v4 (#45318)
This PR migrates the whole monorepo to use Tailwind v4:
- Removed `@tailwindcss/container-queries` plugin since it's included by
default in v4,
- Bump all instances of Tailwind to v4. Made minimal changes to the
shared config to remove non-supported features (`alpha` mentions),
- Migrate all apps to be compatible with v4 configs,
- Fix the `typography.css` import in 3 apps,
- Add missing rules which were included by default in v3,
- Run `pnpm dlx @tailwindcss/upgrade` on all apps, which renames a lot
of classes
- Rename all misnamed classes according to
https://tailwindcss.com/docs/upgrade-guide#renamed-utilities in all
apps.

---------

Co-authored-by: Jordi Enric <jordi.err@gmail.com>
2026-04-30 10:53:24 +00:00

80 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>
)
}
}
export default SparkBar