import type { Meta, StoryObj } from '@storybook/react'; import React from 'react'; import { MapLayerPanel } from './map-layer-panel'; import type { MapDataLayer } from '../map/map-layers-model'; const INITIAL: MapDataLayer[] = [ { id: 'alvo-a', label: 'Alvo A', group: 'Alvos', colorToken: '--chart-1', visible: true, zIndex: 40, }, { id: 'alvo-b', label: 'Alvo B', group: 'Alvos', colorToken: '--chart-3', visible: true, zIndex: 40, }, { id: 'setores', label: 'Setores de cobertura', group: 'Território', colorToken: '--chart-2', visible: true, zIndex: 20, }, { id: 'densidade', label: 'Densidade de ocorrências', group: 'Território', colorToken: '--destructive', visible: false, zIndex: 10, }, ]; const meta: Meta = { title: 'UI/MapLayerPanel', component: MapLayerPanel, parameters: { layout: 'centered' }, argTypes: { variant: { control: 'inline-radio', options: ['inline', 'overlay'] } }, }; export default meta; type Story = StoryObj; function ControlledPanel(args: React.ComponentProps) { const [layers, setLayers] = React.useState(INITIAL); const handleToggle = (id: string, visible: boolean) => setLayers(current => current.map(l => (l.id === id ? { ...l, visible } : l))); return ; } /** Grouped layers, each with a swatch and a switch. */ export const Default: Story = { args: { title: 'Camadas', layers: INITIAL, onToggle: () => {} }, render: args => (
), }; /** Floating over a map, inside a `relative` container. */ export const Overlay: Story = { args: { title: 'Camadas', variant: 'overlay', position: 'top-right', layers: INITIAL, onToggle: () => {}, }, render: args => (
), }; /** Without groups, the panel is a flat list. */ export const Ungrouped: Story = { args: { layers: INITIAL.map(({ group: _group, ...rest }) => rest), onToggle: () => {}, }, render: args => (
), };