Skip to content

Commit

Permalink
fix: Text not apply default font
Browse files Browse the repository at this point in the history
  • Loading branch information
yyyyaaa committed Oct 25, 2023
1 parent a5b19b7 commit 9d679f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/ui/text/text.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@ import { Sprinkles } from "../../styles/rainbow-sprinkles.css";
export type Variant = "body" | "heading";
export type TextTransform = "ellipsis" | "underline" | "none";

export function getVariantStyles(variant: Variant): Sprinkles {
export function getVariantStyles(
variant: Variant,
customFontFamily?: Sprinkles["fontFamily"]
): Sprinkles {
if (variant === "body") {
return {
fontFamily: "$body",
fontFamily: customFontFamily ?? "$body",
fontSize: "$sm",
fontWeight: "$normal",
lineHeight: "$normal",
};
}

if (variant === "heading") {
return {
fontFamily: "$body",
fontFamily: customFontFamily ?? "$body",
fontSize: "$md",
fontWeight: "$semibold",
lineHeight: "$tall",
Expand Down
3 changes: 1 addition & 2 deletions src/ui/text/text.lite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ export default function Text(props: TextProps) {
{...props.attributes}
{...props.domAttributes}
as={props.as}
{...getVariantStyles(props.variant ?? "body")}
{...getVariantStyles(props.variant ?? "body", props.fontFamily)}
{...getTextTransformStyles({
ellipsis: props.ellipsis,
underline: props.underline,
})}
className={props.className}
color={props.color}
fontFamily={props.fontFamily}
fontSize={props.fontSize}
fontWeight={props.fontWeight}
letterSpacing={props.letterSpacing}
Expand Down

0 comments on commit 9d679f4

Please sign in to comment.