Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

Commit

Permalink
LL-8036 - Infer font weight from LText to UI's Text, mark LTExt as de…
Browse files Browse the repository at this point in the history
…precated (#1990)
  • Loading branch information
nparigi-ledger authored Nov 22, 2021
1 parent 99fafd8 commit 783ae7d
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/components/LText/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import React from "react";
import { Text } from "@ledgerhq/native-ui";
import getFontStyle from "./getFontStyle";
import { FontWeightTypes } from "@ledgerhq/native-ui/components/Text/getTextStyle";

export { getFontStyle };

Expand All @@ -12,6 +13,7 @@ export type Opts = {
monospace?: boolean;
color?: string;
bg?: string;
children?: React.ReactNode;
};

export type Res = {
Expand All @@ -30,9 +32,24 @@ export type Res = {
| "900";
};

export default function LText({ color, children, ...props }: any) {
const inferFontWeight = ({ semiBold, bold }: Opts): FontWeightTypes => {
if (bold) {
return 'bold'
} else if (semiBold) {
return 'semibold'
}
return 'medium'
};

/**
* This component is just a proxy to the Text component defined in @ledgerhq/react-ui.
* It should only be used to map legacy props/logic from LLM to the new text component.
*
* @deprecated Please, prefer using the Text component from our design-system if possible.
*/
export default function LText({ color, children, semiBold, bold, ...props }: Opts) {
return (
<Text {...props} color={color}>
<Text {...props} fontWeight={inferFontWeight({semiBold, bold})} color={color}>
{children}
</Text>
);
Expand Down

0 comments on commit 783ae7d

Please sign in to comment.