UI: init label typography
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
@import "./typography-label.css";
|
||||||
@import "./typography-body.css";
|
@import "./typography-body.css";
|
||||||
@import "./typography-title.css";
|
@import "./typography-title.css";
|
||||||
@import "./typography-headline.css";
|
@import "./typography-headline.css";
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
.fnt-label-default {
|
||||||
|
font-size: 0.8125rem;
|
||||||
|
line-height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fnt-label-s {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
line-height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fnt-label-xs {
|
||||||
|
font-size: 0.6875rem;
|
||||||
|
line-height: 100%;
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@ import { Dynamic } from "solid-js/web";
|
|||||||
import cx from "classnames";
|
import cx from "classnames";
|
||||||
import "./css/typography.css";
|
import "./css/typography.css";
|
||||||
|
|
||||||
type Hierarchy = "body" | "title" | "headline";
|
type Hierarchy = "body" | "title" | "headline" | "label";
|
||||||
type Color = "primary" | "secondary" | "tertiary";
|
type Color = "primary" | "secondary" | "tertiary";
|
||||||
type Weight = "normal" | "medium" | "bold";
|
type Weight = "normal" | "medium" | "bold";
|
||||||
type Tag = "span" | "p" | "h1" | "h2" | "h3" | "h4";
|
type Tag = "span" | "p" | "h1" | "h2" | "h3" | "h4";
|
||||||
@@ -16,6 +16,11 @@ const colorMap: Record<Color, string> = {
|
|||||||
|
|
||||||
// type Size = "default" | "xs" | "s" | "m" | "l";
|
// type Size = "default" | "xs" | "s" | "m" | "l";
|
||||||
interface SizeForHierarchy {
|
interface SizeForHierarchy {
|
||||||
|
label: {
|
||||||
|
default: string;
|
||||||
|
xs: string;
|
||||||
|
s: string;
|
||||||
|
};
|
||||||
body: {
|
body: {
|
||||||
default: string;
|
default: string;
|
||||||
xs: string;
|
xs: string;
|
||||||
@@ -57,6 +62,11 @@ const sizeHierarchyMap: SizeForHierarchy = {
|
|||||||
m: cx("fnt-title-m"),
|
m: cx("fnt-title-m"),
|
||||||
l: cx("fnt-title-l"),
|
l: cx("fnt-title-l"),
|
||||||
},
|
},
|
||||||
|
label: {
|
||||||
|
default: cx("fnt-label-default"),
|
||||||
|
s: cx("fnt-label-s"),
|
||||||
|
xs: cx("fnt-label-xs"),
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const weightMap: Record<Weight, string> = {
|
const weightMap: Record<Weight, string> = {
|
||||||
@@ -74,18 +84,20 @@ interface TypographyProps<H extends Hierarchy> {
|
|||||||
inverted?: boolean;
|
inverted?: boolean;
|
||||||
tag?: Tag;
|
tag?: Tag;
|
||||||
class?: string;
|
class?: string;
|
||||||
|
classList?: Record<string, boolean>;
|
||||||
}
|
}
|
||||||
export const Typography = <H extends Hierarchy>(props: TypographyProps<H>) => {
|
export const Typography = <H extends Hierarchy>(props: TypographyProps<H>) => {
|
||||||
return (
|
return (
|
||||||
<Dynamic
|
<Dynamic
|
||||||
component={props.tag || "span"}
|
component={props.tag || "span"}
|
||||||
class={cx(
|
class={cx(
|
||||||
props.class,
|
|
||||||
colorMap[props.color || "primary"],
|
colorMap[props.color || "primary"],
|
||||||
props.inverted && "fnt-clr--inverted",
|
props.inverted && "fnt-clr--inverted",
|
||||||
sizeHierarchyMap[props.hierarchy][props.size] as string,
|
sizeHierarchyMap[props.hierarchy][props.size] as string,
|
||||||
weightMap[props.weight || "normal"],
|
weightMap[props.weight || "normal"],
|
||||||
|
props.class
|
||||||
)}
|
)}
|
||||||
|
classList={props.classList}
|
||||||
>
|
>
|
||||||
{props.children}
|
{props.children}
|
||||||
</Dynamic>
|
</Dynamic>
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ export const typography: Partial<Config["theme"]> = {
|
|||||||
title: ["1.125rem", { lineHeight: "124%" }],
|
title: ["1.125rem", { lineHeight: "124%" }],
|
||||||
"title-m": ["1.25rem", { lineHeight: "124%" }],
|
"title-m": ["1.25rem", { lineHeight: "124%" }],
|
||||||
"title-l": ["1.375rem", { lineHeight: "124%" }],
|
"title-l": ["1.375rem", { lineHeight: "124%" }],
|
||||||
|
label: ["0.8125rem", { lineHeight: "100%" }],
|
||||||
|
"label-s": ["0.75rem", { lineHeight: "100%" }],
|
||||||
|
"label-xs": ["0.6875rem", { lineHeight: "124%" }],
|
||||||
},
|
},
|
||||||
// textColor: {
|
// textColor: {
|
||||||
// ...defaultTheme.textColor,
|
// ...defaultTheme.textColor,
|
||||||
|
|||||||
Reference in New Issue
Block a user