mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 16:23:44 +00:00
[CL-41] Typography directive (#3741)
This commit is contained in:
26
libs/components/src/typography/typography.directive.ts
Normal file
26
libs/components/src/typography/typography.directive.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Directive, HostBinding, Input } from "@angular/core";
|
||||
|
||||
type TypographyType = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "body1" | "body2" | "helper";
|
||||
|
||||
const styles: Record<TypographyType, string[]> = {
|
||||
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"],
|
||||
body1: ["tw-text-base"],
|
||||
body2: ["tw-text-sm"],
|
||||
helper: ["tw-text-xs"],
|
||||
};
|
||||
|
||||
@Directive({
|
||||
selector: "[bitTypography]",
|
||||
})
|
||||
export class TypographyDirective {
|
||||
@Input("bitTypography") bitTypography: TypographyType;
|
||||
|
||||
@HostBinding("class") get classList() {
|
||||
return styles[this.bitTypography];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user