Files
supabase/apps/studio/components/ui/Charts/NoDataPlaceholder.tsx
038249088a feat: update realtime report (#40252)
* feat: update realtime report

Co-authored-by: Jordi Enric <jordi.err@gmail.com>

* fix: misc bug fixes

* fixup! fix: misc bug fixes

---------

Co-authored-by: Jordi Enric <jordi.err@gmail.com>
Co-authored-by: Charis Lam <26616127+charislam@users.noreply.github.com>
Co-authored-by: Ali Waseem <waseema393@gmail.com>
2025-11-12 10:33:27 -05:00

61 lines
1.7 KiB
TypeScript

import { BarChart2 } from 'lucide-react'
import { cn } from 'ui'
import { ChartHeader } from './ChartHeader'
import { useChartSize } from './Charts.utils'
interface NoDataPlaceholderProps {
title?: string
attribute?: string
format?: string | ((value: unknown) => string)
message?: string
description?: string
className?: string
size: Parameters<typeof useChartSize>[0]
isFullHeight?: boolean
titleTooltip?: string
hideTotalPlaceholder?: boolean
}
const NoDataPlaceholder = ({
attribute,
message = 'No data to show',
description,
format,
className = '',
size,
isFullHeight = false,
titleTooltip,
hideTotalPlaceholder = false,
}: NoDataPlaceholderProps) => {
const { minHeight } = useChartSize(size)
return (
<div className={cn(isFullHeight && 'h-full')}>
{attribute !== undefined && (
<ChartHeader
title={attribute}
format={format}
highlightedValue={hideTotalPlaceholder ? undefined : 0}
titleTooltip={titleTooltip}
/>
)}
<div
className={cn(
'border-control flex flex-grow w-full flex-col items-center justify-center space-y-2 border border-dashed text-center',
isFullHeight && 'h-full',
className
)}
// extra 20 px for the x ticks
style={{ minHeight: minHeight + 20 }}
>
<BarChart2 size={20} className="text-border-stronger" />
<div className="px-1">
<p className="text-foreground-light text-xs">{message}</p>
{description && <p className="text-foreground-lighter text-xs">{description}</p>}
</div>
</div>
</div>
)
}
export default NoDataPlaceholder