mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 22:33:35 +00:00
* adds small button size variant * makes small icon button same size as small button * testing small button for extension header * remove extension changes * update popout layout story * revert change to small icon button padding * add whitespace to see if error resolves * default buttonType to primary * default buttonType to secondary * add comment around why nonNullButtonSize value exists * add comment to property about using the non null version * Update apps/browser/src/platform/popup/layout/popup-layout.stories.ts Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> * updated input syntax when using static values * remove nonNull value coersion * allow changing of size input in Story --------- Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com>
168 lines
6.1 KiB
TypeScript
168 lines
6.1 KiB
TypeScript
import { Meta, StoryObj } from "@storybook/angular";
|
|
|
|
import { ButtonComponent } from "./button.component";
|
|
|
|
export default {
|
|
title: "Component Library/Button",
|
|
component: ButtonComponent,
|
|
args: {
|
|
buttonType: "primary",
|
|
disabled: false,
|
|
loading: false,
|
|
size: "default",
|
|
},
|
|
argTypes: {
|
|
size: {
|
|
options: ["small", "default"],
|
|
control: { type: "radio" },
|
|
},
|
|
},
|
|
parameters: {
|
|
design: {
|
|
type: "figma",
|
|
url: "https://www.figma.com/design/Zt3YSeb6E6lebAffrNLa0h/Tailwind-Component-Library?node-id=16329-28224&t=b5tDKylm5sWm2yKo-4",
|
|
},
|
|
},
|
|
} as Meta<ButtonComponent>;
|
|
|
|
type Story = StoryObj<ButtonComponent>;
|
|
|
|
export const Primary: Story = {
|
|
render: (args) => ({
|
|
props: args,
|
|
template: /*html*/ `
|
|
<div class="tw-flex tw-gap-4 tw-mb-6 tw-items-center">
|
|
<button bitButton [disabled]="disabled" [loading]="loading" [buttonType]="buttonType" [size]="size" [block]="block">Button</button>
|
|
<button bitButton [disabled]="disabled" [loading]="loading" [buttonType]="buttonType" [size]="size" [block]="block" class="tw-test-hover">Button:hover</button>
|
|
<button bitButton [disabled]="disabled" [loading]="loading" [buttonType]="buttonType" [size]="size" [block]="block" class="tw-test-focus-visible">Button:focus-visible</button>
|
|
<button bitButton [disabled]="disabled" [loading]="loading" [buttonType]="buttonType" [size]="size" [block]="block" class="tw-test-hover tw-test-focus-visible">Button:hover:focus-visible</button>
|
|
<button bitButton [disabled]="disabled" [loading]="loading" [buttonType]="buttonType" [size]="size" [block]="block" class="tw-test-active">Button:active</button>
|
|
</div>
|
|
<div class="tw-flex tw-gap-4 tw-items-center">
|
|
<a href="#" bitButton [disabled]="disabled" [loading]="loading" [buttonType]="buttonType" [size]="size" [block]="block">Anchor</a>
|
|
<a href="#" bitButton [disabled]="disabled" [loading]="loading" [buttonType]="buttonType" [size]="size" [block]="block" class="tw-test-hover">Anchor:hover</a>
|
|
<a href="#" bitButton [disabled]="disabled" [loading]="loading" [buttonType]="buttonType" [size]="size" [block]="block" class="tw-test-focus-visible">Anchor:focus-visible</a>
|
|
<a href="#" bitButton [disabled]="disabled" [loading]="loading" [buttonType]="buttonType" [size]="size" [block]="block" class="tw-test-hover tw-test-focus-visible">Anchor:hover:focus-visible</a>
|
|
<a href="#" bitButton [disabled]="disabled" [loading]="loading" [buttonType]="buttonType" [size]="size" [block]="block" class="tw-test-active">Anchor:active</a>
|
|
</div>
|
|
`,
|
|
}),
|
|
args: {
|
|
buttonType: "primary",
|
|
},
|
|
};
|
|
|
|
export const Secondary: Story = {
|
|
...Primary,
|
|
args: {
|
|
buttonType: "secondary",
|
|
},
|
|
};
|
|
|
|
export const Danger: Story = {
|
|
...Primary,
|
|
args: {
|
|
buttonType: "danger",
|
|
},
|
|
};
|
|
|
|
export const Small: Story = {
|
|
render: (args) => ({
|
|
props: args,
|
|
template: /*html*/ `
|
|
<div class="tw-flex tw-gap-4 tw-mb-6 tw-items-center">
|
|
<button bitButton [disabled]="disabled" [loading]="loading" [buttonType]="'primary'" [size]="size" [block]="block">Primary small</button>
|
|
<button bitButton [disabled]="disabled" [loading]="loading" [buttonType]="'secondary'" [size]="size" [block]="block">Secondary small</button>
|
|
<button bitButton [disabled]="disabled" [loading]="loading" [buttonType]="'danger'" [size]="size" [block]="block">Danger small</button>
|
|
</div>
|
|
`,
|
|
}),
|
|
args: {
|
|
size: "small",
|
|
},
|
|
};
|
|
|
|
export const Loading: Story = {
|
|
render: (args) => ({
|
|
props: args,
|
|
template: `
|
|
<button bitButton [disabled]="disabled" [loading]="loading" [block]="block" buttonType="primary" class="tw-mr-2">Primary</button>
|
|
<button bitButton [disabled]="disabled" [loading]="loading" [block]="block" buttonType="secondary" class="tw-mr-2">Secondary</button>
|
|
<button bitButton [disabled]="disabled" [loading]="loading" [block]="block" buttonType="danger" class="tw-mr-2">Danger</button>
|
|
`,
|
|
}),
|
|
args: {
|
|
disabled: false,
|
|
loading: true,
|
|
},
|
|
};
|
|
|
|
export const Disabled: Story = {
|
|
...Loading,
|
|
args: {
|
|
disabled: true,
|
|
loading: false,
|
|
},
|
|
};
|
|
|
|
export const DisabledWithAttribute: Story = {
|
|
render: (args) => ({
|
|
props: args,
|
|
template: `
|
|
@if (disabled) {
|
|
<button bitButton disabled [loading]="loading" [block]="block" buttonType="primary" class="tw-mr-2">Primary</button>
|
|
<button bitButton disabled [loading]="loading" [block]="block" buttonType="secondary" class="tw-mr-2">Secondary</button>
|
|
<button bitButton disabled [loading]="loading" [block]="block" buttonType="danger" class="tw-mr-2">Danger</button>
|
|
} @else {
|
|
<button bitButton [loading]="loading" [block]="block" buttonType="primary" class="tw-mr-2">Primary</button>
|
|
<button bitButton [loading]="loading" [block]="block" buttonType="secondary" class="tw-mr-2">Secondary</button>
|
|
<button bitButton [loading]="loading" [block]="block" buttonType="danger" class="tw-mr-2">Danger</button>
|
|
}
|
|
`,
|
|
}),
|
|
args: {
|
|
disabled: true,
|
|
loading: false,
|
|
},
|
|
};
|
|
|
|
export const Block: Story = {
|
|
render: (args) => ({
|
|
props: args,
|
|
template: `
|
|
<span class="tw-flex">
|
|
<button bitButton [buttonType]="buttonType" [block]="block">[block]="true" Button</button>
|
|
<a bitButton [buttonType]="buttonType" [block]="block" href="#" class="tw-ml-2">[block]="true" Link</a>
|
|
|
|
<button bitButton [buttonType]="buttonType" block class="tw-ml-2">block Button</button>
|
|
<a bitButton [buttonType]="buttonType" block href="#" class="tw-ml-2">block Link</a>
|
|
</span>
|
|
`,
|
|
}),
|
|
args: {
|
|
block: true,
|
|
},
|
|
};
|
|
|
|
export const WithIcon: Story = {
|
|
render: (args) => ({
|
|
props: args,
|
|
template: `
|
|
<span class="tw-flex tw-gap-8">
|
|
<div>
|
|
<button bitButton [buttonType]="buttonType" [block]="block">
|
|
<i class="bwi bwi-plus tw-me-2"></i>
|
|
Button label
|
|
</button>
|
|
</div>
|
|
<div>
|
|
<button bitButton [buttonType]="buttonType" [block]="block">
|
|
Button label
|
|
<i class="bwi bwi-plus tw-ms-2"></i>
|
|
</button>
|
|
</div>
|
|
</span>
|
|
`,
|
|
}),
|
|
};
|