Skip to content

Commit 65c9076

Browse files
committed
ui-manchette: clean manchette's story
Signed-off-by: Clara Ni <[email protected]>
1 parent aada4b4 commit 65c9076

File tree

1 file changed

+1
-69
lines changed

1 file changed

+1
-69
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
import React, { useRef, useState } from 'react';
2-
31
import '@osrd-project/ui-core/dist/theme.css';
42
import '@osrd-project/ui-manchette/dist/theme.css';
5-
import { EyeClosed, Telescope } from '@osrd-project/ui-icons';
63
import type { Meta, StoryObj } from '@storybook/react';
74

85
import { SAMPLE_PATH_PROPERTIES_DATA } from './assets/sampleData';
9-
import Menu, { type MenuItem } from './components/Menu';
106
import Manchette from '../components/Manchette';
117
import { type StyledOperationalPointType } from '../types';
128

@@ -23,78 +19,14 @@ const meta: Meta<typeof Manchette> = {
2319
type: 'object',
2420
},
2521
},
26-
zoomYIn: {
27-
action: 'zoomYIn',
28-
},
29-
zoomYOut: {
30-
action: 'zoomYOut',
31-
},
3222
},
3323
};
3424

35-
const ManchetteWithWaypointMenu = () => {
36-
const [menuPosition, setMenuPosition] = useState<{ top: number; left: number } | null>(null);
37-
const [activeOperationalPointId, setActiveOperationalPointId] = useState<string>();
38-
39-
const menuRef = useRef<HTMLDivElement>(null);
40-
41-
const menuItems: MenuItem[] = [
42-
{
43-
title: 'Action 1',
44-
icon: <EyeClosed />,
45-
onClick: () => {
46-
setMenuPosition(null);
47-
setActiveOperationalPointId(undefined);
48-
},
49-
},
50-
{
51-
title: 'Action 2',
52-
icon: <Telescope />,
53-
onClick: () => {
54-
setMenuPosition(null);
55-
setActiveOperationalPointId(undefined);
56-
},
57-
},
58-
];
59-
60-
const handleWaypointClick = (id: string, ref: HTMLDivElement | null) => {
61-
if (!ref) return;
62-
const position = ref.getBoundingClientRect();
63-
setMenuPosition({ top: position.bottom - 2, left: position.left });
64-
setActiveOperationalPointId(id);
65-
};
66-
67-
return (
68-
<Manchette
69-
operationalPoints={OperationalPointListData.map((op) => ({
70-
...op,
71-
onClick: (id, ref) => {
72-
handleWaypointClick(id, ref);
73-
},
74-
}))}
75-
zoomYIn={() => {}}
76-
zoomYOut={() => {}}
77-
toggleMode={() => {}}
78-
activeOperationalPointId={activeOperationalPointId}
79-
>
80-
{menuPosition && (
81-
<Menu
82-
menuRef={menuRef}
83-
items={menuItems}
84-
style={{ width: '305px', top: menuPosition.top, left: menuPosition.left }}
85-
/>
86-
)}
87-
</Manchette>
88-
);
89-
};
90-
9125
export default meta;
92-
type Story = StoryObj<typeof ManchetteWithWaypointMenu>;
26+
type Story = StoryObj<typeof Manchette>;
9327

9428
export const Default: Story = {
9529
args: {
9630
operationalPoints: OperationalPointListData,
9731
},
9832
};
99-
100-
export const WaypointMenu = () => <ManchetteWithWaypointMenu />;

0 commit comments

Comments
 (0)