mirror of
https://github.com/bitwarden/browser
synced 2025-12-11 05:43:41 +00:00
[CL-376] add dialog background input (#10237)
This commit is contained in:
@@ -36,7 +36,9 @@
|
|||||||
[ngClass]="{
|
[ngClass]="{
|
||||||
'tw-p-4': !disablePadding,
|
'tw-p-4': !disablePadding,
|
||||||
'tw-overflow-y-auto': !loading,
|
'tw-overflow-y-auto': !loading,
|
||||||
'tw-invisible tw-overflow-y-hidden': loading
|
'tw-invisible tw-overflow-y-hidden': loading,
|
||||||
|
'tw-bg-background': background === 'default',
|
||||||
|
'tw-bg-background-alt': background === 'alt'
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<ng-content select="[bitDialogContent]"></ng-content>
|
<ng-content select="[bitDialogContent]"></ng-content>
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ import { fadeIn } from "../animations";
|
|||||||
animations: [fadeIn],
|
animations: [fadeIn],
|
||||||
})
|
})
|
||||||
export class DialogComponent {
|
export class DialogComponent {
|
||||||
|
/** Background color */
|
||||||
|
@Input()
|
||||||
|
background: "default" | "alt" = "default";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dialog size, more complex dialogs should use large, otherwise default is fine.
|
* Dialog size, more complex dialogs should use large, otherwise default is fine.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,12 +1,19 @@
|
|||||||
|
import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from "@angular/forms";
|
||||||
import { NoopAnimationsModule } from "@angular/platform-browser/animations";
|
import { NoopAnimationsModule } from "@angular/platform-browser/animations";
|
||||||
import { Meta, StoryObj, moduleMetadata } from "@storybook/angular";
|
import { Meta, StoryObj, moduleMetadata } from "@storybook/angular";
|
||||||
|
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
|
|
||||||
|
import { BadgeModule } from "../../badge";
|
||||||
import { ButtonModule } from "../../button";
|
import { ButtonModule } from "../../button";
|
||||||
|
import { CardComponent } from "../../card";
|
||||||
|
import { FormFieldModule } from "../../form-field";
|
||||||
import { IconButtonModule } from "../../icon-button";
|
import { IconButtonModule } from "../../icon-button";
|
||||||
|
import { InputModule } from "../../input";
|
||||||
|
import { SectionComponent, SectionHeaderComponent } from "../../section";
|
||||||
import { SharedModule } from "../../shared";
|
import { SharedModule } from "../../shared";
|
||||||
import { TabsModule } from "../../tabs";
|
import { TabsModule } from "../../tabs";
|
||||||
|
import { TypographyModule } from "../../typography";
|
||||||
import { I18nMockService } from "../../utils/i18n-mock.service";
|
import { I18nMockService } from "../../utils/i18n-mock.service";
|
||||||
import { DialogModule } from "../dialog.module";
|
import { DialogModule } from "../dialog.module";
|
||||||
|
|
||||||
@@ -19,11 +26,20 @@ export default {
|
|||||||
moduleMetadata({
|
moduleMetadata({
|
||||||
imports: [
|
imports: [
|
||||||
DialogModule,
|
DialogModule,
|
||||||
|
BadgeModule,
|
||||||
ButtonModule,
|
ButtonModule,
|
||||||
SharedModule,
|
SharedModule,
|
||||||
IconButtonModule,
|
IconButtonModule,
|
||||||
TabsModule,
|
TabsModule,
|
||||||
NoopAnimationsModule,
|
NoopAnimationsModule,
|
||||||
|
SectionComponent,
|
||||||
|
SectionHeaderComponent,
|
||||||
|
CardComponent,
|
||||||
|
TypographyModule,
|
||||||
|
FormsModule,
|
||||||
|
ReactiveFormsModule,
|
||||||
|
FormFieldModule,
|
||||||
|
InputModule,
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
{
|
{
|
||||||
@@ -31,6 +47,7 @@ export default {
|
|||||||
useFactory: () => {
|
useFactory: () => {
|
||||||
return new I18nMockService({
|
return new I18nMockService({
|
||||||
close: "Close",
|
close: "Close",
|
||||||
|
loading: "Loading",
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -63,6 +80,9 @@ export const Default: Story = {
|
|||||||
props: args,
|
props: args,
|
||||||
template: `
|
template: `
|
||||||
<bit-dialog [dialogSize]="dialogSize" [title]="title" [subtitle]="subtitle" [loading]="loading" [disablePadding]="disablePadding">
|
<bit-dialog [dialogSize]="dialogSize" [title]="title" [subtitle]="subtitle" [loading]="loading" [disablePadding]="disablePadding">
|
||||||
|
<ng-container bitDialogTitle>
|
||||||
|
<span bitBadge variant="success">Foobar</span>
|
||||||
|
</ng-container>
|
||||||
<ng-container bitDialogContent>Dialog body text goes here.</ng-container>
|
<ng-container bitDialogContent>Dialog body text goes here.</ng-container>
|
||||||
<ng-container bitDialogFooter>
|
<ng-container bitDialogFooter>
|
||||||
<button bitButton buttonType="primary" [disabled]="loading">Save</button>
|
<button bitButton buttonType="primary" [disabled]="loading">Save</button>
|
||||||
@@ -173,3 +193,79 @@ export const TabContent: Story = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const WithCards: Story = {
|
||||||
|
render: (args: DialogComponent) => ({
|
||||||
|
props: {
|
||||||
|
formObj: new FormGroup({
|
||||||
|
name: new FormControl(""),
|
||||||
|
}),
|
||||||
|
...args,
|
||||||
|
},
|
||||||
|
template: /*html*/ `
|
||||||
|
<form [formGroup]="formObj">
|
||||||
|
<bit-dialog background="alt" [dialogSize]="dialogSize" [title]="title" [subtitle]="subtitle" [loading]="loading" [disablePadding]="disablePadding">
|
||||||
|
<ng-container bitDialogContent>
|
||||||
|
<bit-section>
|
||||||
|
<bit-section-header>
|
||||||
|
<h2 bitTypography="h6">
|
||||||
|
Foo
|
||||||
|
</h2>
|
||||||
|
<button bitIconButton="bwi-star" size="small" slot="end"></button>
|
||||||
|
</bit-section-header>
|
||||||
|
<bit-card>
|
||||||
|
<bit-form-field>
|
||||||
|
<bit-label>Label</bit-label>
|
||||||
|
<input bitInput formControlName="name" />
|
||||||
|
<bit-hint>Optional Hint</bit-hint>
|
||||||
|
</bit-form-field>
|
||||||
|
<bit-form-field disableMargin>
|
||||||
|
<bit-label>Label</bit-label>
|
||||||
|
<input bitInput formControlName="name" />
|
||||||
|
<bit-hint>Optional Hint</bit-hint>
|
||||||
|
</bit-form-field>
|
||||||
|
</bit-card>
|
||||||
|
</bit-section>
|
||||||
|
<bit-section>
|
||||||
|
<bit-section-header>
|
||||||
|
<h2 bitTypography="h6">
|
||||||
|
Bar
|
||||||
|
</h2>
|
||||||
|
<button bitIconButton="bwi-star" size="small" slot="end"></button>
|
||||||
|
</bit-section-header>
|
||||||
|
<bit-card>
|
||||||
|
<bit-form-field>
|
||||||
|
<bit-label>Label</bit-label>
|
||||||
|
<input bitInput formControlName="name" />
|
||||||
|
<bit-hint>Optional Hint</bit-hint>
|
||||||
|
</bit-form-field>
|
||||||
|
<bit-form-field disableMargin>
|
||||||
|
<bit-label>Label</bit-label>
|
||||||
|
<input bitInput formControlName="name" />
|
||||||
|
<bit-hint>Optional Hint</bit-hint>
|
||||||
|
</bit-form-field>
|
||||||
|
</bit-card>
|
||||||
|
</bit-section>
|
||||||
|
</ng-container>
|
||||||
|
<ng-container bitDialogFooter>
|
||||||
|
<button bitButton buttonType="primary" [disabled]="loading">Save</button>
|
||||||
|
<button bitButton buttonType="secondary" [disabled]="loading">Cancel</button>
|
||||||
|
<button
|
||||||
|
[disabled]="loading"
|
||||||
|
class="tw-ml-auto"
|
||||||
|
bitIconButton="bwi-trash"
|
||||||
|
buttonType="danger"
|
||||||
|
size="default"
|
||||||
|
title="Delete"
|
||||||
|
aria-label="Delete"></button>
|
||||||
|
</ng-container>
|
||||||
|
</bit-dialog>
|
||||||
|
</form>
|
||||||
|
`,
|
||||||
|
}),
|
||||||
|
args: {
|
||||||
|
dialogSize: "default",
|
||||||
|
title: "Default",
|
||||||
|
subtitle: "Subtitle",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user