diff --git a/packages/api/.storybook/preview.jsx b/packages/api/.storybook/preview.jsx index 4e5317f7..d36dbe24 100644 --- a/packages/api/.storybook/preview.jsx +++ b/packages/api/.storybook/preview.jsx @@ -39,6 +39,7 @@ const preview = { }, controls: { + disableSaveFromUI: true, // show description and default values in the individual stories (basic, etc.) expanded: true, matchers: { diff --git a/packages/api/src/helpers/constants.ts b/packages/api/src/helpers/constants.ts new file mode 100644 index 00000000..b916af3e --- /dev/null +++ b/packages/api/src/helpers/constants.ts @@ -0,0 +1,5 @@ +export const commonControlsSetup = { + parameters: { + controls: { exclude: ["spacing"], sort: "requiredFirst" }, + }, +}; diff --git a/packages/api/src/stories/Bubble.stories.tsx b/packages/api/src/stories/Bubble.stories.tsx index c79e0257..94e05daf 100644 --- a/packages/api/src/stories/Bubble.stories.tsx +++ b/packages/api/src/stories/Bubble.stories.tsx @@ -2,25 +2,28 @@ import type { Meta, StoryObj } from "@storybook/react"; import "@versini/ui-bubble/dist/style.css"; import { Bubble } from "../../../ui-bubble/src/components"; +import { commonControlsSetup } from "../helpers/constants"; type Story = StoryObj; const meta: Meta = { parameters: { layout: "centered", - docs: { - controls: { exclude: ["spacing"] }, - }, + docs: { ...commonControlsSetup.parameters }, }, title: "Components/Bubble", component: Bubble, - args: {}, + args: { + copyToClipboardFocusMode: "system", + copyToClipboardMode: "system", + }, }; export default meta; export const Basic: Story = { + ...commonControlsSetup, render: (args) => (
@@ -36,6 +39,7 @@ export const Basic: Story = { const string = "DOM element with string"; export const Copy: Story = { + ...commonControlsSetup, render: (args) => (
@@ -69,6 +73,7 @@ export const Copy: Story = { }; export const LongText: Story = { + ...commonControlsSetup, render: (args) => (
@@ -136,6 +141,7 @@ export const LongText: Story = { }; export const WithFooter: Story = { + ...commonControlsSetup, render: (args) => (
; const meta: Meta = { parameters: { layout: "centered", - docs: { - controls: { exclude: ["spacing"] }, - }, + docs: { ...commonControlsSetup.parameters }, }, title: "Components/Button", component: Button, - args: { onClick: fn() }, + args: { + onClick: fn(), + disabled: false, + noTruncate: false, + variant: "primary", + focusMode: "system", + mode: "system", + size: "medium", + noBorder: false, + raw: false, + fullWidth: false, + noInternalClick: false, + }, }; export default meta; export const Basic: Story = { + ...commonControlsSetup, render: (args) => (
@@ -32,6 +44,7 @@ export const Basic: Story = { }; export const Truncate: Story = { + ...commonControlsSetup, args: { className: "w-44 sm:w-52" }, render: (args) => { return ( @@ -41,12 +54,12 @@ export const Truncate: Story = {
-
+

For text to truncate, you need to limit the width of the buttons.

This can be done by using Tailwind width classes, for example

- className={args.className} + className={args.className}
); diff --git a/packages/api/src/stories/ButtonIcon.stories.tsx b/packages/api/src/stories/ButtonIcon.stories.tsx index 9ec1de19..31a8e1e9 100644 --- a/packages/api/src/stories/ButtonIcon.stories.tsx +++ b/packages/api/src/stories/ButtonIcon.stories.tsx @@ -10,24 +10,36 @@ import { IconPrevious, IconSettings, } from "@versini/ui-icons"; +import { commonControlsSetup } from "../helpers/constants"; type Story = StoryObj; const meta: Meta = { parameters: { layout: "centered", - docs: { - controls: { exclude: ["spacing"] }, - }, + docs: { ...commonControlsSetup.parameters }, }, title: "Components/ButtonIcon", component: ButtonIcon, - args: { onClick: fn() }, + args: { + onClick: fn(), + align: "center", + disabled: false, + focusMode: "system", + mode: "system", + size: "medium", + noBorder: false, + raw: false, + fullWidth: false, + noInternalClick: false, + noBackground: false, + }, }; export default meta; export const Basic: Story = { + ...commonControlsSetup, render: (args) => (
@@ -47,6 +59,7 @@ export const Basic: Story = { }; export const WithLabel: Story = { + ...commonControlsSetup, render: (args) => ( <>
diff --git a/packages/api/src/stories/ButtonLink.stories.tsx b/packages/api/src/stories/ButtonLink.stories.tsx index 463935f0..c4d4a021 100644 --- a/packages/api/src/stories/ButtonLink.stories.tsx +++ b/packages/api/src/stories/ButtonLink.stories.tsx @@ -3,25 +3,42 @@ import { fn } from "@storybook/test"; import "@versini/ui-button/dist/style.css"; import { ButtonLink } from "../../../ui-button/src/components"; +import { commonControlsSetup } from "../helpers/constants"; type Story = StoryObj; const meta: Meta = { parameters: { layout: "centered", - docs: { - controls: { exclude: ["spacing"] }, - }, + docs: { ...commonControlsSetup.parameters }, }, title: "Components/ButtonLink", component: ButtonLink, - args: { onClick: fn() }, + args: { + onClick: fn(), + disabled: false, + noTruncate: false, + variant: "primary", + focusMode: "system", + mode: "system", + size: "small", + noBorder: false, + raw: false, + fullWidth: false, + noInternalClick: false, + noNewWindowIcon: false, + target: "_self", + }, }; export default meta; export const Basic: Story = { + ...commonControlsSetup, + args: { + href: "https://www.example.com", + }, render: (args) => (
Anchor as a button @@ -35,7 +52,8 @@ export const Basic: Story = { }; export const NewWindow: Story = { - args: { target: "_blank" }, + ...commonControlsSetup, + args: { target: "_blank", href: "https://www.example.com" }, render: (args) => (
Anchor as a button @@ -49,7 +67,8 @@ export const NewWindow: Story = { }; export const Truncate: Story = { - args: { className: "w-44 sm:w-52" }, + ...commonControlsSetup, + args: { className: "w-44 sm:w-52", href: "https://www.example.com" }, render: (args) => ( <>
@@ -60,10 +79,10 @@ export const Truncate: Story = { Anchor as a button lorem ipsum dolor sit amet
-
+

For text to truncate, you need to limit the width of the buttons.

This can be done by using Tailwind width classes, for example

- className={args.className} + className={args.className}
), diff --git a/packages/api/src/stories/Card.stories.tsx b/packages/api/src/stories/Card.stories.tsx index 7970df3b..59bcb693 100644 --- a/packages/api/src/stories/Card.stories.tsx +++ b/packages/api/src/stories/Card.stories.tsx @@ -1,24 +1,28 @@ import type { Meta, StoryObj } from "@storybook/react"; import { Card } from "@versini/ui-card/src/components"; +import { commonControlsSetup } from "../helpers/constants"; type Story = StoryObj; const meta: Meta = { parameters: { layout: "centered", - docs: { - controls: { exclude: ["spacing"] }, - }, + docs: { ...commonControlsSetup.parameters }, }, title: "Components/Card", component: Card, - args: {}, + args: { + compact: false, + mode: "system", + noBorder: false, + }, }; export default meta; export const Basic: Story = { + ...commonControlsSetup, args: { header: "Dune", footer: "Frank Herbert", @@ -45,6 +49,7 @@ export const Basic: Story = { }; export const Custom: Story = { + ...commonControlsSetup, args: { header:

Dune

, footer:

Frank Herbert

, diff --git a/packages/ui-bubble/src/components/Bubble/BubbleTypes.d.ts b/packages/ui-bubble/src/components/Bubble/BubbleTypes.d.ts index 8cbd79d5..09b4eeaf 100644 --- a/packages/ui-bubble/src/components/Bubble/BubbleTypes.d.ts +++ b/packages/ui-bubble/src/components/Bubble/BubbleTypes.d.ts @@ -2,7 +2,7 @@ import type { SpacingProps } from "@versini/ui-private/dist/utilities"; export type BubbleProps = { /** - * The children to render. + * The text to render in the bubble. */ children: React.ReactNode; /** @@ -11,6 +11,9 @@ export type BubbleProps = { className?: string; /** * Whether or not to show a "copy/paste" icon next to the Bubble. + * - If a function is passed, it will be called with the text to copy. + * - If a string is passed, that string will be copied. + * - If a boolean is passed, the children will be copied. */ copyToClipboard?: boolean | string | ((text: any) => void); /** diff --git a/packages/ui-button/src/components/Button/ButtonTypes.d.ts b/packages/ui-button/src/components/Button/ButtonTypes.d.ts index 5b12cacf..a3d1635e 100644 --- a/packages/ui-button/src/components/Button/ButtonTypes.d.ts +++ b/packages/ui-button/src/components/Button/ButtonTypes.d.ts @@ -42,7 +42,7 @@ export type CommonButtonProps = { export type ButtonProps = { /** - * The children to render. + * The text to render in the button. */ children: React.ReactNode; /** @@ -76,12 +76,23 @@ export type ButtonLinkProps = { * @default false */ noNewWindowIcon?: boolean; + /** + * A string that is the result of parsing the href HTML attribute + * relative to the document, containing a valid URL of a linked resource. + */ + href?: string; + /** + * A string that reflects the target HTML attribute, indicating where + * to display the linked resource. + * @default _self + */ + target?: "_blank" | "_self" | "_parent" | "_top"; } & ButtonProps & React.AnchorHTMLAttributes; export type ButtonIconProps = { /** - * The children to render. + * The icon to render in the button. */ children: React.ReactNode; /** @@ -90,7 +101,7 @@ export type ButtonIconProps = { */ align?: "left" | "right" | "center"; /** - * The label to show next to the icon. + * The label to use as aria-label. */ label?: string; /**