mirror of
https://github.com/status-im/nimbus-gui.git
synced 2025-02-10 10:26:53 +00:00
fix: update formatted text to work with status
This commit is contained in:
parent
9d7cd4c2c5
commit
e9b4946c73
@ -1,35 +1,27 @@
|
|||||||
import { Text } from 'tamagui'
|
import { Text } from '@status-im/components'
|
||||||
|
|
||||||
export type TextElement = {
|
export type TextElement = {
|
||||||
text: string
|
text: string
|
||||||
bold?: boolean
|
bold?: boolean
|
||||||
italic?: boolean
|
italic?: boolean
|
||||||
|
weight?: 'regular' | 'medium' | 'bold'
|
||||||
}
|
}
|
||||||
|
|
||||||
type FormattedTextProps = {
|
type FormattedTextProps = {
|
||||||
textElements: TextElement[]
|
textElements: TextElement[]
|
||||||
color?: string
|
color?: string
|
||||||
fontSize?: string
|
size: 27 | 19 | 15 | 13 | 11
|
||||||
}
|
}
|
||||||
|
|
||||||
const FormattedText = ({ textElements, color, fontSize }: FormattedTextProps) => {
|
const FormattedText = ({ textElements, color, size }: FormattedTextProps) => {
|
||||||
const calculateStyle = (textElement: TextElement) => {
|
|
||||||
const isBold = textElement.bold ?? false
|
|
||||||
const isItalic = textElement.italic ?? false
|
|
||||||
|
|
||||||
return { fontWeight: isBold ? 'bold' : '', fontStyle: isItalic ? 'italic' : '' }
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Text color={color} fontSize={fontSize}>
|
<>
|
||||||
{textElements.map((textElement, index) => {
|
{textElements.map((textElement, index) => (
|
||||||
return (
|
<Text key={index} size={size} color={color} weight={textElement.weight}>
|
||||||
<span style={calculateStyle(textElement)} key={index}>
|
|
||||||
{textElement.text}
|
{textElement.text}
|
||||||
</span>
|
|
||||||
)
|
|
||||||
})}
|
|
||||||
</Text>
|
</Text>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user