Skip to content

Commit 5a3f32e

Browse files
committed
feat(): update
1 parent b89d714 commit 5a3f32e

File tree

2 files changed

+132
-7
lines changed

2 files changed

+132
-7
lines changed

packages/plasma-new-hope/src/examples/components/_beta/Popover/Popover.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { ComponentProps, useState } from 'react';
2+
import type { ComponentProps } from 'react';
33
import type { StoryObj, Meta } from '@storybook/react-vite';
44

55
import { Cell, CellTextbox, CellTextboxTitle, CellTextboxSubtitle } from '../../Cell/Cell';

packages/sdds-finai/src/components/_beta/Popover/Popover.stories.tsx

Lines changed: 131 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Popover } from './Popover';
1010

1111
type StoryProps = ComponentProps<typeof Popover>;
1212

13+
const appearance = ['closeNone', 'closeInner'];
1314
const placements = [
1415
'top',
1516
'top-start',
@@ -32,6 +33,12 @@ const meta: Meta<StoryProps> = {
3233
title: '_Beta/Popover',
3334
component: Popover,
3435
argTypes: {
36+
appearance: {
37+
options: appearance,
38+
control: {
39+
type: 'select',
40+
},
41+
},
3542
placement: {
3643
options: placements,
3744
control: {
@@ -84,11 +91,6 @@ const meta: Meta<StoryProps> = {
8491
type: 'number',
8592
},
8693
},
87-
resizable: {
88-
control: {
89-
type: 'boolean',
90-
},
91-
},
9294
view: {
9395
options: view,
9496
control: {
@@ -103,6 +105,7 @@ const meta: Meta<StoryProps> = {
103105
},
104106
},
105107
args: {
108+
appearance: 'closeNone',
106109
placement: 'bottom',
107110
trigger: 'click',
108111
defaultOpened: false,
@@ -113,7 +116,6 @@ const meta: Meta<StoryProps> = {
113116
outsideClick: true,
114117
delayOpen: 0,
115118
delayClose: 0,
116-
resizable: false,
117119
view: 'default',
118120
size: 'm',
119121
},
@@ -158,3 +160,126 @@ const StoryDefault = (args: StoryProps) => {
158160
export const Default: StoryObj<StoryProps> = {
159161
render: (args) => <StoryDefault {...args} />,
160162
};
163+
164+
const StoryResizable = (args: StoryProps) => {
165+
const {
166+
resizableDirections,
167+
resizableHiddenIcons,
168+
resizableDefaultSize,
169+
resizableMinWidth,
170+
resizableMinHeight,
171+
resizableMaxWidth,
172+
resizableMaxHeight,
173+
resizableIconSize,
174+
} = args;
175+
176+
React.useEffect(() => {
177+
window.scrollTo(
178+
(document.documentElement.scrollWidth - window.innerWidth) / 2,
179+
(document.documentElement.scrollHeight - window.innerHeight) / 2,
180+
);
181+
}, []);
182+
183+
const cells = [
184+
{ num: 1, color: '#e74c3c' },
185+
{ num: 2, color: '#3498db' },
186+
{ num: 3, color: '#f1c40f' },
187+
{ num: 4, color: '#27ae60' },
188+
];
189+
190+
return (
191+
<div
192+
style={{
193+
display: 'flex',
194+
alignItems: 'center',
195+
justifyContent: 'center',
196+
width: '400vw',
197+
height: '400vh',
198+
}}
199+
>
200+
<Popover
201+
target={<Button>Target</Button>}
202+
resizable={{
203+
directions: resizableDirections,
204+
hiddenIcons: resizableHiddenIcons,
205+
defaultSize: resizableDefaultSize,
206+
minWidth: resizableMinWidth,
207+
minHeight: resizableMinHeight,
208+
maxWidth: resizableMaxWidth,
209+
maxHeight: resizableMaxHeight,
210+
iconSize: resizableIconSize,
211+
}}
212+
{...args}
213+
>
214+
<div
215+
style={{
216+
width: '100%',
217+
height: '100%',
218+
display: 'grid',
219+
gridTemplateColumns: '1fr 1fr',
220+
gridTemplateRows: '1fr 1fr',
221+
}}
222+
>
223+
{cells.map(({ num, color }) => (
224+
<div
225+
key={num}
226+
style={{
227+
background: color,
228+
color: 'white',
229+
fontSize: '4vw',
230+
display: 'flex',
231+
justifyContent: 'center',
232+
alignItems: 'center',
233+
}}
234+
>
235+
{num}
236+
</div>
237+
))}
238+
</div>
239+
</Popover>
240+
</div>
241+
);
242+
};
243+
244+
export const Resizable: StoryObj<StoryProps> = {
245+
argTypes: {
246+
resizableDirections: {
247+
control: 'check',
248+
options: ['top', 'top-right', 'right', 'bottom-right', 'bottom', 'bottom-left', 'left', 'top-left'],
249+
},
250+
resizableDefaultSize: {
251+
control: 'object',
252+
},
253+
resizableHiddenIcons: {
254+
control: 'check',
255+
options: ['top-right', 'bottom-right', 'bottom-left', 'top-left'],
256+
},
257+
resizableMinWidth: {
258+
control: 'number',
259+
},
260+
resizableMinHeight: {
261+
control: 'number',
262+
},
263+
resizableMaxWidth: {
264+
control: 'number',
265+
},
266+
resizableMaxHeight: {
267+
control: 'number',
268+
},
269+
resizableIconSize: {
270+
control: {
271+
type: 'select',
272+
},
273+
options: ['xs', 's', 'm'],
274+
},
275+
},
276+
args: {
277+
resizableDirections: ['bottom-right'],
278+
resizableHiddenIcons: [],
279+
resizableIconSize: 's',
280+
resizableDefaultSize: { width: 300, height: 300 },
281+
resizableMinWidth: 300,
282+
resizableMinHeight: 300,
283+
},
284+
render: (args) => <StoryResizable {...args} />,
285+
};

0 commit comments

Comments
 (0)