Skip to content

Commit

Permalink
chore: consolifates button stories
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabian Gaukler committed Nov 15, 2024
1 parent 3891484 commit 038daa1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 131 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ArgTypes, StoryObj } from "@storybook/web-components";
import type { ArgTypes } from "@storybook/web-components";
import { html } from "lit";

type ButtonSize = "default" | "small";
Expand All @@ -10,9 +10,6 @@ export const buttonArgs = (variant: ButtonVariant): ButtonArgs => ({
variant,
size: "default",
disabled: false,
hovered: false,
active: false,
focused: false,
iconPosition: "left",
label: "",
});
Expand All @@ -33,55 +30,10 @@ export interface ButtonArgs {
variant: ButtonVariant;
size: ButtonSize;
disabled: boolean;
hovered: boolean;
active: boolean;
focused: boolean;
icon?: string;
iconPosition: ButtonIconPosition;
}

export type Story = StoryObj<ButtonArgs>;
export const EnabledStory: Story = {
args: {
label: "Enabled Button",
},
};

// Hovered (Button Hovered)
export const HoveredStory: Story = {
args: {
label: "Hovered Button",
hovered: true,
},
parameters: { pseudo: { hover: true } },
};

// Focused
export const FocusedStory: Story = {
args: {
label: "Focused Button",
focused: true,
},
parameters: { pseudo: { focus: true } },
};

// Active (Pressed)
export const ActiveStory: Story = {
args: {
label: "Active Button",
active: true,
},
parameters: { pseudo: { active: true } },
};

// Disabled
export const DisabledStory: Story = {
args: {
label: "Disabled Button",
disabled: true,
},
};

export const renderButtons = (args: ButtonArgs, colorScheme: ColorScheme) =>
html`<div
style="display:flex;gap:0.5rem;flex-direction:column;padding:2rem;color-scheme:${colorScheme};background-color:${colorScheme ===
Expand Down
24 changes: 24 additions & 0 deletions packages/documentation/src/elements/button/button.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { Meta, StoryObj } from "@storybook/web-components";
import { html } from "lit";
import {
buttonArgs,
buttonArgTypes,
renderButtons,
type ButtonArgs,
} from "./button-story-helpers.js";

const meta: Meta<ButtonArgs> = {
argTypes: buttonArgTypes,

render: (args) =>
html`<div style="display:flex;gap:1rem">
${renderButtons(args, "light")}${renderButtons(args, "dark")}
</div>`,
};

export default meta;

export type Story = StoryObj<ButtonArgs>;

export const ButtonPrimary: Story = { args: buttonArgs("primary") };
export const ButtonSecondary: Story = { args: buttonArgs("secondary") };

0 comments on commit 038daa1

Please sign in to comment.