@factorialco/f0-react-native 0.26.0 → 0.28.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.
- package/README.md +2 -2
- package/lib/module/components/exports.js +1 -1
- package/lib/module/components/exports.js.map +1 -1
- package/lib/module/components/primitives/F0Text/AnimatedF0Text/AnimatedF0Text.js +2 -0
- package/lib/module/components/primitives/F0Text/AnimatedF0Text/AnimatedF0Text.js.map +1 -0
- package/lib/module/components/primitives/F0Text/AnimatedF0Text/AnimatedF0Text.md +159 -0
- package/lib/module/components/primitives/F0Text/AnimatedF0Text/AnimatedF0Text.types.js +2 -0
- package/lib/module/components/primitives/F0Text/AnimatedF0Text/AnimatedF0Text.types.js.map +1 -0
- package/lib/module/components/primitives/F0Text/AnimatedF0Text/index.js +2 -0
- package/lib/module/components/primitives/F0Text/AnimatedF0Text/index.js.map +1 -0
- package/lib/module/components/primitives/F0Text/F0Text/F0Text.js +2 -0
- package/lib/module/components/primitives/F0Text/F0Text/F0Text.js.map +1 -0
- package/lib/module/components/primitives/F0Text/F0Text/F0Text.md +320 -0
- package/lib/module/components/primitives/F0Text/F0Text/F0Text.styles.js +2 -0
- package/lib/module/components/primitives/F0Text/F0Text/F0Text.styles.js.map +1 -0
- package/lib/module/components/primitives/F0Text/F0Text/F0Text.types.js +2 -0
- package/lib/module/components/primitives/F0Text/F0Text/F0Text.types.js.map +1 -0
- package/lib/module/components/primitives/F0Text/F0Text/index.js +2 -0
- package/lib/module/components/primitives/F0Text/F0Text/index.js.map +1 -0
- package/lib/module/components/primitives/F0Text/index.js +2 -0
- package/lib/module/components/primitives/F0Text/index.js.map +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/lib/utils.js +1 -1
- package/lib/module/lib/utils.js.map +1 -1
- package/lib/module/styles/theme.css +7 -0
- package/lib/typescript/components/exports.d.ts +1 -0
- package/lib/typescript/components/exports.d.ts.map +1 -1
- package/lib/typescript/components/primitives/F0Text/AnimatedF0Text/AnimatedF0Text.d.ts +5 -0
- package/lib/typescript/components/primitives/F0Text/AnimatedF0Text/AnimatedF0Text.d.ts.map +1 -0
- package/lib/typescript/components/primitives/F0Text/AnimatedF0Text/AnimatedF0Text.types.d.ts +45 -0
- package/lib/typescript/components/primitives/F0Text/AnimatedF0Text/AnimatedF0Text.types.d.ts.map +1 -0
- package/lib/typescript/components/primitives/F0Text/AnimatedF0Text/index.d.ts +8 -0
- package/lib/typescript/components/primitives/F0Text/AnimatedF0Text/index.d.ts.map +1 -0
- package/lib/typescript/components/primitives/F0Text/F0Text/F0Text.d.ts +8 -0
- package/lib/typescript/components/primitives/F0Text/F0Text/F0Text.d.ts.map +1 -0
- package/lib/typescript/components/primitives/F0Text/F0Text/F0Text.styles.d.ts +144 -0
- package/lib/typescript/components/primitives/F0Text/F0Text/F0Text.styles.d.ts.map +1 -0
- package/lib/typescript/components/primitives/F0Text/F0Text/F0Text.types.d.ts +86 -0
- package/lib/typescript/components/primitives/F0Text/F0Text/F0Text.types.d.ts.map +1 -0
- package/lib/typescript/components/primitives/F0Text/F0Text/index.d.ts +9 -0
- package/lib/typescript/components/primitives/F0Text/F0Text/index.d.ts.map +1 -0
- package/lib/typescript/components/primitives/F0Text/index.d.ts +12 -0
- package/lib/typescript/components/primitives/F0Text/index.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/lib/utils.d.ts +9 -0
- package/lib/typescript/lib/utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/exports.ts +3 -0
- package/src/components/primitives/F0Text/AnimatedF0Text/AnimatedF0Text.md +159 -0
- package/src/components/primitives/F0Text/AnimatedF0Text/AnimatedF0Text.tsx +72 -0
- package/src/components/primitives/F0Text/AnimatedF0Text/AnimatedF0Text.types.ts +61 -0
- package/src/components/primitives/F0Text/AnimatedF0Text/__tests__/AnimatedF0Text.spec.tsx +131 -0
- package/src/components/primitives/F0Text/AnimatedF0Text/__tests__/__snapshots__/AnimatedF0Text.spec.tsx.snap +144 -0
- package/src/components/primitives/F0Text/AnimatedF0Text/index.ts +8 -0
- package/src/components/primitives/F0Text/F0Text/F0Text.md +320 -0
- package/src/components/primitives/F0Text/F0Text/F0Text.styles.ts +71 -0
- package/src/components/primitives/F0Text/F0Text/F0Text.tsx +76 -0
- package/src/components/primitives/F0Text/F0Text/F0Text.types.ts +134 -0
- package/src/components/primitives/F0Text/F0Text/__tests__/F0Text.spec.tsx +228 -0
- package/src/components/primitives/F0Text/F0Text/__tests__/__snapshots__/F0Text.spec.tsx.snap +325 -0
- package/src/components/primitives/F0Text/F0Text/index.ts +22 -0
- package/src/components/primitives/F0Text/index.ts +26 -0
- package/src/index.ts +1 -1
- package/src/lib/__tests__/utils.spec.ts +48 -0
- package/src/lib/utils.ts +19 -0
- package/src/styles/theme.css +7 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { TextProps as RNTextProps } from "react-native"
|
|
2
|
+
import type { AnimatedProps } from "react-native-reanimated"
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
TextAlign,
|
|
6
|
+
TextColor,
|
|
7
|
+
TextDecoration,
|
|
8
|
+
TextTransform,
|
|
9
|
+
TypographyVariant,
|
|
10
|
+
} from "../F0Text/F0Text.types"
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Props for the AnimatedF0Text component.
|
|
14
|
+
*
|
|
15
|
+
* Combines F0Text semantic typography props with Reanimated animation
|
|
16
|
+
* capabilities (`entering`, `exiting`, `layout`, animated `style`).
|
|
17
|
+
*/
|
|
18
|
+
export interface AnimatedF0TextProps extends Omit<
|
|
19
|
+
AnimatedProps<RNTextProps>,
|
|
20
|
+
"className"
|
|
21
|
+
> {
|
|
22
|
+
/**
|
|
23
|
+
* Semantic typography variant
|
|
24
|
+
* @default "body-sm-default"
|
|
25
|
+
*/
|
|
26
|
+
variant?: TypographyVariant
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Text color from F0 semantic color system
|
|
30
|
+
* @default "default"
|
|
31
|
+
*/
|
|
32
|
+
color?: TextColor
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Text alignment
|
|
36
|
+
* @default "left"
|
|
37
|
+
*/
|
|
38
|
+
align?: TextAlign
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Text decoration
|
|
42
|
+
* @default "none"
|
|
43
|
+
*/
|
|
44
|
+
decoration?: TextDecoration
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Text transform
|
|
48
|
+
* @default "none"
|
|
49
|
+
*/
|
|
50
|
+
transform?: TextTransform
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Maximum number of lines before truncating with ellipsis
|
|
54
|
+
*/
|
|
55
|
+
numberOfLines?: number
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Children content
|
|
59
|
+
*/
|
|
60
|
+
children?: React.ReactNode
|
|
61
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { render } from "@testing-library/react-native"
|
|
2
|
+
import React from "react"
|
|
3
|
+
|
|
4
|
+
import { AnimatedF0Text } from "../AnimatedF0Text"
|
|
5
|
+
|
|
6
|
+
describe("AnimatedF0Text", () => {
|
|
7
|
+
describe("Snapshots", () => {
|
|
8
|
+
it("renders with default variant (body-sm-default)", () => {
|
|
9
|
+
const { toJSON } = render(<AnimatedF0Text>Default text</AnimatedF0Text>)
|
|
10
|
+
expect(toJSON()).toMatchSnapshot()
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
it("renders all typography variants", () => {
|
|
14
|
+
const variants = [
|
|
15
|
+
"heading-xl",
|
|
16
|
+
"heading-lg",
|
|
17
|
+
"heading-md",
|
|
18
|
+
"heading-sm",
|
|
19
|
+
"body-md-default",
|
|
20
|
+
"body-md-medium",
|
|
21
|
+
"body-md-semibold",
|
|
22
|
+
"body-sm-default",
|
|
23
|
+
"body-sm-medium",
|
|
24
|
+
"body-sm-semibold",
|
|
25
|
+
"body-xs-medium",
|
|
26
|
+
] as const
|
|
27
|
+
|
|
28
|
+
variants.forEach((variant) => {
|
|
29
|
+
const { toJSON } = render(
|
|
30
|
+
<AnimatedF0Text variant={variant}>{variant} text</AnimatedF0Text>
|
|
31
|
+
)
|
|
32
|
+
expect(toJSON()).toMatchSnapshot(`variant-${variant}`)
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it("renders with color variants", () => {
|
|
37
|
+
const colors = ["default", "secondary", "accent", "critical"] as const
|
|
38
|
+
|
|
39
|
+
colors.forEach((color) => {
|
|
40
|
+
const { toJSON } = render(
|
|
41
|
+
<AnimatedF0Text color={color}>{color} text</AnimatedF0Text>
|
|
42
|
+
)
|
|
43
|
+
expect(toJSON()).toMatchSnapshot(`color-${color}`)
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
describe("Behavior", () => {
|
|
49
|
+
it("renders children correctly", () => {
|
|
50
|
+
const { getByText } = render(<AnimatedF0Text>Hello World</AnimatedF0Text>)
|
|
51
|
+
expect(getByText("Hello World")).toBeTruthy()
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it("applies correct variant classes", () => {
|
|
55
|
+
const { getByText } = render(
|
|
56
|
+
<AnimatedF0Text variant="heading-xl">XL Heading</AnimatedF0Text>
|
|
57
|
+
)
|
|
58
|
+
const element = getByText("XL Heading")
|
|
59
|
+
expect(element.props.className).toContain("text-[36px]")
|
|
60
|
+
expect(element.props.className).toContain("leading-[40px]")
|
|
61
|
+
expect(element.props.className).toContain("tracking-[-0.2px]")
|
|
62
|
+
expect(element.props.className).toContain("font-semibold")
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it("applies correct color classes", () => {
|
|
66
|
+
const { getByText } = render(
|
|
67
|
+
<AnimatedF0Text color="secondary">Secondary text</AnimatedF0Text>
|
|
68
|
+
)
|
|
69
|
+
const element = getByText("Secondary text")
|
|
70
|
+
expect(element.props.className).toContain("text-f0-foreground-secondary")
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
it("applies correct alignment classes", () => {
|
|
74
|
+
const { getByText } = render(
|
|
75
|
+
<AnimatedF0Text align="center">Centered text</AnimatedF0Text>
|
|
76
|
+
)
|
|
77
|
+
const element = getByText("Centered text")
|
|
78
|
+
expect(element.props.className).toContain("text-center")
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
it("applies decoration classes", () => {
|
|
82
|
+
const { getByText } = render(
|
|
83
|
+
<AnimatedF0Text decoration="underline">Underlined text</AnimatedF0Text>
|
|
84
|
+
)
|
|
85
|
+
const element = getByText("Underlined text")
|
|
86
|
+
expect(element.props.className).toContain("underline")
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
it("applies transform classes", () => {
|
|
90
|
+
const { getByText } = render(
|
|
91
|
+
<AnimatedF0Text transform="uppercase">uppercase text</AnimatedF0Text>
|
|
92
|
+
)
|
|
93
|
+
const element = getByText("uppercase text")
|
|
94
|
+
expect(element.props.className).toContain("uppercase")
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
it("sets numberOfLines prop correctly", () => {
|
|
98
|
+
const { getByText } = render(
|
|
99
|
+
<AnimatedF0Text numberOfLines={3}>Multiline text</AnimatedF0Text>
|
|
100
|
+
)
|
|
101
|
+
const element = getByText("Multiline text")
|
|
102
|
+
expect(element.props.numberOfLines).toBe(3)
|
|
103
|
+
expect(element.props.ellipsizeMode).toBe("tail")
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
it("does not set ellipsizeMode when numberOfLines is not provided", () => {
|
|
107
|
+
const { getByText } = render(<AnimatedF0Text>Normal text</AnimatedF0Text>)
|
|
108
|
+
const element = getByText("Normal text")
|
|
109
|
+
expect(element.props.ellipsizeMode).toBeUndefined()
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
it("accepts style prop for animated styles", () => {
|
|
113
|
+
const animatedStyle = { opacity: 0.5 }
|
|
114
|
+
const { getByText } = render(
|
|
115
|
+
<AnimatedF0Text style={animatedStyle}>Styled text</AnimatedF0Text>
|
|
116
|
+
)
|
|
117
|
+
const element = getByText("Styled text")
|
|
118
|
+
expect(element.props.style).toEqual(animatedStyle)
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
it("forwards additional props", () => {
|
|
122
|
+
const { getByText } = render(
|
|
123
|
+
<AnimatedF0Text testID="test-animated-text">
|
|
124
|
+
Pressable text
|
|
125
|
+
</AnimatedF0Text>
|
|
126
|
+
)
|
|
127
|
+
const element = getByText("Pressable text")
|
|
128
|
+
expect(element.props.testID).toBe("test-animated-text")
|
|
129
|
+
})
|
|
130
|
+
})
|
|
131
|
+
})
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
|
2
|
+
|
|
3
|
+
exports[`AnimatedF0Text Snapshots renders all typography variants: variant-body-md-default 1`] = `
|
|
4
|
+
<Text
|
|
5
|
+
className="text-[16px] leading-[24px] font-normal text-f0-foreground text-left"
|
|
6
|
+
>
|
|
7
|
+
body-md-default
|
|
8
|
+
text
|
|
9
|
+
</Text>
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
exports[`AnimatedF0Text Snapshots renders all typography variants: variant-body-md-medium 1`] = `
|
|
13
|
+
<Text
|
|
14
|
+
className="text-[16px] leading-[24px] font-medium text-f0-foreground text-left"
|
|
15
|
+
>
|
|
16
|
+
body-md-medium
|
|
17
|
+
text
|
|
18
|
+
</Text>
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
exports[`AnimatedF0Text Snapshots renders all typography variants: variant-body-md-semibold 1`] = `
|
|
22
|
+
<Text
|
|
23
|
+
className="text-[16px] leading-[24px] font-semibold text-f0-foreground text-left"
|
|
24
|
+
>
|
|
25
|
+
body-md-semibold
|
|
26
|
+
text
|
|
27
|
+
</Text>
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
exports[`AnimatedF0Text Snapshots renders all typography variants: variant-body-sm-default 1`] = `
|
|
31
|
+
<Text
|
|
32
|
+
className="text-[14px] leading-[20px] font-normal text-f0-foreground text-left"
|
|
33
|
+
>
|
|
34
|
+
body-sm-default
|
|
35
|
+
text
|
|
36
|
+
</Text>
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
exports[`AnimatedF0Text Snapshots renders all typography variants: variant-body-sm-medium 1`] = `
|
|
40
|
+
<Text
|
|
41
|
+
className="text-[14px] leading-[20px] font-medium text-f0-foreground text-left"
|
|
42
|
+
>
|
|
43
|
+
body-sm-medium
|
|
44
|
+
text
|
|
45
|
+
</Text>
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
exports[`AnimatedF0Text Snapshots renders all typography variants: variant-body-sm-semibold 1`] = `
|
|
49
|
+
<Text
|
|
50
|
+
className="text-[14px] leading-[20px] font-semibold text-f0-foreground text-left"
|
|
51
|
+
>
|
|
52
|
+
body-sm-semibold
|
|
53
|
+
text
|
|
54
|
+
</Text>
|
|
55
|
+
`;
|
|
56
|
+
|
|
57
|
+
exports[`AnimatedF0Text Snapshots renders all typography variants: variant-body-xs-medium 1`] = `
|
|
58
|
+
<Text
|
|
59
|
+
className="text-[12px] leading-[16px] font-medium text-f0-foreground text-left"
|
|
60
|
+
>
|
|
61
|
+
body-xs-medium
|
|
62
|
+
text
|
|
63
|
+
</Text>
|
|
64
|
+
`;
|
|
65
|
+
|
|
66
|
+
exports[`AnimatedF0Text Snapshots renders all typography variants: variant-heading-lg 1`] = `
|
|
67
|
+
<Text
|
|
68
|
+
className="text-[24px] leading-[32px] tracking-[-0.2px] font-semibold text-f0-foreground text-left"
|
|
69
|
+
>
|
|
70
|
+
heading-lg
|
|
71
|
+
text
|
|
72
|
+
</Text>
|
|
73
|
+
`;
|
|
74
|
+
|
|
75
|
+
exports[`AnimatedF0Text Snapshots renders all typography variants: variant-heading-md 1`] = `
|
|
76
|
+
<Text
|
|
77
|
+
className="text-[20px] leading-[28px] tracking-[-0.2px] font-semibold text-f0-foreground text-left"
|
|
78
|
+
>
|
|
79
|
+
heading-md
|
|
80
|
+
text
|
|
81
|
+
</Text>
|
|
82
|
+
`;
|
|
83
|
+
|
|
84
|
+
exports[`AnimatedF0Text Snapshots renders all typography variants: variant-heading-sm 1`] = `
|
|
85
|
+
<Text
|
|
86
|
+
className="text-[16px] leading-[24px] font-semibold text-f0-foreground text-left"
|
|
87
|
+
>
|
|
88
|
+
heading-sm
|
|
89
|
+
text
|
|
90
|
+
</Text>
|
|
91
|
+
`;
|
|
92
|
+
|
|
93
|
+
exports[`AnimatedF0Text Snapshots renders all typography variants: variant-heading-xl 1`] = `
|
|
94
|
+
<Text
|
|
95
|
+
className="text-[36px] leading-[40px] tracking-[-0.2px] font-semibold text-f0-foreground text-left"
|
|
96
|
+
>
|
|
97
|
+
heading-xl
|
|
98
|
+
text
|
|
99
|
+
</Text>
|
|
100
|
+
`;
|
|
101
|
+
|
|
102
|
+
exports[`AnimatedF0Text Snapshots renders with color variants: color-accent 1`] = `
|
|
103
|
+
<Text
|
|
104
|
+
className="text-[14px] leading-[20px] font-normal text-f0-foreground-accent text-left"
|
|
105
|
+
>
|
|
106
|
+
accent
|
|
107
|
+
text
|
|
108
|
+
</Text>
|
|
109
|
+
`;
|
|
110
|
+
|
|
111
|
+
exports[`AnimatedF0Text Snapshots renders with color variants: color-critical 1`] = `
|
|
112
|
+
<Text
|
|
113
|
+
className="text-[14px] leading-[20px] font-normal text-f0-foreground-critical text-left"
|
|
114
|
+
>
|
|
115
|
+
critical
|
|
116
|
+
text
|
|
117
|
+
</Text>
|
|
118
|
+
`;
|
|
119
|
+
|
|
120
|
+
exports[`AnimatedF0Text Snapshots renders with color variants: color-default 1`] = `
|
|
121
|
+
<Text
|
|
122
|
+
className="text-[14px] leading-[20px] font-normal text-f0-foreground text-left"
|
|
123
|
+
>
|
|
124
|
+
default
|
|
125
|
+
text
|
|
126
|
+
</Text>
|
|
127
|
+
`;
|
|
128
|
+
|
|
129
|
+
exports[`AnimatedF0Text Snapshots renders with color variants: color-secondary 1`] = `
|
|
130
|
+
<Text
|
|
131
|
+
className="text-[14px] leading-[20px] font-normal text-f0-foreground-secondary text-left"
|
|
132
|
+
>
|
|
133
|
+
secondary
|
|
134
|
+
text
|
|
135
|
+
</Text>
|
|
136
|
+
`;
|
|
137
|
+
|
|
138
|
+
exports[`AnimatedF0Text Snapshots renders with default variant (body-sm-default) 1`] = `
|
|
139
|
+
<Text
|
|
140
|
+
className="text-[14px] leading-[20px] font-normal text-f0-foreground text-left"
|
|
141
|
+
>
|
|
142
|
+
Default text
|
|
143
|
+
</Text>
|
|
144
|
+
`;
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
# F0Text
|
|
2
|
+
|
|
3
|
+
Primitive text component for React Native with semantic typography variants and optimized performance.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Semantic typography variants (heading and body styles)
|
|
8
|
+
- F0 semantic color system integration
|
|
9
|
+
- Inter font family support
|
|
10
|
+
- Type-safe TypeScript API
|
|
11
|
+
- Uniwind (Tailwind) styling
|
|
12
|
+
- Performance optimized with React.memo and useMemo
|
|
13
|
+
- Full accessibility support
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { F0Text } from "@factorialco/f0-react-native"
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
<!-- prettier-ignore -->
|
|
24
|
+
```tsx
|
|
25
|
+
<>
|
|
26
|
+
<F0Text variant="heading-lg">Welcome</F0Text>
|
|
27
|
+
<F0Text variant="body-sm-default" color="secondary">
|
|
28
|
+
Secondary text
|
|
29
|
+
</F0Text>
|
|
30
|
+
<F0Text variant="body-md-medium" align="center">
|
|
31
|
+
Centered text
|
|
32
|
+
</F0Text>
|
|
33
|
+
<F0Text variant="body-sm-default" numberOfLines={2}>
|
|
34
|
+
Truncated text...
|
|
35
|
+
</F0Text>
|
|
36
|
+
</>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## API Reference
|
|
40
|
+
|
|
41
|
+
### Props
|
|
42
|
+
|
|
43
|
+
| Prop | Type | Default | Description |
|
|
44
|
+
| --------------- | ------------------- | ------------------- | ------------------------------------------------------- |
|
|
45
|
+
| `variant` | `TypographyVariant` | `'body-sm-default'` | Typography variant with weight included |
|
|
46
|
+
| `color` | `TextColor` | `'default'` | Text color from F0 semantic color system |
|
|
47
|
+
| `align` | `TextAlign` | `'left'` | Text alignment (left, center, right, justify) |
|
|
48
|
+
| `decoration` | `TextDecoration` | `'none'` | Text decoration (none, underline, line-through) |
|
|
49
|
+
| `transform` | `TextTransform` | `'none'` | Text transform (none, uppercase, lowercase, capitalize) |
|
|
50
|
+
| `numberOfLines` | `number` | `undefined` | Max lines before truncation with ellipsis |
|
|
51
|
+
|
|
52
|
+
All React Native `TextProps` are also supported (onPress, testID, etc.).
|
|
53
|
+
|
|
54
|
+
**Note**: `className` and `style` props are **not available**. Use semantic props for typography. For spacing/layout, wrap F0Text in a View. Both props are filtered at runtime to prevent override via spread.
|
|
55
|
+
|
|
56
|
+
### Typography Variants
|
|
57
|
+
|
|
58
|
+
All variants use **Inter** font family with the weight included in the variant name.
|
|
59
|
+
|
|
60
|
+
#### Heading Variants
|
|
61
|
+
|
|
62
|
+
| Variant | Size | Line Height | Weight | Letter Spacing |
|
|
63
|
+
| ------------ | ---- | ----------- | -------------- | -------------- |
|
|
64
|
+
| `heading-xl` | 36px | 40px | Semibold (600) | -0.2px |
|
|
65
|
+
| `heading-lg` | 24px | 32px | Semibold (600) | -0.2px |
|
|
66
|
+
| `heading-md` | 20px | 28px | Semibold (600) | -0.2px |
|
|
67
|
+
| `heading-sm` | 16px | 24px | Semibold (600) | - |
|
|
68
|
+
|
|
69
|
+
#### Body Variants
|
|
70
|
+
|
|
71
|
+
| Variant | Size | Line Height | Weight | Letter Spacing |
|
|
72
|
+
| ------------------ | ---- | ----------- | -------------- | -------------- |
|
|
73
|
+
| `body-md-default` | 16px | 24px | Regular (400) | - |
|
|
74
|
+
| `body-md-medium` | 16px | 24px | Medium (500) | - |
|
|
75
|
+
| `body-md-semibold` | 16px | 24px | Semibold (600) | - |
|
|
76
|
+
| `body-sm-default` | 14px | 20px | Regular (400) | - |
|
|
77
|
+
| `body-sm-medium` | 14px | 20px | Medium (500) | - |
|
|
78
|
+
| `body-sm-semibold` | 14px | 20px | Semibold (600) | - |
|
|
79
|
+
| `body-xs-medium` | 12px | 16px | Medium (500) | - |
|
|
80
|
+
|
|
81
|
+
### Color Variants
|
|
82
|
+
|
|
83
|
+
| Color | Usage |
|
|
84
|
+
| ------------------- | ---------------------------------- |
|
|
85
|
+
| `default` | Primary text |
|
|
86
|
+
| `secondary` | Secondary information |
|
|
87
|
+
| `tertiary` | Tertiary/subtle text |
|
|
88
|
+
| `inverse` | Text on dark backgrounds |
|
|
89
|
+
| `inverse-secondary` | Secondary text on dark backgrounds |
|
|
90
|
+
| `disabled` | Disabled state text |
|
|
91
|
+
| `accent` | Highlighted/accent text |
|
|
92
|
+
| `critical` | Error messages |
|
|
93
|
+
| `info` | Informational text |
|
|
94
|
+
| `warning` | Warning messages |
|
|
95
|
+
| `positive` | Success messages |
|
|
96
|
+
| `selected` | Selected state text |
|
|
97
|
+
|
|
98
|
+
## Examples
|
|
99
|
+
|
|
100
|
+
### Typography Variants
|
|
101
|
+
|
|
102
|
+
<!-- prettier-ignore -->
|
|
103
|
+
```tsx
|
|
104
|
+
<>
|
|
105
|
+
{/* Headings */}
|
|
106
|
+
<F0Text variant="heading-xl">Extra Large Heading</F0Text>
|
|
107
|
+
<F0Text variant="heading-lg">Large Heading</F0Text>
|
|
108
|
+
<F0Text variant="heading-md">Medium Heading</F0Text>
|
|
109
|
+
<F0Text variant="heading-sm">Small Heading</F0Text>
|
|
110
|
+
|
|
111
|
+
{/* Body with different weights */}
|
|
112
|
+
<F0Text variant="body-md-default">Regular body text</F0Text>
|
|
113
|
+
<F0Text variant="body-md-medium">Medium body text</F0Text>
|
|
114
|
+
<F0Text variant="body-md-semibold">Semibold body text</F0Text>
|
|
115
|
+
|
|
116
|
+
{/* Smaller sizes */}
|
|
117
|
+
<F0Text variant="body-sm-default">Small regular text</F0Text>
|
|
118
|
+
<F0Text variant="body-xs-medium">Extra small medium text</F0Text>
|
|
119
|
+
</>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Colors
|
|
123
|
+
|
|
124
|
+
<!-- prettier-ignore -->
|
|
125
|
+
```tsx
|
|
126
|
+
<>
|
|
127
|
+
<F0Text variant="body-sm-default" color="default">
|
|
128
|
+
Primary text
|
|
129
|
+
</F0Text>
|
|
130
|
+
<F0Text variant="body-sm-default" color="secondary">
|
|
131
|
+
Secondary information
|
|
132
|
+
</F0Text>
|
|
133
|
+
<F0Text variant="body-sm-default" color="critical">
|
|
134
|
+
Error message
|
|
135
|
+
</F0Text>
|
|
136
|
+
<F0Text variant="body-sm-default" color="positive">
|
|
137
|
+
Success message
|
|
138
|
+
</F0Text>
|
|
139
|
+
<F0Text variant="body-sm-default" color="accent">
|
|
140
|
+
Highlighted text
|
|
141
|
+
</F0Text>
|
|
142
|
+
</>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Text Decorations & Transforms
|
|
146
|
+
|
|
147
|
+
<!-- prettier-ignore -->
|
|
148
|
+
```tsx
|
|
149
|
+
<>
|
|
150
|
+
<F0Text variant="body-sm-default" decoration="underline">
|
|
151
|
+
Underlined text
|
|
152
|
+
</F0Text>
|
|
153
|
+
<F0Text variant="body-sm-default" decoration="line-through">
|
|
154
|
+
Strikethrough text
|
|
155
|
+
</F0Text>
|
|
156
|
+
<F0Text variant="body-sm-default" transform="uppercase">
|
|
157
|
+
uppercase text
|
|
158
|
+
</F0Text>
|
|
159
|
+
<F0Text variant="body-sm-default" transform="capitalize">
|
|
160
|
+
capitalize words
|
|
161
|
+
</F0Text>
|
|
162
|
+
</>
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Truncation
|
|
166
|
+
|
|
167
|
+
<!-- prettier-ignore -->
|
|
168
|
+
```tsx
|
|
169
|
+
<>
|
|
170
|
+
<F0Text variant="body-sm-default" numberOfLines={1}>
|
|
171
|
+
This long text will be truncated after one line with an ellipsis...
|
|
172
|
+
</F0Text>
|
|
173
|
+
|
|
174
|
+
<F0Text variant="body-md-default" numberOfLines={3}>
|
|
175
|
+
This text can span up to three lines before being truncated with an ellipsis
|
|
176
|
+
at the end. Perfect for card descriptions or preview text.
|
|
177
|
+
</F0Text>
|
|
178
|
+
</>
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Spacing & Layout
|
|
182
|
+
|
|
183
|
+
F0Text doesn't accept `className` to prevent typography override. Use a View wrapper for spacing:
|
|
184
|
+
|
|
185
|
+
<!-- prettier-ignore -->
|
|
186
|
+
```tsx
|
|
187
|
+
<>
|
|
188
|
+
{/* Spacing with View wrapper */}
|
|
189
|
+
<View className="mt-4 mb-2">
|
|
190
|
+
<F0Text variant="body-sm-default">Text with margin</F0Text>
|
|
191
|
+
</View>
|
|
192
|
+
|
|
193
|
+
{/* Layout with View wrapper */}
|
|
194
|
+
<View className="flex-1">
|
|
195
|
+
<F0Text variant="body-sm-default">Flexible text</F0Text>
|
|
196
|
+
</View>
|
|
197
|
+
|
|
198
|
+
{/* Icon + Text pattern */}
|
|
199
|
+
<View className="flex-row items-center gap-2">
|
|
200
|
+
<F0Icon icon={Check} size="sm" />
|
|
201
|
+
<F0Text variant="body-sm-default">Success message</F0Text>
|
|
202
|
+
</View>
|
|
203
|
+
</>
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Combined Props
|
|
207
|
+
|
|
208
|
+
<!-- prettier-ignore -->
|
|
209
|
+
```tsx
|
|
210
|
+
<F0Text
|
|
211
|
+
variant="heading-md"
|
|
212
|
+
color="accent"
|
|
213
|
+
align="center"
|
|
214
|
+
decoration="underline"
|
|
215
|
+
transform="uppercase"
|
|
216
|
+
>
|
|
217
|
+
Featured Title
|
|
218
|
+
</F0Text>
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Nested Text
|
|
222
|
+
|
|
223
|
+
<!-- prettier-ignore -->
|
|
224
|
+
```tsx
|
|
225
|
+
<F0Text variant="body-sm-default">
|
|
226
|
+
This is regular text with{" "}
|
|
227
|
+
<F0Text variant="body-sm-semibold" color="accent">
|
|
228
|
+
bold accent nested text
|
|
229
|
+
</F0Text>{" "}
|
|
230
|
+
inside.
|
|
231
|
+
</F0Text>
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### Real-world Card Example
|
|
235
|
+
|
|
236
|
+
<!-- prettier-ignore -->
|
|
237
|
+
```tsx
|
|
238
|
+
<View className="rounded-lg bg-f0-background-secondary p-4">
|
|
239
|
+
<View className="mb-2">
|
|
240
|
+
<F0Text variant="heading-sm">Card Title</F0Text>
|
|
241
|
+
</View>
|
|
242
|
+
<F0Text variant="body-sm-default" color="secondary" numberOfLines={2}>
|
|
243
|
+
This is a description that will be truncated after two lines if it's too
|
|
244
|
+
long to fit in the available space.
|
|
245
|
+
</F0Text>
|
|
246
|
+
<View className="mt-2">
|
|
247
|
+
<F0Text variant="body-xs-medium" color="tertiary">
|
|
248
|
+
Last updated 2 hours ago
|
|
249
|
+
</F0Text>
|
|
250
|
+
</View>
|
|
251
|
+
</View>
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## Architecture
|
|
255
|
+
|
|
256
|
+
```
|
|
257
|
+
F0Text/ # Parent folder for text primitives
|
|
258
|
+
├── F0Text/ # Static text component
|
|
259
|
+
│ ├── F0Text.tsx # Main component
|
|
260
|
+
│ ├── F0Text.md # Documentation
|
|
261
|
+
│ ├── F0Text.types.ts # TypeScript types
|
|
262
|
+
│ ├── F0Text.styles.ts # Tailwind variants config
|
|
263
|
+
│ ├── index.ts # Public exports
|
|
264
|
+
│ └── __tests__/
|
|
265
|
+
│ ├── F0Text.spec.tsx
|
|
266
|
+
│ └── __snapshots__/
|
|
267
|
+
├── AnimatedF0Text/ # Animated text component
|
|
268
|
+
│ ├── AnimatedF0Text.tsx
|
|
269
|
+
│ ├── AnimatedF0Text.md
|
|
270
|
+
│ ├── AnimatedF0Text.types.ts
|
|
271
|
+
│ ├── index.ts
|
|
272
|
+
│ └── __tests__/
|
|
273
|
+
│ ├── AnimatedF0Text.spec.tsx
|
|
274
|
+
│ └── __snapshots__/
|
|
275
|
+
└── index.ts # Barrel re-exporting both
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### Font Family
|
|
279
|
+
|
|
280
|
+
F0Text uses **Inter** font family through Tailwind/Uniwind font weight classes:
|
|
281
|
+
|
|
282
|
+
| Tailwind Class | React Native Font Family | Font Weight |
|
|
283
|
+
| --------------- | ------------------------ | ----------- |
|
|
284
|
+
| `font-normal` | Inter-Regular | 400 |
|
|
285
|
+
| `font-medium` | Inter-Medium | 500 |
|
|
286
|
+
| `font-semibold` | Inter-SemiBold | 600 |
|
|
287
|
+
| `font-bold` | Inter-Bold | 700 |
|
|
288
|
+
|
|
289
|
+
## Accessibility
|
|
290
|
+
|
|
291
|
+
- Fully supports React Native `Text` accessibility props
|
|
292
|
+
- Supports `accessibilityRole`, `accessibilityLabel`, `accessibilityHint`, `accessibilityState`, and `accessible`
|
|
293
|
+
- Proper ellipsis and truncation with `numberOfLines`
|
|
294
|
+
- F0 color system helps ensure sufficient contrast; verify with platform accessibility tools
|
|
295
|
+
|
|
296
|
+
## Performance
|
|
297
|
+
|
|
298
|
+
- **React.memo**: Prevents re-renders when props unchanged
|
|
299
|
+
- **useMemo**: Memoizes className computation
|
|
300
|
+
|
|
301
|
+
### Best Practices
|
|
302
|
+
|
|
303
|
+
<!-- prettier-ignore -->
|
|
304
|
+
```tsx
|
|
305
|
+
// ✅ Good: Use appropriate variant
|
|
306
|
+
<F0Text variant="body-md-semibold">Bold text</F0Text>
|
|
307
|
+
|
|
308
|
+
// ❌ Bad: Don't try to override with className (not supported)
|
|
309
|
+
// <F0Text className="font-bold">Text</F0Text>
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
<!-- prettier-ignore -->
|
|
313
|
+
```tsx
|
|
314
|
+
// ✅ Good: Memoized handler
|
|
315
|
+
const handlePress = useCallback(() => {}, [])
|
|
316
|
+
<F0Text onPress={handlePress}>Click</F0Text>
|
|
317
|
+
|
|
318
|
+
// ❌ Bad: Inline function
|
|
319
|
+
<F0Text onPress={() => {}}>Click</F0Text>
|
|
320
|
+
```
|