({ id, config }: { id: string; config: ChartConfig })
| 70 | } |
| 71 | |
| 72 | const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => { |
| 73 | const colorConfig = Object.entries(config).filter( |
| 74 | ([, config]) => config.theme || config.color |
| 75 | ) |
| 76 | |
| 77 | if (!colorConfig.length) { |
| 78 | return null |
| 79 | } |
| 80 | |
| 81 | return ( |
| 82 | <style |
| 83 | dangerouslySetInnerHTML={{ |
| 84 | __html: Object.entries(THEMES) |
| 85 | .map( |
| 86 | ([theme, prefix]) => ` |
| 87 | ${prefix} [data-chart=${id}] { |
| 88 | ${colorConfig |
| 89 | .map(([key, itemConfig]) => { |
| 90 | const color = |
| 91 | itemConfig.theme?.[theme as keyof typeof itemConfig.theme] || |
| 92 | itemConfig.color |
| 93 | return color ? ` --color-${key}: ${color};` : null |
| 94 | }) |
| 95 | .join("\n")} |
| 96 | } |
| 97 | ` |
| 98 | ) |
| 99 | .join("\n"), |
| 100 | }} |
| 101 | /> |
| 102 | ) |
| 103 | } |
| 104 | |
| 105 | const ChartTooltip = RechartsPrimitive.Tooltip |
| 106 |
nothing calls this directly
no outgoing calls
no test coverage detected