Skip to content

Commit f081a2c

Browse files
authored
docs: fix show hide event readability and make controls expanded as d… (#2081)
1 parent 9976fa0 commit f081a2c

File tree

3 files changed

+78
-18
lines changed

3 files changed

+78
-18
lines changed

packages/core/.storybook/preview.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ const fontLoader = async () => ({
4545
const preview: Preview = {
4646
parameters: {
4747
controls: {
48-
sort: "alpha"
48+
sort: "alpha",
49+
expanded: true
4950
},
5051
docs: {
5152
liveEdit: {
@@ -146,6 +147,7 @@ const preview: Preview = {
146147
}
147148
}
148149
},
150+
149151
loaders: isChromatic() && document.fonts ? [fontLoader] : []
150152
};
151153

packages/core/src/components/Dialog/__stories__/Dialog.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Canvas, Meta } from "@storybook/blocks";
1+
import { Meta } from "@storybook/blocks";
22
import { Link } from "vibe-storybook-components";
33
import { AttentionBox, AttentionBoxLink } from "../../../components";
44
import {

packages/core/src/components/Dialog/__stories__/Dialog.stories.js

Lines changed: 74 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
} from "../__tests__/DialogDataTestIds";
1212
import useSwitch from "../../../hooks/useSwitch";
1313
import "./Dialog.stories.scss";
14+
import { HideShowEvent } from "../../../constants/dialog";
1415

1516
const metaSettings = createStoryMetaSettingsDecorator({
1617
component: Dialog,
@@ -19,14 +20,30 @@ const metaSettings = createStoryMetaSettingsDecorator({
1920
actionPropsArray: [] // List the component's actions here
2021
});
2122

23+
const showHideArgTypes = {
24+
options: Object.values(HideShowEvent),
25+
control: {
26+
type: "multi-select"
27+
},
28+
table: {
29+
type: {
30+
summary: Object.values(HideShowEvent).join(" | ")
31+
}
32+
}
33+
};
34+
2235
export default {
2336
title: "Popover/Dialog",
2437
component: Dialog,
25-
argTypes: metaSettings.argTypes,
38+
argTypes: {
39+
...metaSettings.argTypes,
40+
hideTrigger: showHideArgTypes,
41+
showTrigger: showHideArgTypes
42+
},
2643
decorators: metaSettings.decorators
2744
};
2845

29-
const dialogTemplate = ({ shouldShowOnMount, position, ...dialogProps }) => {
46+
const dialogTemplate = ({ showTrigger, hideTrigger, shouldShowOnMount = true, position, ...dialogProps }) => {
3047
// for prevent dialog to move while scrolling
3148
const modifiers = [
3249
{
@@ -40,10 +57,10 @@ const dialogTemplate = ({ shouldShowOnMount, position, ...dialogProps }) => {
4057
<div className="monday-storybook-dialog--story-padding">
4158
<Dialog
4259
modifiers={modifiers}
43-
shouldShowOnMount={shouldShowOnMount || true}
60+
shouldShowOnMount={shouldShowOnMount}
4461
{...dialogProps}
45-
showTrigger={[Dialog.hideShowTriggers.CLICK]}
46-
hideTrigger={[Dialog.hideShowTriggers.CLICK]}
62+
showTrigger={showTrigger || [Dialog.hideShowTriggers.CLICK]}
63+
hideTrigger={hideTrigger || [Dialog.hideShowTriggers.CLICK]}
4764
position={position || Dialog.positions.RIGHT}
4865
content={
4966
<DialogContentContainer>
@@ -59,16 +76,12 @@ const dialogTemplate = ({ shouldShowOnMount, position, ...dialogProps }) => {
5976

6077
export const Overview = {
6178
render: dialogTemplate.bind({}),
62-
79+
name: "Overview",
6380
parameters: {
6481
docs: {
65-
source: {
66-
type: "code"
67-
}
82+
liveEdit: { isEnabled: false }
6883
}
69-
},
70-
71-
name: "Overview"
84+
}
7285
};
7386

7487
export const Positions = {
@@ -171,7 +184,14 @@ export const Positions = {
171184
);
172185
},
173186

174-
name: "Positions"
187+
name: "Positions",
188+
parameters: {
189+
docs: {
190+
liveEdit: {
191+
scope: { useSwitch, ExampleContent }
192+
}
193+
}
194+
}
175195
};
176196

177197
export const ShowTriggers = {
@@ -273,6 +293,11 @@ export const ShowTriggers = {
273293
parameters: {
274294
chromatic: {
275295
pauseAnimationAtEnd: true
296+
},
297+
docs: {
298+
liveEdit: {
299+
scope: { useSwitch, ExampleContent }
300+
}
276301
}
277302
}
278303
};
@@ -481,6 +506,18 @@ export const HideTriggers = {
481506
parameters: {
482507
chromatic: {
483508
pauseAnimationAtEnd: true
509+
},
510+
docs: {
511+
liveEdit: {
512+
scope: {
513+
useSwitch,
514+
ExampleContent,
515+
HIDE_TRIGGERS_CONTAINER,
516+
CLICK_OUTSIDE_DIALOG,
517+
CLICK_OUTSIDE_DIALOG_BUTTON,
518+
CONTEXT_MENU_DIALOG
519+
}
520+
}
484521
}
485522
}
486523
};
@@ -512,7 +549,14 @@ export const ControlledDialog = {
512549
);
513550
},
514551

515-
name: "Controlled Dialog"
552+
name: "Controlled Dialog",
553+
parameters: {
554+
docs: {
555+
liveEdit: {
556+
scope: { useSwitch }
557+
}
558+
}
559+
}
516560
};
517561

518562
export const DialogWithTooltip = {
@@ -548,7 +592,14 @@ export const DialogWithTooltip = {
548592
);
549593
},
550594

551-
name: "Dialog with tooltip"
595+
name: "Dialog with tooltip",
596+
parameters: {
597+
docs: {
598+
liveEdit: {
599+
scope: { ExampleContent, Info }
600+
}
601+
}
602+
}
552603
};
553604

554605
export const DisableScrollWhenDialogOpen = {
@@ -596,5 +647,12 @@ export const DisableScrollWhenDialogOpen = {
596647
);
597648
},
598649

599-
name: "Disable scroll when dialog open"
650+
name: "Disable scroll when dialog open",
651+
parameters: {
652+
docs: {
653+
liveEdit: {
654+
scope: { ExampleContent, useSwitch }
655+
}
656+
}
657+
}
600658
};

0 commit comments

Comments
 (0)