Files
supabase/apps/studio/components/ui/Charts/ChartHeader.tsx
T
Ivan Vasilov 436bdb10ae chore: Move the studio app to apps/studio (#18915)
* Move all studio files from /studio to /apps/studio.

* Move studio specific prettier ignores.

* Fix the ui references from studio.

* Fix the css imports.

* Fix all package.json issues.

* Fix the prettier setup for the studio app.

* Add .turbo folder to prettierignore.

* Fix the github workflows.
2023-11-15 12:38:55 +01:00

57 lines
1.5 KiB
TypeScript

export interface ChartHeaderProps {
title?: string
format?: string | ((value: unknown) => string)
customDateFormat?: string
minimalHeader?: boolean
displayDateInUtc?: boolean
highlightedLabel?: number | string | null
highlightedValue?: number | string | null
}
const ChartHeader: React.FC<ChartHeaderProps> = ({
format,
highlightedValue,
highlightedLabel,
title,
minimalHeader = false,
}: ChartHeaderProps) => {
const chartTitle = (
<h3 className={'text-foreground-lighter ' + (minimalHeader ? 'text-xs' : 'text-sm')}>
{title}
</h3>
)
const highlighted = (
<h5
className={`text-foreground text-xl font-normal ${minimalHeader ? 'text-base' : 'text-2xl'}`}
>
{highlightedValue !== undefined && String(highlightedValue)}
<span className="text-lg">
{typeof format === 'function' ? format(highlightedValue) : format}
</span>
</h5>
)
const label = <h5 className="text-foreground-lighter text-xs">{highlightedLabel}</h5>
if (minimalHeader) {
return (
<div className="flex flex-row items-center gap-x-4" style={{ minHeight: '1.8rem' }}>
{title && chartTitle}
<div className="flex flex-row items-baseline gap-x-2">
{highlightedValue !== undefined && highlighted}
{label}
</div>
</div>
)
}
return (
<div className="h-16">
{title && chartTitle}
{highlightedValue !== undefined && highlighted}
{label}
</div>
)
}
export default ChartHeader