mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 08:43:33 +00:00
* Use typescript-strict-plugin to iteratively turn on strict * Add strict testing to pipeline Can be executed locally through either `npm run test:types` for full type checking including spec files, or `npx tsc-strict` for only tsconfig.json included files. * turn on strict for scripts directory * Use plugin for all tsconfigs in monorepo vscode is capable of executing tsc with plugins, but uses the most relevant tsconfig to do so. If the plugin is not a part of that config, it is skipped and developers get no feedback of strict compile time issues. These updates remedy that at the cost of slightly more complex removal of the plugin when the time comes. * remove plugin from configs that extend one that already has it * Update workspace settings to honor strict plugin * Apply strict-plugin to native message test runner * Update vscode workspace to use root tsc version * `./node_modules/.bin/update-strict-comments` 🤖 This is a one-time operation. All future files should adhere to strict type checking. * Add fixme to `ts-strict-ignore` comments * `update-strict-comments` 🤖 repeated for new merge files
126 lines
4.8 KiB
TypeScript
126 lines
4.8 KiB
TypeScript
// FIXME: Update this file to be type safe and remove this and next line
|
|
// @ts-strict-ignore
|
|
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,
|
|
},
|
|
parameters: {
|
|
design: {
|
|
type: "figma",
|
|
url: "https://www.figma.com/file/Zt3YSeb6E6lebAffrNLa0h/Tailwind-Component-Library?node-id=5115%3A26950",
|
|
},
|
|
},
|
|
} 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">
|
|
<button bitButton [disabled]="disabled" [loading]="loading" [buttonType]="buttonType" [block]="block">Button</button>
|
|
<button bitButton [disabled]="disabled" [loading]="loading" [buttonType]="buttonType" [block]="block" class="tw-test-hover">Button:hover</button>
|
|
<button bitButton [disabled]="disabled" [loading]="loading" [buttonType]="buttonType" [block]="block" class="tw-test-focus-visible">Button:focus-visible</button>
|
|
<button bitButton [disabled]="disabled" [loading]="loading" [buttonType]="buttonType" [block]="block" class="tw-test-hover tw-test-focus-visible">Button:hover:focus-visible</button>
|
|
<button bitButton [disabled]="disabled" [loading]="loading" [buttonType]="buttonType" [block]="block" class="tw-test-active">Button:active</button>
|
|
</div>
|
|
<div class="tw-flex tw-gap-4">
|
|
<a href="#" bitButton [disabled]="disabled" [loading]="loading" [buttonType]="buttonType" [block]="block">Anchor</a>
|
|
<a href="#" bitButton [disabled]="disabled" [loading]="loading" [buttonType]="buttonType" [block]="block" class="tw-test-hover">Anchor:hover</a>
|
|
<a href="#" bitButton [disabled]="disabled" [loading]="loading" [buttonType]="buttonType" [block]="block" class="tw-test-focus-visible">Anchor:focus-visible</a>
|
|
<a href="#" bitButton [disabled]="disabled" [loading]="loading" [buttonType]="buttonType" [block]="block" class="tw-test-hover tw-test-focus-visible">Anchor:hover:focus-visible</a>
|
|
<a href="#" bitButton [disabled]="disabled" [loading]="loading" [buttonType]="buttonType" [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 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: `
|
|
<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>
|
|
`,
|
|
}),
|
|
args: {
|
|
disabled: true,
|
|
loading: false,
|
|
},
|
|
};
|
|
|
|
export const Block: Story = {
|
|
render: (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>
|
|
`,
|
|
}),
|
|
args: {
|
|
block: true,
|
|
},
|
|
};
|