-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathSpeedSpaceChart.stories.tsx
79 lines (68 loc) · 2.03 KB
/
SpeedSpaceChart.stories.tsx
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
import React, { useEffect, useState } from 'react';
import type { Meta, StoryObj } from '@storybook/react';
import '@osrd-project/ui-core/dist/theme.css';
import '@osrd-project/ui-speedspacechart/dist/theme.css';
import { translations as defaultTranslation } from './assets/const';
import { pathPropertiesPmpLm } from './assets/path_properties_PMP_LM';
import { powerRestrictionsPmpLm } from './assets/power_restrictions_PMP_LM';
import { simulationPmpLm } from './assets/simulation_PMP_LM';
import { speedLimitTags } from './assets/speed_limit_tags_PMP_LM';
import { formatData } from './utils';
import SpeedSpaceChart, { type SpeedSpaceChartProps } from '../components/SpeedSpaceChart';
const defaultData = formatData(
simulationPmpLm,
pathPropertiesPmpLm,
powerRestrictionsPmpLm,
speedLimitTags
);
const SpeedSpaceChartStory = ({
height,
width,
backgroundColor,
data,
translations,
}: SpeedSpaceChartProps) => {
const [containerHeight, setContainerHeight] = useState(521.5);
useEffect(() => {
setContainerHeight(height);
}, [height]);
return (
<div style={{ height: containerHeight }}>
<SpeedSpaceChart
width={width}
height={height}
backgroundColor={backgroundColor}
data={data}
setHeight={setContainerHeight}
translations={translations}
/>
</div>
);
};
const meta: Meta<typeof SpeedSpaceChart> = {
title: 'SpeedSpaceChart/Rendering',
component: SpeedSpaceChart,
decorators: [(Story) => <Story />],
args: {
width: 1440,
height: 521.5,
backgroundColor: 'rgb(247, 246, 238)',
data: defaultData,
setHeight: () => {},
translations: defaultTranslation,
},
render: (args) => <SpeedSpaceChartStory {...args} />,
tags: ['autodocs'],
};
export default meta;
type Story = StoryObj<typeof SpeedSpaceChart>;
export const SpeedSpaceChartDefault: Story = {
args: {
width: 1440,
height: 521.5,
backgroundColor: 'rgb(247, 246, 238)',
data: defaultData,
setHeight: () => {},
translations: defaultTranslation,
},
};