diff --git a/src/components/FormattedText/FormattedText.jsx b/src/components/FormattedText/FormattedText.jsx deleted file mode 100644 index c3463616..00000000 --- a/src/components/FormattedText/FormattedText.jsx +++ /dev/null @@ -1,27 +0,0 @@ -import { Text } from "tamagui"; - -const FormattedText = ({ textElements, color, fontSize }) => { - return ( - - {textElements.map((textElement, index) => { - if (textElement.bold) { - return ( - - {textElement.bold} - - ); - } - if (textElement.italic) { - return ( - - {textElement.italic} - - ); - } - return {textElement.text}; - })} - - ); -}; - -export { FormattedText }; diff --git a/src/components/FormattedText/FormattedText.tsx b/src/components/FormattedText/FormattedText.tsx new file mode 100644 index 00000000..e43c5d8f --- /dev/null +++ b/src/components/FormattedText/FormattedText.tsx @@ -0,0 +1,36 @@ +import { Text } from 'tamagui' + +type TextElement = { + text: string + bold?: boolean + italic?: boolean +} + +type FormattedTextProps = { + textElements: TextElement[] + color?: string + fontSize?: string +} + +const FormattedText = ({ textElements, color, fontSize }: FormattedTextProps) => { + const calculateStyle = (textElement: TextElement) => { + const isBold = textElement.bold ?? false + const isItalic = textElement.italic ?? false + + return { fontWeight: isBold ? 'bold' : '', fontStyle: isItalic ? 'italic' : '' } + } + + return ( + + {textElements.map((textElement, index) => { + return ( + + {textElement.text} + + ) + })} + + ) +} + +export { FormattedText } diff --git a/src/components/FormattedText/index.jsx b/src/components/FormattedText/index.tsx similarity index 100% rename from src/components/FormattedText/index.jsx rename to src/components/FormattedText/index.tsx