diff --git a/libs/components/src/dialog/dialog.service.stories.ts b/libs/components/src/dialog/dialog.service.stories.ts
index e7c5a17c308..790e1b2a63e 100644
--- a/libs/components/src/dialog/dialog.service.stories.ts
+++ b/libs/components/src/dialog/dialog.service.stories.ts
@@ -1,12 +1,17 @@
import { DIALOG_DATA, DialogModule, DialogRef } from "@angular/cdk/dialog";
-import { Component, Inject } from "@angular/core";
-import { Meta, StoryObj, moduleMetadata } from "@storybook/angular";
+import { Component, Inject, input } from "@angular/core";
+import { NoopAnimationsModule } from "@angular/platform-browser/animations";
+import { RouterTestingModule } from "@angular/router/testing";
+import { Meta, StoryObj, applicationConfig, moduleMetadata } from "@storybook/angular";
+import { getAllByRole, userEvent } from "@storybook/test";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { ButtonModule } from "../button";
import { IconButtonModule } from "../icon-button";
+import { LayoutComponent } from "../layout";
import { SharedModule } from "../shared";
+import { positionFixedWrapperDecorator } from "../stories/storybook-decorators";
import { I18nMockService } from "../utils/i18n-mock.service";
import { DialogComponent } from "./dialog/dialog.component";
@@ -19,11 +24,18 @@ interface Animal {
}
@Component({
- template: ``,
+ template: `
+
+
+
+
+ `,
})
class StoryDialogComponent {
constructor(public dialogService: DialogService) {}
+ isDrawer = input(false);
+
openDialog() {
this.dialogService.open(StoryDialogContentComponent, {
data: {
@@ -31,6 +43,14 @@ class StoryDialogComponent {
},
});
}
+
+ openDrawer() {
+ this.dialogService.openDrawer(StoryDialogContentComponent, {
+ data: {
+ animal: "panda",
+ },
+ });
+ }
}
@Component({
@@ -65,25 +85,37 @@ export default {
title: "Component Library/Dialogs/Service",
component: StoryDialogComponent,
decorators: [
+ positionFixedWrapperDecorator(),
moduleMetadata({
declarations: [StoryDialogContentComponent],
imports: [
SharedModule,
ButtonModule,
+ NoopAnimationsModule,
DialogModule,
IconButtonModule,
DialogCloseDirective,
DialogComponent,
DialogTitleContainerDirective,
+ RouterTestingModule,
+ LayoutComponent,
],
+ providers: [DialogService],
+ }),
+ applicationConfig({
providers: [
- DialogService,
{
provide: I18nService,
useFactory: () => {
return new I18nMockService({
close: "Close",
- loading: "Loading",
+ search: "Search",
+ skipToContent: "Skip to content",
+ submenu: "submenu",
+ toggleCollapse: "toggle collapse",
+ toggleSideNavigation: "Toggle side navigation",
+ yes: "Yes",
+ no: "No",
});
},
},
@@ -100,4 +132,20 @@ export default {
type Story = StoryObj;
-export const Default: Story = {};
+export const Default: Story = {
+ play: async (context) => {
+ const canvas = context.canvasElement;
+
+ const button = getAllByRole(canvas, "button")[0];
+ await userEvent.click(button);
+ },
+};
+
+export const Drawer: Story = {
+ play: async (context) => {
+ const canvas = context.canvasElement;
+
+ const button = getAllByRole(canvas, "button")[1];
+ await userEvent.click(button);
+ },
+};
diff --git a/libs/components/src/dialog/dialogs.mdx b/libs/components/src/dialog/dialogs.mdx
index 63df0bfc131..b63f368a5dd 100644
--- a/libs/components/src/dialog/dialogs.mdx
+++ b/libs/components/src/dialog/dialogs.mdx
@@ -22,6 +22,9 @@ For alerts or simple confirmation actions, like speedbumps, use the
Dialogs's should be used sparingly as they do call extra attention to themselves and can be
interruptive if overused.
+For non-blocking, supplementary content, open dialogs as a
+[Drawer](?path=/story/component-library-dialogs-service--drawer).
+
## Placement
Dialogs should be centered vertically and horizontally on screen. Dialogs height should expand to
diff --git a/libs/components/src/drawer/drawer.mdx b/libs/components/src/drawer/drawer.mdx
index 57d618cfe95..bc99fa290d6 100644
--- a/libs/components/src/drawer/drawer.mdx
+++ b/libs/components/src/drawer/drawer.mdx
@@ -12,6 +12,8 @@ import { DrawerComponent } from "@bitwarden/components";
# Drawer
+**Note: `bit-drawer` is deprecated. Use `bit-dialog` and `DialogService.openDrawer(...)` instead.**
+
A drawer is a panel of supplementary content that is adjacent to the page's main content.
diff --git a/libs/components/src/stories/kitchen-sink/kitchen-sink.stories.ts b/libs/components/src/stories/kitchen-sink/kitchen-sink.stories.ts
index 2005a190bd3..3cbddfa9914 100644
--- a/libs/components/src/stories/kitchen-sink/kitchen-sink.stories.ts
+++ b/libs/components/src/stories/kitchen-sink/kitchen-sink.stories.ts
@@ -14,7 +14,6 @@ import {
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
-// import { DialogService } from "../../dialog";
import { LayoutComponent } from "../../layout";
import { I18nMockService } from "../../utils/i18n-mock.service";
import { positionFixedWrapperDecorator } from "../storybook-decorators";