Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fix show hide event readability and make controls expanded as d… #2081

Merged
merged 4 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/core/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ const fontLoader = async () => ({
const preview: Preview = {
parameters: {
controls: {
sort: "alpha"
sort: "alpha",
expanded: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

},
docs: {
liveEdit: {
Expand Down Expand Up @@ -146,6 +147,7 @@ const preview: Preview = {
}
}
},

loaders: isChromatic() && document.fonts ? [fontLoader] : []
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Canvas, Meta } from "@storybook/blocks";
import { Meta } from "@storybook/blocks";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💪🏼

import { Link } from "vibe-storybook-components";
import { AttentionBox, AttentionBoxLink } from "../../../components";
import {
Expand Down
37 changes: 25 additions & 12 deletions packages/core/src/components/Dialog/__stories__/Dialog.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from "../__tests__/DialogDataTestIds";
import useSwitch from "../../../hooks/useSwitch";
import "./Dialog.stories.scss";
import { HideShowEvent } from "../../../constants/dialog";

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

const showHideArgTypes = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW have you tried using the enumPropNamesArray?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it is not doing anything that helps with the readability :(

options: Object.values(HideShowEvent),
control: {
type: "multi-select"
},
table: {
type: {
summary: Object.values(HideShowEvent).join(" | ")
}
}
};
Comment on lines +24 to +33
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

definitely should be (in a future enhancement, maybe create a task?) a common util, or as part of the createMeta

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll create a task for it in the backlog


export default {
title: "Popover/Dialog",
component: Dialog,
argTypes: metaSettings.argTypes,
argTypes: {
...metaSettings.argTypes,
hideTrigger: showHideArgTypes,
showTrigger: showHideArgTypes
},
decorators: metaSettings.decorators
};

const dialogTemplate = ({ shouldShowOnMount, position, ...dialogProps }) => {
const dialogTemplate = ({ showTrigger, hideTrigger, shouldShowOnMount = true, position, ...dialogProps }) => {
// for prevent dialog to move while scrolling
const modifiers = [
{
Expand All @@ -40,10 +57,10 @@ const dialogTemplate = ({ shouldShowOnMount, position, ...dialogProps }) => {
<div className="monday-storybook-dialog--story-padding">
<Dialog
modifiers={modifiers}
shouldShowOnMount={shouldShowOnMount || true}
shouldShowOnMount={shouldShowOnMount}
{...dialogProps}
showTrigger={[Dialog.hideShowTriggers.CLICK]}
hideTrigger={[Dialog.hideShowTriggers.CLICK]}
showTrigger={showTrigger || [Dialog.hideShowTriggers.CLICK]}
hideTrigger={hideTrigger || [Dialog.hideShowTriggers.CLICK]}
Comment on lines +62 to +63
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can give these two also a default in the signature

position={position || Dialog.positions.RIGHT}
content={
<DialogContentContainer>
Expand All @@ -59,16 +76,12 @@ const dialogTemplate = ({ shouldShowOnMount, position, ...dialogProps }) => {

export const Overview = {
render: dialogTemplate.bind({}),

name: "Overview",
parameters: {
docs: {
source: {
type: "code"
}
liveEdit: { isEnabled: false }
}
},

name: "Overview"
}
};

export const Positions = {
Expand Down