mirror of
https://github.com/bitwarden/browser
synced 2026-01-23 12:53:44 +00:00
[EC-86] Refactor badge-list module/component
- Move the badge list component to its own module. - Extract badge list stories from badge stories. - Cleanup bade stories and module after refactor.
This commit is contained in:
@@ -8,6 +8,7 @@ import { ToastrModule } from "ngx-toastr";
|
||||
|
||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||
import {
|
||||
BadgeListModule,
|
||||
BadgeModule,
|
||||
ButtonModule,
|
||||
CalloutModule,
|
||||
@@ -44,6 +45,7 @@ import "./locales";
|
||||
CalloutModule,
|
||||
ToastrModule,
|
||||
BadgeModule,
|
||||
BadgeListModule,
|
||||
ButtonModule,
|
||||
MenuModule,
|
||||
FormFieldModule,
|
||||
@@ -62,6 +64,7 @@ import "./locales";
|
||||
ReactiveFormsModule,
|
||||
RouterModule,
|
||||
BadgeModule,
|
||||
BadgeListModule,
|
||||
ButtonModule,
|
||||
CalloutModule,
|
||||
ToastrModule,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Component, Input, OnChanges } from "@angular/core";
|
||||
|
||||
import { BadgeTypes } from "./badge.directive";
|
||||
import { BadgeTypes } from "../badge";
|
||||
|
||||
@Component({
|
||||
selector: "bit-badge-list",
|
||||
13
libs/components/src/badge-list/badge-list.module.ts
Normal file
13
libs/components/src/badge-list/badge-list.module.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { NgModule } from "@angular/core";
|
||||
|
||||
import { BadgeModule } from "../badge";
|
||||
import { SharedModule } from "../shared";
|
||||
|
||||
import { BadgeListComponent } from "./badge-list.component";
|
||||
|
||||
@NgModule({
|
||||
imports: [SharedModule, BadgeModule],
|
||||
exports: [BadgeListComponent],
|
||||
declarations: [BadgeListComponent],
|
||||
})
|
||||
export class BadgeListModule {}
|
||||
57
libs/components/src/badge-list/badge-list.stories.ts
Normal file
57
libs/components/src/badge-list/badge-list.stories.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import { Meta, moduleMetadata, Story } from "@storybook/angular";
|
||||
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
|
||||
import { BadgeModule, BadgeTypes } from "../badge";
|
||||
import { SharedModule } from "../shared";
|
||||
import { I18nMockService } from "../utils/i18n-mock.service";
|
||||
|
||||
import { BadgeListComponent } from "./badge-list.component";
|
||||
|
||||
export default {
|
||||
title: "Component Library/Badge/List",
|
||||
decorators: [
|
||||
moduleMetadata({
|
||||
imports: [SharedModule, BadgeModule],
|
||||
declarations: [BadgeListComponent],
|
||||
providers: [
|
||||
{
|
||||
provide: I18nService,
|
||||
useFactory: () => {
|
||||
return new I18nMockService({
|
||||
plusNMore: (n) => `+ ${n} more`,
|
||||
});
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
],
|
||||
args: {
|
||||
badgeType: "primary",
|
||||
},
|
||||
argTypes: {
|
||||
badgeType: {
|
||||
options: ["primary", "secondary", "success", "danger", "warning", "info"] as BadgeTypes[],
|
||||
control: { type: "inline-radio" },
|
||||
},
|
||||
},
|
||||
parameters: {
|
||||
design: {
|
||||
type: "figma",
|
||||
url: "https://www.figma.com/file/f32LSg3jaegICkMu7rPARm/Tailwind-Component-Library-Update?node-id=1881%3A16956",
|
||||
},
|
||||
},
|
||||
} as Meta;
|
||||
|
||||
const ListTemplate: Story<BadgeListComponent> = (args: BadgeListComponent) => ({
|
||||
props: args,
|
||||
template: `
|
||||
<bit-badge-list [badgeType]="badgeType" [maxItems]="maxItems" [items]="items"></bit-badge-list>`,
|
||||
});
|
||||
|
||||
export const Default = ListTemplate.bind({});
|
||||
Default.args = {
|
||||
badgeType: "info",
|
||||
maxItems: 3,
|
||||
items: ["Badge 1", "Badge 2", "Badge 3", "Badge 4", "Badge 5"],
|
||||
};
|
||||
1
libs/components/src/badge-list/index.ts
Normal file
1
libs/components/src/badge-list/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./badge-list.module";
|
||||
@@ -1,13 +1,11 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { NgModule } from "@angular/core";
|
||||
|
||||
import { SharedModule } from "../shared";
|
||||
|
||||
import { BadgeListComponent } from "./badge-list.component";
|
||||
import { BadgeDirective } from "./badge.directive";
|
||||
|
||||
@NgModule({
|
||||
imports: [SharedModule],
|
||||
exports: [BadgeDirective, BadgeListComponent],
|
||||
declarations: [BadgeDirective, BadgeListComponent],
|
||||
imports: [CommonModule],
|
||||
exports: [BadgeDirective],
|
||||
declarations: [BadgeDirective],
|
||||
})
|
||||
export class BadgeModule {}
|
||||
|
||||
@@ -1,29 +1,14 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { Meta, moduleMetadata, Story } from "@storybook/angular";
|
||||
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
|
||||
import { SharedModule } from "../shared";
|
||||
import { I18nMockService } from "../utils/i18n-mock.service";
|
||||
|
||||
import { BadgeListComponent } from "./badge-list.component";
|
||||
import { BadgeDirective, BadgeTypes } from "./badge.directive";
|
||||
|
||||
export default {
|
||||
title: "Component Library/Badge",
|
||||
decorators: [
|
||||
moduleMetadata({
|
||||
imports: [SharedModule],
|
||||
declarations: [BadgeDirective, BadgeListComponent],
|
||||
providers: [
|
||||
{
|
||||
provide: I18nService,
|
||||
useFactory: () => {
|
||||
return new I18nMockService({
|
||||
plusNMore: (n) => `+ ${n} more`,
|
||||
});
|
||||
},
|
||||
},
|
||||
],
|
||||
imports: [CommonModule],
|
||||
declarations: [BadgeDirective],
|
||||
}),
|
||||
],
|
||||
args: {
|
||||
@@ -81,16 +66,3 @@ export const Info = Template.bind({});
|
||||
Info.args = {
|
||||
badgeType: "info",
|
||||
};
|
||||
|
||||
const ListTemplate: Story<BadgeListComponent> = (args: BadgeListComponent) => ({
|
||||
props: args,
|
||||
template: `
|
||||
<bit-badge-list [badgeType]="badgeType" [maxItems]="maxItems" [items]="items"></bit-badge-list>`,
|
||||
});
|
||||
|
||||
export const BadgeList = ListTemplate.bind({});
|
||||
BadgeList.args = {
|
||||
badgeType: "info",
|
||||
maxItems: 3,
|
||||
items: ["Badge 1", "Badge 2", "Badge 3", "Badge 4", "Badge 5"],
|
||||
};
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export { BadgeDirective } from "./badge.directive";
|
||||
export { BadgeDirective, BadgeTypes } from "./badge.directive";
|
||||
export * from "./badge.module";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export * from "./badge";
|
||||
export * from "./badge-list";
|
||||
export * from "./banner";
|
||||
export * from "./button";
|
||||
export * from "./callout";
|
||||
|
||||
Reference in New Issue
Block a user