From 7d8229ab38534972e5871a74618d4ae9afab02bc Mon Sep 17 00:00:00 2001 From: imagoiq <12294151+imagoiq@users.noreply.github.com> Date: Mon, 13 Nov 2023 12:45:02 +0100 Subject: [PATCH] chore(documentation): move codeOrSourceMdx and bombArgs to utils folder --- .../alert/alert.snapshot.stories.ts | 6 +++--- .../badge/badge.snapshot.stories.ts | 2 +- .../blockquote/blockquote.snapshot.stories.ts | 2 +- .../button-group.snapshot.stories.ts | 2 +- .../button/button.snapshot.stories.ts | 2 +- .../components/card/card.snapshot.stories.ts | 2 +- .../checkbox/checkbox.snapshot.stories.ts | 2 +- .../choice-card.snapshot.stories.ts | 2 +- .../collapsible.snapshot.stories.ts | 2 +- .../heading/heading.snapshot.stories.ts | 2 +- .../radio/radio.snapshot.stories.ts | 2 +- .../range/range.snapshot.stories.ts | 2 +- .../switch/switch.snapshot.stories.ts | 2 +- .../table/table.snapshot.stories.ts | 2 +- .../components/tabs/tabs.snapshot.stories.ts | 2 +- .../toast/toast.snapshot.stories.ts | 2 +- .../topic-teaser.snapshot.stories.ts | 4 ++-- .../stories/misc/changelog/changelog.docs.mdx | 2 +- .../src/stories/utilities/bombArgs.ts | 19 ------------------- .../src/utils/{bombArgs.ts => bomb-args.ts} | 0 .../codeOrSourceMdx.tsx} | 2 +- packages/documentation/src/utils/index.ts | 1 + 22 files changed, 23 insertions(+), 41 deletions(-) delete mode 100644 packages/documentation/src/stories/utilities/bombArgs.ts rename packages/documentation/src/utils/{bombArgs.ts => bomb-args.ts} (100%) rename packages/documentation/src/{stories/utilities/markdown/CodeOrSourceMdx.tsx => utils/codeOrSourceMdx.tsx} (92%) diff --git a/packages/documentation/src/stories/components/alert/alert.snapshot.stories.ts b/packages/documentation/src/stories/components/alert/alert.snapshot.stories.ts index 1bd0ee6116..8cf72487f4 100644 --- a/packages/documentation/src/stories/components/alert/alert.snapshot.stories.ts +++ b/packages/documentation/src/stories/components/alert/alert.snapshot.stories.ts @@ -1,7 +1,7 @@ import { Args, StoryObj } from '@storybook/web-components'; import { html } from 'lit'; import { spreadArgs } from '../../../utils'; -import { bombArgs } from '../../utilities/bombArgs'; +import { bombArgs } from '../../../utils'; import alertMeta from './standard-html/alert.stories'; import { getAlertClasses } from './standard-html/getAlertClasses'; @@ -17,7 +17,7 @@ export const Alert: Story = {
${['bg-white', 'bg-dark'].map( bg => html` -
+
${bombArgs({ type: alertMeta?.argTypes?.type?.options, icon: ['no-icon', undefined, '1001'], @@ -116,7 +116,7 @@ export const PostAlert: Story = { args => html` `, )} diff --git a/packages/documentation/src/stories/components/badge/badge.snapshot.stories.ts b/packages/documentation/src/stories/components/badge/badge.snapshot.stories.ts index 437ca204b2..cd4b4b125a 100644 --- a/packages/documentation/src/stories/components/badge/badge.snapshot.stories.ts +++ b/packages/documentation/src/stories/components/badge/badge.snapshot.stories.ts @@ -1,7 +1,7 @@ import type { Args, StoryContext, StoryObj } from '@storybook/web-components'; import meta from './badge.stories'; import { html } from 'lit'; -import { bombArgs } from '../../../utils/bombArgs'; +import { bombArgs } from '../../../utils'; export default { ...meta, diff --git a/packages/documentation/src/stories/components/blockquote/blockquote.snapshot.stories.ts b/packages/documentation/src/stories/components/blockquote/blockquote.snapshot.stories.ts index d100929d1b..80c97938ba 100644 --- a/packages/documentation/src/stories/components/blockquote/blockquote.snapshot.stories.ts +++ b/packages/documentation/src/stories/components/blockquote/blockquote.snapshot.stories.ts @@ -1,7 +1,7 @@ import type { Args, StoryContext, StoryObj } from '@storybook/web-components'; import meta from './blockquote.stories'; import { html } from 'lit'; -import { bombArgs } from '../../../utils/bombArgs'; +import { bombArgs } from '../../../utils'; export default { ...meta, diff --git a/packages/documentation/src/stories/components/button-group/button-group.snapshot.stories.ts b/packages/documentation/src/stories/components/button-group/button-group.snapshot.stories.ts index 25e06891b7..d73f6d06f2 100644 --- a/packages/documentation/src/stories/components/button-group/button-group.snapshot.stories.ts +++ b/packages/documentation/src/stories/components/button-group/button-group.snapshot.stories.ts @@ -1,7 +1,7 @@ import type { Args, StoryContext, StoryObj } from '@storybook/web-components'; import meta from './button-group.stories'; import { html } from 'lit'; -import { bombArgs } from '../../../utils/bombArgs'; +import { bombArgs } from '../../../utils'; export default { ...meta, diff --git a/packages/documentation/src/stories/components/button/button.snapshot.stories.ts b/packages/documentation/src/stories/components/button/button.snapshot.stories.ts index 22f6ab2c14..f96d1210d9 100644 --- a/packages/documentation/src/stories/components/button/button.snapshot.stories.ts +++ b/packages/documentation/src/stories/components/button/button.snapshot.stories.ts @@ -1,7 +1,7 @@ import type { Args, StoryContext, StoryObj } from '@storybook/web-components'; import meta, { Default, AccentColors, ContextualColors } from './button.stories'; import { html } from 'lit'; -import { bombArgs } from '../../../utils/bombArgs'; +import { bombArgs } from '../../../utils'; export default { ...meta, diff --git a/packages/documentation/src/stories/components/card/card.snapshot.stories.ts b/packages/documentation/src/stories/components/card/card.snapshot.stories.ts index 9f9a7e164f..d9a8d3ac7f 100644 --- a/packages/documentation/src/stories/components/card/card.snapshot.stories.ts +++ b/packages/documentation/src/stories/components/card/card.snapshot.stories.ts @@ -1,7 +1,7 @@ import type { Args, StoryContext, StoryObj } from '@storybook/web-components'; import meta, { Default, CustomContent, CardGroup } from './card.stories'; import { html } from 'lit'; -import { bombArgs } from '../../../utils/bombArgs'; +import { bombArgs } from '../../../utils'; export default { ...meta, diff --git a/packages/documentation/src/stories/components/checkbox/checkbox.snapshot.stories.ts b/packages/documentation/src/stories/components/checkbox/checkbox.snapshot.stories.ts index eed7c3ad40..4c12131207 100644 --- a/packages/documentation/src/stories/components/checkbox/checkbox.snapshot.stories.ts +++ b/packages/documentation/src/stories/components/checkbox/checkbox.snapshot.stories.ts @@ -1,7 +1,7 @@ import type { Args, StoryContext, StoryObj } from '@storybook/web-components'; import meta, { Inline } from './checkbox.stories'; import { html } from 'lit'; -import { bombArgs } from '../../../utils/bombArgs'; +import { bombArgs } from '../../../utils'; export default { ...meta, diff --git a/packages/documentation/src/stories/components/choice-card/choice-card.snapshot.stories.ts b/packages/documentation/src/stories/components/choice-card/choice-card.snapshot.stories.ts index 765e95c7ae..9e612df209 100644 --- a/packages/documentation/src/stories/components/choice-card/choice-card.snapshot.stories.ts +++ b/packages/documentation/src/stories/components/choice-card/choice-card.snapshot.stories.ts @@ -1,4 +1,4 @@ -import { bombArgs } from '../../../utils/bombArgs'; +import { bombArgs } from '../../../utils'; import { choiceCardMeta, choiceCardDefault } from './choice-card'; import { StoryObj } from '@storybook/web-components'; import { html } from 'lit'; diff --git a/packages/documentation/src/stories/components/collapsible/collapsible.snapshot.stories.ts b/packages/documentation/src/stories/components/collapsible/collapsible.snapshot.stories.ts index 0a912aec93..0828293c83 100644 --- a/packages/documentation/src/stories/components/collapsible/collapsible.snapshot.stories.ts +++ b/packages/documentation/src/stories/components/collapsible/collapsible.snapshot.stories.ts @@ -1,6 +1,6 @@ import { html } from 'lit'; import type { Args, StoryContext, StoryObj } from '@storybook/web-components'; -import { bombArgs } from '../../../utils/bombArgs'; +import { bombArgs } from '../../../utils'; import meta, { Default } from './collapsible.stories'; diff --git a/packages/documentation/src/stories/components/heading/heading.snapshot.stories.ts b/packages/documentation/src/stories/components/heading/heading.snapshot.stories.ts index 556a454421..b2263ffc48 100644 --- a/packages/documentation/src/stories/components/heading/heading.snapshot.stories.ts +++ b/packages/documentation/src/stories/components/heading/heading.snapshot.stories.ts @@ -1,7 +1,7 @@ import type { Args, StoryContext, StoryObj } from '@storybook/web-components'; import meta, { Default } from './heading.stories'; import { html } from 'lit'; -import { bombArgs } from '../../../utils/bombArgs'; +import { bombArgs } from '../../../utils'; export default { ...meta, diff --git a/packages/documentation/src/stories/components/radio/radio.snapshot.stories.ts b/packages/documentation/src/stories/components/radio/radio.snapshot.stories.ts index 7a9a13a3ea..a3ccd2613e 100644 --- a/packages/documentation/src/stories/components/radio/radio.snapshot.stories.ts +++ b/packages/documentation/src/stories/components/radio/radio.snapshot.stories.ts @@ -1,7 +1,7 @@ import type { Args, StoryContext, StoryObj } from '@storybook/web-components'; import meta, { renderInline } from './radio.stories'; import { html } from 'lit'; -import { bombArgs } from '../../../utils/bombArgs'; +import { bombArgs } from '../../../utils'; export default { ...meta, diff --git a/packages/documentation/src/stories/components/range/range.snapshot.stories.ts b/packages/documentation/src/stories/components/range/range.snapshot.stories.ts index 0714df690d..e56f1cc249 100644 --- a/packages/documentation/src/stories/components/range/range.snapshot.stories.ts +++ b/packages/documentation/src/stories/components/range/range.snapshot.stories.ts @@ -1,7 +1,7 @@ import type { Args, StoryContext, StoryObj } from '@storybook/web-components'; import meta from './range.stories'; import { html } from 'lit'; -import { bombArgs } from '../../../utils/bombArgs'; +import { bombArgs } from '../../../utils'; export default { ...meta, diff --git a/packages/documentation/src/stories/components/switch/switch.snapshot.stories.ts b/packages/documentation/src/stories/components/switch/switch.snapshot.stories.ts index f53ed1f4be..06b6906bde 100644 --- a/packages/documentation/src/stories/components/switch/switch.snapshot.stories.ts +++ b/packages/documentation/src/stories/components/switch/switch.snapshot.stories.ts @@ -1,7 +1,7 @@ import type { Args, StoryContext, StoryObj } from '@storybook/web-components'; import meta from './switch.stories'; import { html } from 'lit'; -import { bombArgs } from '../../../utils/bombArgs'; +import { bombArgs } from '../../../utils'; export default { ...meta, diff --git a/packages/documentation/src/stories/components/table/table.snapshot.stories.ts b/packages/documentation/src/stories/components/table/table.snapshot.stories.ts index d570dd587f..ac9c29432d 100644 --- a/packages/documentation/src/stories/components/table/table.snapshot.stories.ts +++ b/packages/documentation/src/stories/components/table/table.snapshot.stories.ts @@ -1,7 +1,7 @@ import type { Args, StoryContext, StoryObj } from '@storybook/web-components'; import meta from './table.stories'; import { html } from 'lit'; -import { bombArgs } from '../../../utils/bombArgs'; +import { bombArgs } from '../../../utils'; export default { ...meta, diff --git a/packages/documentation/src/stories/components/tabs/tabs.snapshot.stories.ts b/packages/documentation/src/stories/components/tabs/tabs.snapshot.stories.ts index 3f5c509e74..7ddf9123ad 100644 --- a/packages/documentation/src/stories/components/tabs/tabs.snapshot.stories.ts +++ b/packages/documentation/src/stories/components/tabs/tabs.snapshot.stories.ts @@ -1,7 +1,7 @@ import type { Args, StoryContext, StoryObj } from '@storybook/web-components'; import meta from './tabs.stories'; import { html } from 'lit'; -import { bombArgs } from '../../../utils/bombArgs'; +import { bombArgs } from '../../../utils'; export default { ...meta, diff --git a/packages/documentation/src/stories/components/toast/toast.snapshot.stories.ts b/packages/documentation/src/stories/components/toast/toast.snapshot.stories.ts index cee21adbb9..2b727d9a1b 100644 --- a/packages/documentation/src/stories/components/toast/toast.snapshot.stories.ts +++ b/packages/documentation/src/stories/components/toast/toast.snapshot.stories.ts @@ -1,7 +1,7 @@ import type { Args, StoryContext, StoryObj } from '@storybook/web-components'; import meta from './toast.stories'; import { html } from 'lit'; -import { bombArgs } from '../../../utils/bombArgs'; +import { bombArgs } from '../../../utils'; export default { ...meta, diff --git a/packages/documentation/src/stories/components/topic-teaser/topic-teaser.snapshot.stories.ts b/packages/documentation/src/stories/components/topic-teaser/topic-teaser.snapshot.stories.ts index c3399dd853..732fe2586c 100644 --- a/packages/documentation/src/stories/components/topic-teaser/topic-teaser.snapshot.stories.ts +++ b/packages/documentation/src/stories/components/topic-teaser/topic-teaser.snapshot.stories.ts @@ -1,7 +1,7 @@ import type { Args, StoryContext, StoryObj } from '@storybook/web-components'; import meta, { Default } from './topic-teaser.stories'; import { html } from 'lit'; -import { bombArgs } from '../../../utils/bombArgs'; +import { bombArgs } from '../../../utils'; export default { ...meta, @@ -18,7 +18,7 @@ export const TopicTeaser: Story = {
${['white', 'dark'].map( bg => html` -
+
${bombArgs({ subtitle: [short, long], title: [short, long], diff --git a/packages/documentation/src/stories/misc/changelog/changelog.docs.mdx b/packages/documentation/src/stories/misc/changelog/changelog.docs.mdx index 135fe55d39..c81be8e5e9 100644 --- a/packages/documentation/src/stories/misc/changelog/changelog.docs.mdx +++ b/packages/documentation/src/stories/misc/changelog/changelog.docs.mdx @@ -1,6 +1,6 @@ import { Markdown, Meta } from '@storybook/blocks'; import changelog from '../../../../../styles/CHANGELOG.md?raw'; -import { CodeOrSourceMdx } from '../../utilities/markdown/CodeOrSourceMdx'; +import { CodeOrSourceMdx } from '../../../utils/CodeOrSourceMdx'; }) => { - return (function recurse(keys): Array<{ [key: string]: unknown }> { - if (!keys.length) return [{}]; - let result = recurse(keys.slice(1)); - return variants[keys[0]].reduce( - (acc: Array<{ [key: string]: unknown }>, value) => - acc.concat(result.map((item: any) => Object.assign({}, item, { [keys[0]]: value }))), - [], - ); - })(Object.keys(variants)); -}; diff --git a/packages/documentation/src/utils/bombArgs.ts b/packages/documentation/src/utils/bomb-args.ts similarity index 100% rename from packages/documentation/src/utils/bombArgs.ts rename to packages/documentation/src/utils/bomb-args.ts diff --git a/packages/documentation/src/stories/utilities/markdown/CodeOrSourceMdx.tsx b/packages/documentation/src/utils/codeOrSourceMdx.tsx similarity index 92% rename from packages/documentation/src/stories/utilities/markdown/CodeOrSourceMdx.tsx rename to packages/documentation/src/utils/codeOrSourceMdx.tsx index bb3d9b48e9..bed393c564 100644 --- a/packages/documentation/src/stories/utilities/markdown/CodeOrSourceMdx.tsx +++ b/packages/documentation/src/utils/codeOrSourceMdx.tsx @@ -1,7 +1,7 @@ // Source: https://github.com/storybookjs/storybook/blob/next/code/ui/blocks/src/blocks/mdx.tsx#L34 import { Source } from '@storybook/blocks'; import { Code } from '@storybook/components'; -import { SourceDarkMode } from '../../../../.storybook/preview'; +import { SourceDarkMode } from '../../.storybook/preview'; // @ts-ignore export const CodeOrSourceMdx = ({ className, children, ...rest }) => { diff --git a/packages/documentation/src/utils/index.ts b/packages/documentation/src/utils/index.ts index fc4ca0d03f..ba9a736578 100644 --- a/packages/documentation/src/utils/index.ts +++ b/packages/documentation/src/utils/index.ts @@ -1,3 +1,4 @@ +export * from './bomb-args'; export * from './component-properties'; export * from './get-attributes'; export * from './map-classes';