mirror of
https://github.com/bitwarden/browser
synced 2025-12-13 23:03:32 +00:00
[EC-457] Component library icon buttons (#3372)
* [EC-457] feat: initial version of icon button * [EC-457] feat: modify template and start adding inputs * [EC-457] feat: implement all styles * [EC-457] chore: cleanup * [EC-457] feat: fix hover styles after discussions * [EC-457] feat: add focus ring workaround * [EC-457] chore: refactor stories a bit * [EC-457] fix: button style attr name reserved word collision * [EC-356] feat: match padding with figma * [EC-457] feat: use icon button in banner * [EC-457] chore: cleanup css classes * [EC-457] feat: improve aria * [EC-457] feat: use icon button in dialog * [EC-457] fix: make focus and hover styles independent * [EC-457] fix: remove primary 500 border * [EC-457] chore: cleanup * [EC-457] chore: move css class to common list * [EC-457] fix: use focus-visible * [EC-457] chore: expand on workaround fix * [EC-457] fix: default sizing * [EC-457] fix: align trash icon right * [EC-457] fix: add missing aria labels * [EC-457] fix: add i18n service to banner tests * [EC-457] chore: rename size `default` to `button` * [EC-457] feat: double padding * [EC-457] feat: simplify sizes - update default * [EC-457] fix: revert selector fix - gonna create separate pr * [EC-457] chore: remove superfluous dependencies * [EC-457] fix: remove non-working onClose handler Removing this storybook action because we already test it as part of the dialog service stories. It requries mocking the dialogRef to capture the close function which makes this story more complex but adds very little value as we already test it elsewhere.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { DialogModule as CdkDialogModule } from "@angular/cdk/dialog";
|
||||
import { NgModule } from "@angular/core";
|
||||
|
||||
import { IconButtonModule } from "../icon-button";
|
||||
import { SharedModule } from "../shared";
|
||||
|
||||
import { DialogService } from "./dialog.service";
|
||||
@@ -10,11 +11,11 @@ import { DialogTitleContainerDirective } from "./directives/dialog-title-contain
|
||||
import { SimpleDialogComponent } from "./simple-dialog/simple-dialog.component";
|
||||
|
||||
@NgModule({
|
||||
imports: [SharedModule, CdkDialogModule],
|
||||
imports: [SharedModule, IconButtonModule, CdkDialogModule],
|
||||
declarations: [
|
||||
DialogCloseDirective,
|
||||
DialogComponent,
|
||||
DialogTitleContainerDirective,
|
||||
DialogComponent,
|
||||
SimpleDialogComponent,
|
||||
],
|
||||
exports: [CdkDialogModule, DialogComponent, SimpleDialogComponent],
|
||||
|
||||
@@ -3,19 +3,19 @@
|
||||
class="tw-my-4 tw-flex tw-max-h-screen tw-flex-col tw-overflow-hidden tw-rounded tw-border tw-border-solid tw-border-secondary-300 tw-bg-text-contrast tw-text-main"
|
||||
>
|
||||
<div
|
||||
class="tw-flex tw-gap-4 tw-border-0 tw-border-b tw-border-solid tw-border-secondary-300 tw-p-4"
|
||||
class="tw-flex tw-items-center tw-gap-4 tw-border-0 tw-border-b tw-border-solid tw-border-secondary-300 tw-p-4"
|
||||
>
|
||||
<h1 bitDialogTitleContainer class="tw-mb-0 tw-grow tw-text-lg tw-uppercase">
|
||||
<ng-content select="[bitDialogTitle]"></ng-content>
|
||||
</h1>
|
||||
<button
|
||||
bitIconButton="bwi-close"
|
||||
buttonType="main"
|
||||
size="default"
|
||||
bitDialogClose
|
||||
class="tw-border-0 tw-bg-transparent tw-p-0"
|
||||
title="{{ 'close' | i18n }}"
|
||||
attr.aria-label="{{ 'close' | i18n }}"
|
||||
>
|
||||
<i class="bwi bwi-close tw-text-xs tw-font-bold tw-text-main" aria-hidden="true"></i>
|
||||
</button>
|
||||
[attr.title]="'close' | i18n"
|
||||
[attr.aria-label]="'close' | i18n"
|
||||
></button>
|
||||
</div>
|
||||
|
||||
<div class="tw-overflow-y-auto tw-p-4 tw-pb-8">
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Meta, moduleMetadata, Story } from "@storybook/angular";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
|
||||
import { ButtonModule } from "../../button";
|
||||
import { IconButtonModule } from "../../icon-button";
|
||||
import { SharedModule } from "../../shared";
|
||||
import { I18nMockService } from "../../utils/i18n-mock.service";
|
||||
import { DialogCloseDirective } from "../directives/dialog-close.directive";
|
||||
@@ -15,7 +16,7 @@ export default {
|
||||
component: DialogComponent,
|
||||
decorators: [
|
||||
moduleMetadata({
|
||||
imports: [SharedModule, ButtonModule],
|
||||
imports: [ButtonModule, SharedModule, IconButtonModule],
|
||||
declarations: [DialogTitleContainerDirective, DialogCloseDirective],
|
||||
providers: [
|
||||
{
|
||||
@@ -46,9 +47,16 @@ const Template: Story<DialogComponent> = (args: DialogComponent) => ({
|
||||
<bit-dialog [dialogSize]="dialogSize">
|
||||
<span bitDialogTitle>{{title}}</span>
|
||||
<span bitDialogContent>Dialog body text goes here.</span>
|
||||
<div bitDialogFooter class="tw-flex tw-flex-row tw-gap-2">
|
||||
<div bitDialogFooter class="tw-flex tw-items-center tw-flex-row tw-gap-2">
|
||||
<button bitButton buttonType="primary">Save</button>
|
||||
<button bitButton buttonType="secondary">Cancel</button>
|
||||
<button
|
||||
class="tw-ml-auto"
|
||||
bitIconButton="bwi-trash"
|
||||
buttonType="danger"
|
||||
size="default"
|
||||
title="Delete"
|
||||
aria-label="Delete"></button>
|
||||
</div>
|
||||
</bit-dialog>
|
||||
`,
|
||||
|
||||
@@ -2,7 +2,12 @@ import { DialogModule, DialogRef, DIALOG_DATA } from "@angular/cdk/dialog";
|
||||
import { Component, Inject } from "@angular/core";
|
||||
import { Meta, moduleMetadata, Story } from "@storybook/angular";
|
||||
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
|
||||
import { ButtonModule } from "../button";
|
||||
import { IconButtonModule } from "../icon-button";
|
||||
import { SharedModule } from "../shared/shared.module";
|
||||
import { I18nMockService } from "../utils/i18n-mock.service";
|
||||
|
||||
import { DialogService } from "./dialog.service";
|
||||
import { DialogCloseDirective } from "./directives/dialog-close.directive";
|
||||
@@ -60,13 +65,23 @@ export default {
|
||||
decorators: [
|
||||
moduleMetadata({
|
||||
declarations: [
|
||||
DialogCloseDirective,
|
||||
SimpleDialogComponent,
|
||||
DialogTitleContainerDirective,
|
||||
StoryDialogContentComponent,
|
||||
DialogCloseDirective,
|
||||
DialogTitleContainerDirective,
|
||||
SimpleDialogComponent,
|
||||
],
|
||||
imports: [SharedModule, IconButtonModule, ButtonModule, DialogModule],
|
||||
providers: [
|
||||
DialogService,
|
||||
{
|
||||
provide: I18nService,
|
||||
useFactory: () => {
|
||||
return new I18nMockService({
|
||||
close: "Close",
|
||||
});
|
||||
},
|
||||
},
|
||||
],
|
||||
imports: [ButtonModule, DialogModule],
|
||||
providers: [DialogService],
|
||||
}),
|
||||
],
|
||||
parameters: {
|
||||
|
||||
Reference in New Issue
Block a user