diff --git a/libs/components/src/dialog/dialog.service.stories.ts b/libs/components/src/dialog/dialog.service.stories.ts index b94b61f7c90..e28f0ac4b19 100644 --- a/libs/components/src/dialog/dialog.service.stories.ts +++ b/libs/components/src/dialog/dialog.service.stories.ts @@ -78,6 +78,7 @@ export default { useFactory: () => { return new I18nMockService({ close: "Close", + loading: "Loading", }); }, }, diff --git a/libs/components/src/dialog/dialog/dialog.component.html b/libs/components/src/dialog/dialog/dialog.component.html index e0847283482..9c2bed339ec 100644 --- a/libs/components/src/dialog/dialog/dialog.component.html +++ b/libs/components/src/dialog/dialog/dialog.component.html @@ -1,12 +1,17 @@
-

+

{{ title }} {{ subtitle }} @@ -24,19 +29,25 @@ >

-
+
- +
@@ -44,7 +55,7 @@
diff --git a/libs/components/src/dialog/dialog/dialog.component.ts b/libs/components/src/dialog/dialog/dialog.component.ts index 6d188ab9df6..b44216de7bc 100644 --- a/libs/components/src/dialog/dialog/dialog.component.ts +++ b/libs/components/src/dialog/dialog/dialog.component.ts @@ -9,6 +9,10 @@ import { fadeIn } from "../animations"; animations: [fadeIn], }) export class DialogComponent { + /** Background color */ + @Input() + background: "default" | "alt" = "default"; + /** * Dialog size, more complex dialogs should use large, otherwise default is fine. */ diff --git a/libs/components/src/dialog/dialog/dialog.mdx b/libs/components/src/dialog/dialog/dialog.mdx index f1f7692d4c8..d4b37d202a0 100644 --- a/libs/components/src/dialog/dialog/dialog.mdx +++ b/libs/components/src/dialog/dialog/dialog.mdx @@ -4,6 +4,10 @@ import * as stories from "./dialog.stories"; +```ts +import { DialogModule } from "@bitwarden/components"; +``` + # Dialog Dialogs are used throughout the app to help the user focus on a specific action. Use this dialog @@ -71,3 +75,10 @@ loading state. Use tabs to separate related content within a dialog. + +## Background Color + +The `background` input can be set to `alt` to change the background color. This is useful for +dialogs that contain multiple card sections. + + diff --git a/libs/components/src/dialog/dialog/dialog.stories.ts b/libs/components/src/dialog/dialog/dialog.stories.ts index cada557ecd0..ee377aa930c 100644 --- a/libs/components/src/dialog/dialog/dialog.stories.ts +++ b/libs/components/src/dialog/dialog/dialog.stories.ts @@ -1,12 +1,19 @@ +import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from "@angular/forms"; import { NoopAnimationsModule } from "@angular/platform-browser/animations"; import { Meta, StoryObj, moduleMetadata } from "@storybook/angular"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; +import { BadgeModule } from "../../badge"; import { ButtonModule } from "../../button"; +import { CardComponent } from "../../card"; +import { FormFieldModule } from "../../form-field"; import { IconButtonModule } from "../../icon-button"; +import { InputModule } from "../../input"; +import { SectionComponent, SectionHeaderComponent } from "../../section"; import { SharedModule } from "../../shared"; import { TabsModule } from "../../tabs"; +import { TypographyModule } from "../../typography"; import { I18nMockService } from "../../utils/i18n-mock.service"; import { DialogModule } from "../dialog.module"; @@ -19,11 +26,20 @@ export default { moduleMetadata({ imports: [ DialogModule, + BadgeModule, ButtonModule, SharedModule, IconButtonModule, TabsModule, NoopAnimationsModule, + SectionComponent, + SectionHeaderComponent, + CardComponent, + TypographyModule, + FormsModule, + ReactiveFormsModule, + FormFieldModule, + InputModule, ], providers: [ { @@ -31,6 +47,7 @@ export default { useFactory: () => { return new I18nMockService({ close: "Close", + loading: "Loading", }); }, }, @@ -63,6 +80,9 @@ export const Default: Story = { props: args, template: ` + + Foobar + Dialog body text goes here. @@ -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*/ ` +
+ + + + +

+ Foo +

+ +
+ + + Label + + Optional Hint + + + Label + + Optional Hint + + +
+ + +

+ Bar +

+ +
+ + + Label + + Optional Hint + + + Label + + Optional Hint + + +
+
+ + + + + +
+
+ `, + }), + args: { + dialogSize: "default", + title: "Default", + subtitle: "Subtitle", + }, +}; diff --git a/libs/components/src/dialog/dialogs.mdx b/libs/components/src/dialog/dialogs.mdx index bd6a30d7f20..a42e304c9a4 100644 --- a/libs/components/src/dialog/dialogs.mdx +++ b/libs/components/src/dialog/dialogs.mdx @@ -2,6 +2,10 @@ import { Meta, Story, Source } from "@storybook/addon-docs"; +```ts +import { DialogModule } from "@bitwarden/components"; +``` + # Dialog Dialogs are used throughout the app to help the user focus on a specific action. diff --git a/libs/components/src/dialog/simple-dialog/simple-configurable-dialog/simple-configurable-dialog.service.stories.ts b/libs/components/src/dialog/simple-dialog/simple-configurable-dialog/simple-configurable-dialog.service.stories.ts index 6c2a25c67ca..7b7d46ee96f 100644 --- a/libs/components/src/dialog/simple-dialog/simple-configurable-dialog/simple-configurable-dialog.service.stories.ts +++ b/libs/components/src/dialog/simple-dialog/simple-configurable-dialog/simple-configurable-dialog.service.stories.ts @@ -1,4 +1,5 @@ import { Component } from "@angular/core"; +import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; import { Meta, StoryObj, applicationConfig, moduleMetadata } from "@storybook/angular"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; @@ -144,7 +145,7 @@ export default { component: StoryDialogComponent, decorators: [ moduleMetadata({ - imports: [ButtonModule, DialogModule, CalloutModule], + imports: [ButtonModule, BrowserAnimationsModule, DialogModule, CalloutModule], }), applicationConfig({ providers: [ diff --git a/libs/components/src/dialog/simple-dialog/simple-dialog.component.html b/libs/components/src/dialog/simple-dialog/simple-dialog.component.html index 261c1107954..0b56c6287dc 100644 --- a/libs/components/src/dialog/simple-dialog/simple-dialog.component.html +++ b/libs/components/src/dialog/simple-dialog/simple-dialog.component.html @@ -1,5 +1,5 @@
@@ -9,11 +9,18 @@ -

+

-
+
+```ts +import { DialogModule } from "@bitwarden/components"; +``` + # Simple Dialogs Simple Dialogs are used throughout the app for simple alert or confirmation actions such as diff --git a/libs/components/src/dialog/simple-dialog/simple-dialog.service.stories.ts b/libs/components/src/dialog/simple-dialog/simple-dialog.service.stories.ts index 08ca6f7dee8..665d658f8ee 100644 --- a/libs/components/src/dialog/simple-dialog/simple-dialog.service.stories.ts +++ b/libs/components/src/dialog/simple-dialog/simple-dialog.service.stories.ts @@ -1,5 +1,6 @@ -import { DialogModule, DialogRef, DIALOG_DATA } from "@angular/cdk/dialog"; +import { DialogRef, DIALOG_DATA } from "@angular/cdk/dialog"; import { Component, Inject } from "@angular/core"; +import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; import { Meta, StoryObj, moduleMetadata } from "@storybook/angular"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; @@ -8,11 +9,8 @@ import { ButtonModule } from "../../button"; import { IconButtonModule } from "../../icon-button"; import { SharedModule } from "../../shared/shared.module"; import { I18nMockService } from "../../utils/i18n-mock.service"; +import { DialogModule } from "../dialog.module"; import { DialogService } from "../dialog.service"; -import { DialogCloseDirective } from "../directives/dialog-close.directive"; -import { DialogTitleContainerDirective } from "../directives/dialog-title-container.directive"; - -import { SimpleDialogComponent } from "./simple-dialog.component"; interface Animal { animal: string; @@ -65,13 +63,14 @@ export default { component: StoryDialogComponent, decorators: [ moduleMetadata({ - declarations: [ - StoryDialogContentComponent, - DialogCloseDirective, - DialogTitleContainerDirective, - SimpleDialogComponent, + declarations: [StoryDialogContentComponent], + imports: [ + SharedModule, + IconButtonModule, + ButtonModule, + BrowserAnimationsModule, + DialogModule, ], - imports: [SharedModule, IconButtonModule, ButtonModule, DialogModule], providers: [ DialogService, { diff --git a/libs/components/src/dialog/simple-dialog/simple-dialog.stories.ts b/libs/components/src/dialog/simple-dialog/simple-dialog.stories.ts index 27a82c46109..d7ec8f47d5e 100644 --- a/libs/components/src/dialog/simple-dialog/simple-dialog.stories.ts +++ b/libs/components/src/dialog/simple-dialog/simple-dialog.stories.ts @@ -1,17 +1,17 @@ +import { NoopAnimationsModule } from "@angular/platform-browser/animations"; import { Meta, StoryObj, moduleMetadata } from "@storybook/angular"; import { ButtonModule } from "../../button"; -import { DialogTitleContainerDirective } from "../directives/dialog-title-container.directive"; +import { DialogModule } from "../dialog.module"; -import { IconDirective, SimpleDialogComponent } from "./simple-dialog.component"; +import { SimpleDialogComponent } from "./simple-dialog.component"; export default { title: "Component Library/Dialogs/Simple Dialog", component: SimpleDialogComponent, decorators: [ moduleMetadata({ - imports: [ButtonModule], - declarations: [IconDirective, DialogTitleContainerDirective], + imports: [ButtonModule, NoopAnimationsModule, DialogModule], }), ], parameters: { @@ -82,3 +82,19 @@ export const ScrollingContent: Story = { useDefaultIcon: true, }, }; + +export const TextOverlow: Story = { + render: (args) => ({ + props: args, + template: ` + + Alert Dialogdialogdialogdialogdialogdialogdialogdialogdialogdialogdialogdialogdialog + Message Contentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontent + + + + + + `, + }), +}; diff --git a/libs/components/src/typography/typography.directive.ts b/libs/components/src/typography/typography.directive.ts index 548f61c1735..010e58fe157 100644 --- a/libs/components/src/typography/typography.directive.ts +++ b/libs/components/src/typography/typography.directive.ts @@ -4,15 +4,15 @@ import { Directive, HostBinding, Input } from "@angular/core"; type TypographyType = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "body1" | "body2" | "helper"; const styles: Record = { - h1: ["tw-text-3xl", "tw-font-semibold", "tw-text-headers"], - h2: ["tw-text-2xl", "tw-font-semibold", "tw-text-headers"], - h3: ["tw-text-xl", "tw-font-semibold", "tw-text-headers"], - h4: ["tw-text-lg", "tw-font-semibold", "tw-text-headers"], - h5: ["tw-text-base", "tw-font-bold", "tw-text-headers"], - h6: ["tw-text-sm", "tw-font-bold", "tw-text-headers"], - body1: ["tw-text-base"], - body2: ["tw-text-sm"], - helper: ["tw-text-xs"], + h1: ["!tw-text-3xl", "tw-font-semibold", "tw-text-headers"], + h2: ["!tw-text-2xl", "tw-font-semibold", "tw-text-headers"], + h3: ["!tw-text-xl", "tw-font-semibold", "tw-text-headers"], + h4: ["!tw-text-lg", "tw-font-semibold", "tw-text-headers"], + h5: ["!tw-text-base", "tw-font-bold", "tw-text-headers"], + h6: ["!tw-text-sm", "tw-font-bold", "tw-text-headers"], + body1: ["!tw-text-base"], + body2: ["!tw-text-sm"], + helper: ["!tw-text-xs"], }; const margins: Record = {