@tipp/ui 0.1.15 → 0.1.16
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.
- package/package.json +1 -1
- package/src/atoms/typo.tsx +25 -21
package/package.json
CHANGED
package/src/atoms/typo.tsx
CHANGED
|
@@ -1,30 +1,34 @@
|
|
|
1
1
|
import type { TextProps as RadixTextProps } from '@radix-ui/themes';
|
|
2
2
|
import { Text as RadixText } from '@radix-ui/themes';
|
|
3
|
-
import React, { useMemo } from 'react';
|
|
3
|
+
import React, { useMemo, forwardRef } from 'react';
|
|
4
4
|
|
|
5
5
|
export type TypoProps = RadixTextProps & {
|
|
6
6
|
variant?: 'body' | 'caption' | 'subtitle';
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const Typo = forwardRef<HTMLSpanElement, TypoProps>(
|
|
10
|
+
(props: TypoProps, ref): React.ReactNode => {
|
|
11
|
+
const { size, variant, children, ...rest } = props;
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
const radixSize = useMemo<RadixTextProps['size']>(() => {
|
|
14
|
+
switch (variant) {
|
|
15
|
+
case 'caption':
|
|
16
|
+
return '1';
|
|
17
|
+
case 'subtitle':
|
|
18
|
+
return '3';
|
|
19
|
+
case 'body':
|
|
20
|
+
return '2';
|
|
21
|
+
default:
|
|
22
|
+
return size;
|
|
23
|
+
}
|
|
24
|
+
}, [size, variant]);
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
26
|
+
return (
|
|
27
|
+
<RadixText {...rest} ref={ref} size={radixSize}>
|
|
28
|
+
{children}
|
|
29
|
+
</RadixText>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
Typo.displayName = 'Typo';
|