1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-13 10:24:20 +01:00

[PM-9969] Papercut - Update component library storybook docs (#10191)

* add component import examples

* component library story html formatting/cleanup nits

* Update libs/components/src/dialog/dialog/dialog.mdx

Co-authored-by: Will Martin <contact@willmartian.com>

* Update libs/components/src/badge/badge.mdx

Co-authored-by: Will Martin <contact@willmartian.com>

* Update libs/components/src/dialog/simple-dialog/simple-dialog.mdx

Co-authored-by: Will Martin <contact@willmartian.com>

---------

Co-authored-by: Will Martin <contact@willmartian.com>
This commit is contained in:
Jonathan Prusik 2024-08-07 11:13:29 -04:00 committed by GitHub
parent f8961e35e7
commit 66d9ab5dc0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 210 additions and 21 deletions

View File

@ -4,6 +4,10 @@ import * as stories from "./badge.stories";
<Meta of={stories} /> <Meta of={stories} />
```ts
import { BadgeModule } from "@bitwarden/components";
```
# Badge # Badge
The Badge directive can be used on a `<span>` (non clickable events), or an `<a>` or `<button>` tag The Badge directive can be used on a `<span>` (non clickable events), or an `<a>` or `<button>` tag

View File

@ -31,9 +31,9 @@ export const Primary: Story = {
props: args, props: args,
template: ` template: `
<span class="tw-text-main">Span </span><span bitBadge [variant]="variant" [truncate]="truncate">Badge containing lengthy text</span> <span class="tw-text-main">Span </span><span bitBadge [variant]="variant" [truncate]="truncate">Badge containing lengthy text</span>
<br><br> <br /><br />
<span class="tw-text-main">Link </span><a href="#" bitBadge [variant]="variant" [truncate]="truncate">Badge</a> <span class="tw-text-main">Link </span><a href="#" bitBadge [variant]="variant" [truncate]="truncate">Badge</a>
<br><br> <br /><br />
<span class="tw-text-main">Button </span><button bitBadge [variant]="variant" [truncate]="truncate">Badge</button> <span class="tw-text-main">Button </span><button bitBadge [variant]="variant" [truncate]="truncate">Badge</button>
`, `,
}), }),

View File

@ -4,6 +4,10 @@ import * as stories from "./button.stories";
<Meta of={stories} /> <Meta of={stories} />
```ts
import { ButtonModule } from "@bitwarden/components";
```
# Button # Button
Buttons are interactive elements that can be triggered using a mouse, keyboard, or touch. They are Buttons are interactive elements that can be triggered using a mouse, keyboard, or touch. They are

View File

@ -0,0 +1,32 @@
import { Meta, Canvas, Source, Primary, Controls } from "@storybook/addon-docs";
import * as stories from "./checkbox.stories";
<Meta of={stories} />
```ts
import { CheckboxModule } from "@bitwarden/components";
```
# Checkbox
<Primary />
<Controls />
## Stories
### Default
<Canvas of={stories.Default} />
### Hint
<Canvas of={stories.Hint} />
### Custom
<Canvas of={stories.Custom} />
### Intermediate
<Canvas of={stories.Indeterminate} />

View File

@ -19,7 +19,7 @@ import { CheckboxModule } from "./checkbox.module";
const template = ` const template = `
<form [formGroup]="formObj"> <form [formGroup]="formObj">
<bit-form-control> <bit-form-control>
<input type="checkbox" bitCheckbox formControlName="checkbox"> <input type="checkbox" bitCheckbox formControlName="checkbox" />
<bit-label>Click me</bit-label> <bit-label>Click me</bit-label>
</bit-form-control> </bit-form-control>
</form> </form>
@ -107,7 +107,7 @@ export const Hint: Story = {
template: ` template: `
<form [formGroup]="formObj"> <form [formGroup]="formObj">
<bit-form-control> <bit-form-control>
<input type="checkbox" bitCheckbox formControlName="checkbox"> <input type="checkbox" bitCheckbox formControlName="checkbox" />
<bit-label>Really long value that never ends.</bit-label> <bit-label>Really long value that never ends.</bit-label>
<bit-hint> <bit-hint>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur iaculis consequat enim vitae elementum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur iaculis consequat enim vitae elementum.
@ -138,15 +138,15 @@ export const Custom: Story = {
<div class="tw-flex tw-flex-col tw-w-32"> <div class="tw-flex tw-flex-col tw-w-32">
<label class="tw-text-main tw-flex tw-bg-secondary-300 tw-p-2 tw-items-baseline"> <label class="tw-text-main tw-flex tw-bg-secondary-300 tw-p-2 tw-items-baseline">
A-Z A-Z
<input class="tw-ml-auto focus-visible:tw-ring-offset-secondary-300" type="checkbox" bitCheckbox> <input class="tw-ml-auto focus-visible:tw-ring-offset-secondary-300" type="checkbox" bitCheckbox />
</label> </label>
<label class="tw-text-main tw-flex tw-bg-secondary-300 tw-p-2 tw-items-baseline"> <label class="tw-text-main tw-flex tw-bg-secondary-300 tw-p-2 tw-items-baseline">
a-z a-z
<input class="tw-ml-auto focus-visible:tw-ring-offset-secondary-300" type="checkbox" bitCheckbox> <input class="tw-ml-auto focus-visible:tw-ring-offset-secondary-300" type="checkbox" bitCheckbox />
</label> </label>
<label class="tw-text-main tw-flex tw-bg-secondary-300 tw-p-2 tw-items-baseline"> <label class="tw-text-main tw-flex tw-bg-secondary-300 tw-p-2 tw-items-baseline">
0-9 0-9
<input class="tw-ml-auto focus-visible:tw-ring-offset-secondary-300" type="checkbox" bitCheckbox> <input class="tw-ml-auto focus-visible:tw-ring-offset-secondary-300" type="checkbox" bitCheckbox />
</label> </label>
</div> </div>
`, `,

View File

@ -4,6 +4,10 @@ import * as stories from "./dialog.stories";
<Meta of={stories} /> <Meta of={stories} />
```ts
import { DialogModule, DialogService } from "@bitwarden/components";
```
# Dialog # Dialog
Dialogs are used throughout the app to help the user focus on a specific action. Use this dialog Dialogs are used throughout the app to help the user focus on a specific action. Use this dialog

View File

@ -145,9 +145,9 @@ export const ScrollingContent: Story = {
template: ` template: `
<bit-dialog title="Scrolling Example" [dialogSize]="dialogSize" [loading]="loading" [disablePadding]="disablePadding"> <bit-dialog title="Scrolling Example" [dialogSize]="dialogSize" [loading]="loading" [disablePadding]="disablePadding">
<span bitDialogContent> <span bitDialogContent>
Dialog body text goes here.<br> Dialog body text goes here.<br />
<ng-container *ngFor="let _ of [].constructor(100)"> <ng-container *ngFor="let _ of [].constructor(100)">
repeating lines of characters <br> repeating lines of characters <br />
</ng-container> </ng-container>
end of sequence! end of sequence!
</span> </span>

View File

@ -4,6 +4,10 @@ import * as stories from "./simple-dialog.stories";
<Meta of={stories} /> <Meta of={stories} />
```ts
import { DialogModule, DialogService } from "@bitwarden/components";
```
# Simple Dialogs # Simple Dialogs
Simple Dialogs are used throughout the app for simple alert or confirmation actions such as Simple Dialogs are used throughout the app for simple alert or confirmation actions such as

View File

@ -64,10 +64,9 @@ export const ScrollingContent: Story = {
<bit-simple-dialog> <bit-simple-dialog>
<span bitDialogTitle>Alert Dialog</span> <span bitDialogTitle>Alert Dialog</span>
<span bitDialogContent> <span bitDialogContent>
Message Content Message Content Message text goes here.<br />
Message text goes here.<br>
<ng-container *ngFor="let _ of [].constructor(100)"> <ng-container *ngFor="let _ of [].constructor(100)">
repeating lines of characters <br> repeating lines of characters <br />
</ng-container> </ng-container>
end of sequence! end of sequence!
</span> </span>

View File

@ -0,0 +1,60 @@
import { Meta, Canvas, Source, Primary, Controls } from "@storybook/addon-docs";
import * as stories from "./form-field.stories";
<Meta of={stories} />
```ts
import { FormFieldModule } from "@bitwarden/components";
```
# Field
<Primary />
<Controls />
## Stories
### Default
<Canvas of={stories.Default} />
### Required
<Canvas of={stories.Required} />
### Hint
<Canvas of={stories.Hint} />
### Disabled
<Canvas of={stories.Disabled} />
### Readonly
<Canvas of={stories.Readonly} />
### Input Group
<Canvas of={stories.InputGroup} />
### Button Input Group
<Canvas of={stories.ButtonInputGroup} />
### Disabled Button Input Group
<Canvas of={stories.DisabledButtonInputGroup} />
### Select
<Canvas of={stories.Select} />
### Advanced Select
<Canvas of={stories.AdvancedSelect} />
### Textarea
<Canvas of={stories.Textarea} />

View File

@ -96,19 +96,19 @@ export const FullExample: Story = {
<bit-label>Name</bit-label> <bit-label>Name</bit-label>
<input bitInput formControlName="name" /> <input bitInput formControlName="name" />
</bit-form-field> </bit-form-field>
<bit-form-field> <bit-form-field>
<bit-label>Email</bit-label> <bit-label>Email</bit-label>
<input bitInput formControlName="email" /> <input bitInput formControlName="email" />
</bit-form-field> </bit-form-field>
<bit-form-field> <bit-form-field>
<bit-label>Country</bit-label> <bit-label>Country</bit-label>
<bit-select formControlName="country"> <bit-select formControlName="country">
<bit-option *ngFor="let country of countries" [value]="country.value" [label]="country.name"></bit-option> <bit-option *ngFor="let country of countries" [value]="country.value" [label]="country.name"></bit-option>
</bit-select> </bit-select>
</bit-form-field> </bit-form-field>
<bit-form-field> <bit-form-field>
<bit-label>Age</bit-label> <bit-label>Age</bit-label>
<input <input
@ -119,13 +119,13 @@ export const FullExample: Story = {
max="150" max="150"
/> />
</bit-form-field> </bit-form-field>
<bit-form-control> <bit-form-control>
<bit-label>Agree to terms</bit-label> <bit-label>Agree to terms</bit-label>
<input type="checkbox" bitCheckbox formControlName="terms"> <input type="checkbox" bitCheckbox formControlName="terms" />
<bit-hint>Required for the service to work properly</bit-hint> <bit-hint>Required for the service to work properly</bit-hint>
</bit-form-control> </bit-form-control>
<bit-radio-group formControlName="updates"> <bit-radio-group formControlName="updates">
<bit-label>Subscribe to updates?</bit-label> <bit-label>Subscribe to updates?</bit-label>
<bit-radio-button value="yes"> <bit-radio-button value="yes">
@ -138,7 +138,7 @@ export const FullExample: Story = {
<bit-label>Decide later</bit-label> <bit-label>Decide later</bit-label>
</bit-radio-button> </bit-radio-button>
</bit-radio-group> </bit-radio-group>
<button type="submit" bitButton buttonType="primary">Submit</button> <button type="submit" bitButton buttonType="primary">Submit</button>
</form> </form>
`, `,

View File

@ -4,6 +4,10 @@ import * as stories from "./icon-button.stories";
<Meta of={stories} /> <Meta of={stories} />
```ts
import { IconButtonModule } from "@bitwarden/components";
```
# Icon Button # Icon Button
Icon buttons are used when no text accompanies the button. It consists of an icon that may be Icon buttons are used when no text accompanies the button. It consists of an icon that may be

View File

@ -4,6 +4,10 @@ import * as stories from "./link.stories";
<Meta of={stories} /> <Meta of={stories} />
```ts
import { LinkModule } from "@bitwarden/components";
```
# Link / Text button # Link / Text button
Text Links and Buttons use the `primary-600` color and can use either the `<a>` or `<button>` tags. Text Links and Buttons use the `primary-600` color and can use either the `<a>` or `<button>` tags.

View File

@ -0,0 +1,20 @@
import { Meta, Canvas, Source, Primary, Controls } from "@storybook/addon-docs";
import * as stories from "./search.stories";
<Meta of={stories} />
```ts
import { SearchModule } from "@bitwarden/components";
```
# Search
<Primary />
<Controls />
## Stories
### Default
<Canvas of={stories.Default} />

View File

@ -0,0 +1,20 @@
import { Meta, Canvas, Source, Primary, Controls } from "@storybook/addon-docs";
import * as stories from "./select.stories";
<Meta of={stories} />
```ts
import { SelectModule } from "@bitwarden/components";
```
# Select
<Primary />
<Controls />
## Stories
### Default
<Canvas of={stories.Default} />

View File

@ -44,7 +44,7 @@ export const Default: Story = {
<ng-template body> <ng-template body>
<tr bitRow [alignContent]="alignRowContent"> <tr bitRow [alignContent]="alignRowContent">
<td bitCell>Cell 1</td> <td bitCell>Cell 1</td>
<td bitCell>Cell 2 <br> Multiline Cell</td> <td bitCell>Cell 2 <br /> Multiline Cell</td>
<td bitCell>Cell 3</td> <td bitCell>Cell 3</td>
</tr> </tr>
<tr bitRow [alignContent]="alignRowContent"> <tr bitRow [alignContent]="alignRowContent">
@ -53,7 +53,7 @@ export const Default: Story = {
<td bitCell>Cell 6</td> <td bitCell>Cell 6</td>
</tr> </tr>
<tr bitRow [alignContent]="alignRowContent"> <tr bitRow [alignContent]="alignRowContent">
<td bitCell>Cell 7 <br> Multiline Cell</td> <td bitCell>Cell 7 <br /> Multiline Cell</td>
<td bitCell>Cell 8</td> <td bitCell>Cell 8</td>
<td bitCell>Cell 9</td> <td bitCell>Cell 9</td>
</tr> </tr>

View File

@ -0,0 +1,30 @@
import { Meta, Canvas, Source, Primary, Controls } from "@storybook/addon-docs";
import * as stories from "./toast.stories";
<Meta of={stories} />
```ts
import { ToastService } from "@bitwarden/components";
```
# Toast
<Primary />
<Controls />
## Stories
### Default
<Canvas of={stories.Default} />
### Long Content
Avoid using long messages in toasts.
<Canvas of={stories.LongContent} />
### Service
<Canvas of={stories.Service} />

View File

@ -4,6 +4,10 @@ import * as stories from "./typography.stories";
<Meta of={stories} /> <Meta of={stories} />
```ts
import { TypographyModule } from "@bitwarden/components";
```
# Typography # Typography
<Primary /> <Primary />