zeplin-extension-style-kit
Version:
Models and utilities to generate CSS-like style code in Zeplin extensions.
46 lines (33 loc) • 1 kB
text/typescript
import { StyleDeclaration } from "../common.js";
import { STYLE_PROPS } from "../constants.js";
const WEIGHT_BOLD = 700;
const WEIGHT_NORMAL = 400;
export type FontWeightValue = number | "normal" | "bold" | "lighter" | "bolder";
export class FontWeight implements StyleDeclaration {
private value: FontWeightValue;
constructor(value: FontWeightValue = FontWeight.DEFAULT_VALUE) {
this.value = value;
}
static get DEFAULT_VALUE(): number {
return WEIGHT_NORMAL;
}
get name(): string {
return STYLE_PROPS.FONT_WEIGHT;
}
hasDefaultValue(): boolean {
return this.value === WEIGHT_NORMAL;
}
equals(other: FontWeight): boolean {
return this.value === other.value;
}
getValue(): string | number {
const { value } = this;
if (value === WEIGHT_BOLD) {
return "bold";
}
if (value === WEIGHT_NORMAL) {
return "normal";
}
return value;
}
}