Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | 3x 35x 35x 280x 11x 2x | import { useState } from 'react';
import { type IESProfile } from '@ies-tools/core';
import { IntensityGraph } from './IntensityGraph.js';
import { IsoluxGraph } from './IsoluxGraph.js';
import { ConeDiagramGraph, IntensityTableGraph, LuminanceTableGraph } from './TableCharts.js';
export const VIEWER_TABS = [
['3d', '3D view'],
['polar', 'Polar'],
['cartesian', 'Cartesian'],
['topology', 'Topology'],
['isolux', 'Isolux'],
['cone', 'Cone'],
['luminance', 'Luminance'],
['intensity-table', 'Intensity table'],
] as const;
export type ViewerTab = (typeof VIEWER_TABS)[number][0];
/** Props for {@link ChartTabs}. */
export interface ChartTabsProps {
tab: ViewerTab;
onTabChange: (tab: ViewerTab) => void;
/** Loaded profile to chart; undefined while loading. */
profile?: IESProfile;
/** Isolux mounting height in meters. */
mountingHeight: number;
}
/** Tab bar over the 3D viewport; chart tabs cover the viewport with the selected chart. */
export function ChartTabs({ tab, onTabChange, profile, mountingHeight }: ChartTabsProps) {
const [logScale, setLogScale] = useState(false);
return (
<>
<div
role="tablist"
aria-label="Light views"
className="pointer-events-auto absolute inset-x-0 top-0 flex h-10 items-end gap-1 overflow-x-auto border-b border-border bg-card px-2"
>
{VIEWER_TABS.map(([value, label]) => (
<button
key={value}
type="button"
role="tab"
aria-selected={tab === value}
className={`cursor-pointer rounded-t-md border border-b-0 px-3 py-1.5 whitespace-nowrap outline-none focus-visible:ring-2 focus-visible:ring-ring ${
tab === value
? 'border-border bg-background text-foreground'
: 'border-transparent text-muted-foreground hover:text-foreground'
}`}
onClick={() => onTabChange(value)}
>
{label}
</button>
))}
</div>
{tab !== '3d' && (
<div
role="tabpanel"
className="pointer-events-auto absolute inset-x-0 top-10 bottom-0 grid place-items-center overflow-auto bg-background p-3 text-foreground"
>
{!profile ? (
<p className="text-muted-foreground">Loading photometry…</p>
) : profile.photometricType !== 1 ? (
<p role="alert">
Charts support Type C photometry only. Inspect or validate Type A/B files with ies inspect / ies validate
or the VS Code information panel.
</p>
) : tab === 'cone' ? (
<ConeDiagramGraph profile={profile} style={{ maxHeight: '100%' }} />
) : tab === 'luminance' ? (
<LuminanceTableGraph profile={profile} style={{ maxHeight: '100%' }} />
) : tab === 'intensity-table' ? (
// Wide grids keep readable cells; auto margins keep an overflowing table scrollable from its start.
<IntensityTableGraph profile={profile} style={{ width: 'auto', maxWidth: 'none', margin: 'auto' }} />
) : tab === 'isolux' ? (
<IsoluxGraph profile={profile} mountingHeight={mountingHeight} style={{ maxHeight: '100%' }} />
) : (
<>
<IntensityGraph
profile={profile}
projection={tab}
principalPlanes={tab !== 'topology'}
logScale={logScale}
style={{ maxHeight: '100%' }}
/>
{tab !== 'topology' && (
// Own themed surface: the chart is a fixed dark image (shared with CLI exports), not themed.
<label className="absolute top-3 right-3 flex items-center gap-2 rounded-md border border-border bg-card px-2 py-1 text-sm text-card-foreground shadow-sm">
<input
name="logScale"
type="checkbox"
checked={logScale}
className="size-4 accent-primary focus-visible:ring-2 focus-visible:ring-ring"
onChange={(event) => setLogScale(event.currentTarget.checked)}
/>
Log scale
</label>
)}
</>
)}
</div>
)}
</>
);
}
|