import React from "react"
import { classNames } from "../../utils/classNames"
import { Flex } from "../Flex"
import { FlexColumn } from "../FlexColumn"
import { Skeleton } from "../Skeleton"
import { Text } from "../Text"
type ChartSkeletonBaseProps = {
className?: string
children?: React.ReactNode
}
export type ChartSkeletonProps = ChartSkeletonBaseProps & {
xAxisLabels?: BaselineProps["labels"]
yAxisLabels?: OrdinateProps["labels"]
contentClassName?: string
skeletonClassName?: string
}
function ChartSkeletonBase({ className, children }: ChartSkeletonBaseProps) {
return (
)
}
type ChartSkeletonLayoutProps = ChartSkeletonProps & {
content: React.ReactNode
}
function ChartSkeletonLayout({
xAxisLabels,
yAxisLabels,
className,
contentClassName,
skeletonClassName,
content,
children,
}: ChartSkeletonLayoutProps) {
const hasYAxisLabels = (yAxisLabels?.length || 0) > 0
const hasXAxisLabels = (xAxisLabels?.length || 0) > 0
return (
{hasXAxisLabels && (
)}
{hasYAxisLabels && (
)}
{content}
{children}
)
}
type ContentProps = {
children: React.ReactNode
className?: string
}
function Content({ children, className }: ContentProps) {
return (
{children}
)
}
type OrdinateProps = {
labels: React.ReactNode[] | string[]
className?: string
skeletonClassName?: string
}
function Ordinate({ labels, className, skeletonClassName }: OrdinateProps) {
return (
{labels.map((label, index) => (
{typeof label === "string" ? (
{label}
) : (
label
)}
))}
)
}
type BaselineProps = {
labels: React.ReactNode[] | string[]
className?: string
skeletonClassName?: string
}
function Baseline({ labels, className, skeletonClassName }: BaselineProps) {
return (
{labels.map((label, index) => (
{typeof label === "string" ? (
{label}
) : (
label
)}
))}
)
}
export const ChartSkeleton = Object.assign(ChartSkeletonLayout, {
Base: ChartSkeletonBase,
Content,
Ordinate,
Baseline,
})