mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 08:43:33 +00:00
* [CL-58] feat: add support for modyfing button types from directives * [CL-58] feat: set button type secondary when used as prefix/suffix * [CL-58] chore: add example using suffix to async actions story * [CL-58] feat: update story with examples * [CL-58] feat: allow buttons to have their style unset * [CL-58] feat: move all styling into prefix/suffix * [CL-58] fix: static content prefix/suffix * [CL-58] fix: add missing bitFormButton to bitAction * [CL-58] fix: disabled opacity not overriding correctly * [CL-58] feat: change hover color to muted * [CL-58] feat: replace undefined with unstyled * [CL-58] fix: focus borders on input and prefix/suffix * [CL-58] feat: update production code to use icon button correctly * [CL-58] refactor: move out button type to common place * [CL-58] fix: buttons not migrated correctly * [CL-58] feat: use icon button in password toggle * [CL-58] fix: remove button icon stories * [SM-358] Migrate password toggles (#4129) * [CL-58] fix: missing i18n service in story * [CL-58] fix: missing bitIconButton directive in export comp Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> Co-authored-by: Thomas Rittson <trittson@bitwarden.com>
104 lines
3.4 KiB
TypeScript
104 lines
3.4 KiB
TypeScript
import { Meta, Story } from "@storybook/angular";
|
|
|
|
import { ButtonComponent } from "./button.component";
|
|
|
|
export default {
|
|
title: "Component Library/Button",
|
|
component: ButtonComponent,
|
|
args: {
|
|
buttonType: "primary",
|
|
disabled: false,
|
|
loading: false,
|
|
},
|
|
parameters: {
|
|
design: {
|
|
type: "figma",
|
|
url: "https://www.figma.com/file/Zt3YSeb6E6lebAffrNLa0h/Tailwind-Component-Library?node-id=5115%3A26950",
|
|
},
|
|
},
|
|
} as Meta;
|
|
|
|
const Template: Story<ButtonComponent> = (args: ButtonComponent) => ({
|
|
props: args,
|
|
template: `
|
|
<button bitButton [disabled]="disabled" [loading]="loading" [buttonType]="buttonType" [block]="block">Button</button>
|
|
<a bitButton [disabled]="disabled" [loading]="loading" [buttonType]="buttonType" [block]="block" href="#" class="tw-ml-2">Link</a>
|
|
`,
|
|
});
|
|
|
|
export const Primary = Template.bind({});
|
|
Primary.args = {
|
|
buttonType: "primary",
|
|
};
|
|
|
|
export const Secondary = Template.bind({});
|
|
Secondary.args = {
|
|
buttonType: "secondary",
|
|
};
|
|
|
|
export const Danger = Template.bind({});
|
|
Danger.args = {
|
|
buttonType: "danger",
|
|
};
|
|
|
|
const AllStylesTemplate: Story = (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>
|
|
`,
|
|
});
|
|
|
|
export const Loading = AllStylesTemplate.bind({});
|
|
Loading.args = {
|
|
disabled: false,
|
|
loading: true,
|
|
};
|
|
|
|
export const Disabled = AllStylesTemplate.bind({});
|
|
Disabled.args = {
|
|
disabled: true,
|
|
loading: false,
|
|
};
|
|
|
|
const DisabledWithAttributeTemplate: Story = (args) => ({
|
|
props: args,
|
|
template: `
|
|
<ng-container *ngIf="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>
|
|
</ng-container>
|
|
<ng-container *ngIf="!disabled">
|
|
<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>
|
|
</ng-container>
|
|
`,
|
|
});
|
|
|
|
export const DisabledWithAttribute = DisabledWithAttributeTemplate.bind({});
|
|
DisabledWithAttribute.args = {
|
|
disabled: true,
|
|
loading: false,
|
|
};
|
|
|
|
const BlockTemplate: Story<ButtonComponent> = (args: ButtonComponent) => ({
|
|
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>
|
|
`,
|
|
});
|
|
|
|
export const Block = BlockTemplate.bind({});
|
|
Block.args = {
|
|
block: true,
|
|
};
|