import { useState } from 'react' import { HISTORICAL_PERIODS } from '@/entities/TimePeriod' import { ACTIVE_POSITION_DEGREES, FULL_CIRCLE_DEGREES, } from '@/widgets/TimeFrameSlider/model' import { CircleTimeline } from './CircleTimeline' import type { Meta, StoryObj } from '@storybook/react' const meta = { title: 'Widgets/CircleTimeline', component: CircleTimeline, parameters: { layout: 'centered', }, tags: ['autodocs'], } satisfies Meta export default meta type Story = StoryObj type CustomStory = Partial & Pick /** * Интерактивный компонент-обертка для управления состоянием */ function CircleTimelineWithState() { const [activeIndex, setActiveIndex] = useState(0) // Расчет угла поворота на основе активного индекса // Каждый период занимает 360/6 = 60 градусов // Активная позиция находится на -60 градусах (верхний правый угол) const rotation = ACTIVE_POSITION_DEGREES - (FULL_CIRCLE_DEGREES / HISTORICAL_PERIODS.length) * activeIndex return (
) } /** * Интерактивный вариант со всеми 6 периодами */ export const Default: CustomStory = { render: () => , parameters: { docs: { description: { story: 'Интерактивная демонстрация с возможностью переключения между периодами', }, }, }, } /** * Первый период (Science) активен */ export const FirstPeriod: Story = { args: { periods: HISTORICAL_PERIODS, activeIndex: 0, onPeriodChange: () => {}, rotation: ACTIVE_POSITION_DEGREES, }, decorators: [ (Story) => (
), ], } /** * Третий период (Tech) активен */ export const ThirdPeriod: Story = { args: { periods: HISTORICAL_PERIODS, activeIndex: 2, onPeriodChange: () => {}, rotation: ACTIVE_POSITION_DEGREES - (FULL_CIRCLE_DEGREES / 6) * 2, }, decorators: [ (Story) => (
), ], } /** * Вариант с 3 периодами для демонстрации гибкости */ export const FewPeriods: Story = { args: { periods: HISTORICAL_PERIODS.slice(0, 3), activeIndex: 0, onPeriodChange: () => {}, rotation: -60, }, decorators: [ (Story) => (
), ], }