From 4d38c7a92a159bc8a1f5674d44cb315d9d32ee91 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Thu, 23 Feb 2023 23:50:38 +0100 Subject: [PATCH] [SM-557] Use bitTypography for headers (#4839) * Use bitTypography * Remove tw-text-xl from menu items --- apps/web/src/app/shared/shared.module.ts | 9 +++-- .../overview/overview.component.html | 4 +-- .../service-accounts-list.component.html | 8 ++--- .../access-selector.component.html | 2 +- .../shared/header.component.html | 4 ++- .../shared/new-menu.component.html | 6 ++-- .../shared/projects-list.component.html | 10 +++--- .../shared/secrets-list.component.html | 16 ++++----- .../src/typography/typography.directive.ts | 33 +++++++++++++++---- 9 files changed, 58 insertions(+), 34 deletions(-) diff --git a/apps/web/src/app/shared/shared.module.ts b/apps/web/src/app/shared/shared.module.ts index 7ac8e3a8e39..27649f12d1b 100644 --- a/apps/web/src/app/shared/shared.module.ts +++ b/apps/web/src/app/shared/shared.module.ts @@ -23,10 +23,11 @@ import { LinkModule, MenuModule, MultiSelectModule, + RadioButtonModule, TableModule, TabsModule, - RadioButtonModule, ToggleGroupModule, + TypographyModule, } from "@bitwarden/components"; // Register the locales for the application @@ -67,10 +68,11 @@ import "./locales"; LinkModule, MenuModule, MultiSelectModule, + RadioButtonModule, TableModule, TabsModule, - RadioButtonModule, ToggleGroupModule, + TypographyModule, // Web specific ], @@ -100,10 +102,11 @@ import "./locales"; LinkModule, MenuModule, MultiSelectModule, + RadioButtonModule, TableModule, TabsModule, - RadioButtonModule, ToggleGroupModule, + TypographyModule, // Web specific ], diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/overview/overview.component.html b/bitwarden_license/bit-web/src/app/secrets-manager/overview/overview.component.html index 2182c9ca44a..1da49ab344e 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/overview/overview.component.html +++ b/bitwarden_license/bit-web/src/app/secrets-manager/overview/overview.component.html @@ -36,7 +36,7 @@
-

{{ "projects" | i18n }}

+

{{ "projects" | i18n }}

-

{{ "secrets" | i18n }}

+

{{ "secrets" | i18n }}

- + @@ -80,11 +80,11 @@ - + {{ "viewServiceAccount" | i18n }}

diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/shared/new-menu.component.html b/bitwarden_license/bit-web/src/app/secrets-manager/shared/new-menu.component.html index 39b9e031a01..528514e678a 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/shared/new-menu.component.html +++ b/bitwarden_license/bit-web/src/app/secrets-manager/shared/new-menu.component.html @@ -10,15 +10,15 @@ diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/shared/projects-list.component.html b/bitwarden_license/bit-web/src/app/secrets-manager/shared/projects-list.component.html index 19fc68fb127..6bf5232152e 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/shared/projects-list.component.html +++ b/bitwarden_license/bit-web/src/app/secrets-manager/shared/projects-list.component.html @@ -56,7 +56,7 @@
- + {{ project.name }} @@ -75,15 +75,15 @@ - + {{ "viewProject" | i18n }} @@ -93,7 +93,7 @@ diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/shared/secrets-list.component.html b/bitwarden_license/bit-web/src/app/secrets-manager/shared/secrets-list.component.html index 34295f2b3b5..96f5dff87fc 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/shared/secrets-list.component.html +++ b/bitwarden_license/bit-web/src/app/secrets-manager/shared/secrets-list.component.html @@ -63,7 +63,7 @@
- + @@ -94,15 +94,15 @@ @@ -125,11 +125,11 @@ diff --git a/libs/components/src/typography/typography.directive.ts b/libs/components/src/typography/typography.directive.ts index 69dfd903afa..f8034fd98fb 100644 --- a/libs/components/src/typography/typography.directive.ts +++ b/libs/components/src/typography/typography.directive.ts @@ -1,26 +1,45 @@ +import { coerceBooleanProperty } from "@angular/cdk/coercion"; 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-mb-2"], - h2: ["tw-text-2xl", "tw-font-semibold", "tw-mb-2"], - h3: ["tw-text-xl", "tw-font-semibold", "tw-mb-2"], - h4: ["tw-text-lg", "tw-font-semibold", "tw-mb-2"], - h5: ["tw-text-base", "tw-font-semibold", "tw-mb-2"], - h6: ["tw-text-sm", "tw-font-semibold", "tw-mb-2"], + h1: ["tw-text-3xl", "tw-font-semibold"], + h2: ["tw-text-2xl", "tw-font-semibold"], + h3: ["tw-text-xl", "tw-font-semibold"], + h4: ["tw-text-lg", "tw-font-semibold"], + h5: ["tw-text-base", "tw-font-semibold"], + h6: ["tw-text-sm", "tw-font-semibold"], body1: ["tw-text-base"], body2: ["tw-text-sm"], helper: ["tw-text-xs"], }; +const margins: Record = { + h1: ["tw-mb-2"], + h2: ["tw-mb-2"], + h3: ["tw-mb-2"], + h4: ["tw-mb-2"], + h5: ["tw-mb-2"], + h6: ["tw-mb-2"], + body1: [], + body2: [], + helper: [], +}; + @Directive({ selector: "[bitTypography]", }) export class TypographyDirective { @Input("bitTypography") bitTypography: TypographyType; + private _margin = true; + @Input() + set noMargin(value: boolean | "") { + this._margin = !coerceBooleanProperty(value); + } + @HostBinding("class") get classList() { - return styles[this.bitTypography]; + return styles[this.bitTypography].concat(this._margin ? margins[this.bitTypography] : []); } }