@telus-uds/components-base 1.24.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -60,6 +60,7 @@ const Typography = forwardRef(
60
60
  const viewport = useViewport()
61
61
  const themeTokens = useThemeTokens('Typography', tokens, variant, { viewport })
62
62
  const { themeOptions } = useTheme()
63
+
63
64
  const resolvedTextProps = {
64
65
  ...selectTextProps(rest),
65
66
  style: selectTextStyles(
@@ -76,13 +77,36 @@ const Typography = forwardRef(
76
77
  ...selectContainerProps(rest)
77
78
  }
78
79
 
80
+ const resetTagStyling = (child) => {
81
+ if (typeof child === 'object' && (child?.type === 'sub' || child?.type === 'sup')) {
82
+ const sanitizedChild = React.cloneElement(child, {
83
+ style: {
84
+ ...child?.props?.style,
85
+ lineHeight: 0
86
+ }
87
+ })
88
+
89
+ return sanitizedChild
90
+ }
91
+
92
+ return child
93
+ }
94
+
95
+ const sanitizeChildren = () => {
96
+ if (Array.isArray(children)) {
97
+ return children.map(resetTagStyling)
98
+ }
99
+
100
+ return resetTagStyling(children)
101
+ }
102
+
79
103
  return block ? (
80
104
  <View ref={ref} {...containerProps}>
81
- <Text {...resolvedTextProps}>{children}</Text>
105
+ <Text {...resolvedTextProps}>{sanitizeChildren(children)}</Text>
82
106
  </View>
83
107
  ) : (
84
108
  <Text ref={ref} {...containerProps} {...resolvedTextProps}>
85
- {children}
109
+ {sanitizeChildren(children)}
86
110
  </Text>
87
111
  )
88
112
  }