import { createElement, type SVGProps } from "react"; import { Box } from "../../../../ui"; import { useThemeColors } from "../../../../theme/theme-context"; import { zoneScaleGeometry, type ZoneScaleProps } from "./model"; const VIEWBOX_WIDTH = 1000; const VIEWBOX_HEIGHT = 78; const BAR_TOP = 26; const BAR_HEIGHT = 14; const BAR_RADIUS = 7; const GAP = 3; const TICK_LABEL_INSET = 34; function SvgText(props: SVGProps) { return createElement("text", props); } export function DesktopZoneColorScale({ indicator, value, width, markerColor }: ZoneScaleProps) { const colors = useThemeColors(); const geometry = zoneScaleGeometry(indicator, value, Math.max(48, width)); const markerX = geometry.markerFraction * VIEWBOX_WIDTH; const barMiddle = BAR_TOP + BAR_HEIGHT / 2; return ( {geometry.bands.map((band, index) => { const x = band.startFraction * VIEWBOX_WIDTH; const barWidth = (band.endFraction - band.startFraction) * VIEWBOX_WIDTH - GAP; const active = value >= band.from && value < band.to; const first = index === 0; const last = index === geometry.bands.length - 1; return ( ); })} {geometry.ticks.map((tick) => { const x = tick.fraction * VIEWBOX_WIDTH; return ( {tick.label} ); })} {geometry.leftLabel ? ( {geometry.leftLabel} ) : null} {geometry.fairLabel ? ( {geometry.fairLabel} ) : null} {geometry.rightLabel ? ( {geometry.rightLabel} ) : null} ); }