@fvc/typography 3.0.1 → 3.0.2-next-3607140332290efd627f3fac1cb34e4dcb36274e

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.
Files changed (2) hide show
  1. package/README.md +230 -0
  2. package/package.json +14 -2
package/README.md ADDED
@@ -0,0 +1,230 @@
1
+ # @fvc/typography
2
+
3
+ `@fvc/typography` provides text rendering primitives on top of Ant Design's `Typography` component. It extends the Ant Design API with design-system props for font family, size, weight, line height, color, alignment, and underline — all applied via CSS custom properties so they compose cleanly with parent themes. Sub-components cover every common text role: `Title`, `Text`, `Paragraph`, and `Link`.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ bun add @fvc/typography
9
+ ```
10
+
11
+ ## Peer Dependencies
12
+
13
+ The package expects these dependencies to be available in the consuming application:
14
+
15
+ ```bash
16
+ bun add react antd @fvc/utils
17
+ ```
18
+
19
+ ## Import
20
+
21
+ ```tsx
22
+ import { Typography } from '@fvc/typography';
23
+ ```
24
+
25
+ ## Quick Start
26
+
27
+ ```tsx
28
+ import { Typography } from '@fvc/typography';
29
+
30
+ export function Hero() {
31
+ return (
32
+ <>
33
+ <Typography.Title>Welcome</Typography.Title>
34
+ <Typography.Text type="gray">Subtitle text here</Typography.Text>
35
+ </>
36
+ );
37
+ }
38
+ ```
39
+
40
+ ## Common Usage
41
+
42
+ ### Title
43
+
44
+ ```tsx
45
+ <Typography.Title>Page heading</Typography.Title>
46
+ ```
47
+
48
+ ### Text
49
+
50
+ ```tsx
51
+ <Typography.Text>Body copy</Typography.Text>
52
+ ```
53
+
54
+ ### Paragraph
55
+
56
+ ```tsx
57
+ <Typography.Paragraph>
58
+ A longer block of text that wraps across multiple lines.
59
+ </Typography.Paragraph>
60
+ ```
61
+
62
+ ### Link
63
+
64
+ ```tsx
65
+ <Typography.Link href="https://example.com">Visit site</Typography.Link>
66
+ ```
67
+
68
+ ### Font Size and Weight
69
+
70
+ ```tsx
71
+ <Typography.Text size="14" weight="600">
72
+ Semi-bold small text
73
+ </Typography.Text>
74
+ ```
75
+
76
+ ### Type Variants
77
+
78
+ The `type` prop applies a preset colour from the design token palette.
79
+
80
+ ```tsx
81
+ <Typography.Text type="blue">Blue text</Typography.Text>
82
+ <Typography.Text type="gray">Gray text</Typography.Text>
83
+ <Typography.Text type="label">Label text</Typography.Text>
84
+ ```
85
+
86
+ ### Custom Color
87
+
88
+ ```tsx
89
+ <Typography.Text color="#e74c3c">Error message</Typography.Text>
90
+ ```
91
+
92
+ ### Font Family
93
+
94
+ ```tsx
95
+ <Typography.Text font="Montserrat" weight="700">
96
+ Montserrat heading
97
+ </Typography.Text>
98
+ ```
99
+
100
+ ### Line Height
101
+
102
+ ```tsx
103
+ <Typography.Text size="16" lineHeight="24">
104
+ Readable body text
105
+ </Typography.Text>
106
+ ```
107
+
108
+ ### Underline
109
+
110
+ ```tsx
111
+ <Typography.Text underline>Underlined text</Typography.Text>
112
+ ```
113
+
114
+ ### Text Alignment
115
+
116
+ ```tsx
117
+ <Typography.Paragraph align="center">Centered paragraph</Typography.Paragraph>
118
+ ```
119
+
120
+ ## Props
121
+
122
+ All sub-components share a common set of extended props in addition to their respective Ant Design base props.
123
+
124
+ ### Shared Extended Props
125
+
126
+ | Prop | Type | Description |
127
+ | ------------ | --------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------- |
128
+ | `align` | `CSSProperties['textAlign']` | Text alignment. |
129
+ | `color` | `string` | Arbitrary CSS color value. |
130
+ | `font` | `'Roboto' \| 'Montserrat'` | Font family. |
131
+ | `lineHeight` | `'base' \| '12' \| '13' \| '14' \| '16' \| '20' \| '24' \| '32' \| number` | Line height in px or a named token. |
132
+ | `size` | `'12' \| '13' \| '14' \| '16' \| '20' \| '24' \| '32' \| number` | Font size in px. |
133
+ | `type` | `'black' \| 'white' \| 'blue' \| 'gray' \| 'green' \| 'light-gray' \| 'dark-gray' \| 'darker-gray' \| 'label' \| 'bold'` | Preset color variant from the design palette. |
134
+ | `underline` | `boolean` | Adds underline text decoration. |
135
+ | `weight` | `'200' \| '300' \| '400' \| '500' \| '600' \| '700' \| '800' \| '900' \| number` | Font weight. |
136
+ | `testId` | `string` | Maps to `data-testid` on the rendered element. |
137
+
138
+ ### `<Typography.Title>`
139
+
140
+ Extends [Ant Design `TitleProps`](https://ant-design.antgroup.com/components/typography#api) plus the shared props above.
141
+
142
+ ### `<Typography.Text>`
143
+
144
+ Extends [Ant Design `TextProps`](https://ant-design.antgroup.com/components/typography#api) plus the shared props above.
145
+
146
+ ### `<Typography.Paragraph>`
147
+
148
+ Extends [Ant Design `ParagraphProps`](https://ant-design.antgroup.com/components/typography#api) plus the shared props above.
149
+
150
+ ### `<Typography.Link>`
151
+
152
+ Extends [Ant Design `LinkProps`](https://ant-design.antgroup.com/components/typography#api) plus the shared props above.
153
+
154
+ ## TypeScript
155
+
156
+ The package ships with type definitions. No `@types/` install needed.
157
+
158
+ ```ts
159
+ import type {
160
+ TypographyProps,
161
+ TextProps,
162
+ TitleProps,
163
+ ParagraphProps,
164
+ LinkProps,
165
+ } from '@fvc/typography/types';
166
+ ```
167
+
168
+ ## Consumer Example
169
+
170
+ ```tsx
171
+ import { Typography } from '@fvc/typography';
172
+
173
+ export function ArticlePreview({ title, summary, authorUrl, authorName }) {
174
+ return (
175
+ <article>
176
+ <Typography.Title size="24" weight="700">
177
+ {title}
178
+ </Typography.Title>
179
+ <Typography.Paragraph type="gray" size="14" lineHeight="20">
180
+ {summary}
181
+ </Typography.Paragraph>
182
+ <Typography.Link href={authorUrl} font="Montserrat" weight="500">
183
+ {authorName}
184
+ </Typography.Link>
185
+ </article>
186
+ );
187
+ }
188
+ ```
189
+
190
+ ## Testing
191
+
192
+ ```tsx
193
+ <Typography.Text testId="username-label">John Doe</Typography.Text>
194
+ ```
195
+
196
+ ```tsx
197
+ screen.getByTestId('username-label');
198
+ ```
199
+
200
+ ## CSS Customisation
201
+
202
+ The component reads the following CSS custom properties from the `@fvc` design token palette. These tokens are provided by `@fvc/utils` — no manual `:root` definition is needed unless you want to override the defaults.
203
+
204
+ | Token | Used for |
205
+ | ------------------------------ | ---------------------------------- |
206
+ | `--body-text-color-1000` | Default text color |
207
+ | `--link-on-light-bg-color-500` | Default link color |
208
+ | `--text-color` | Per-element color override |
209
+ | `--text-fz` | Per-element font size override |
210
+ | `--text-fw` | Per-element font weight override |
211
+ | `--text-lh` | Per-element line height override |
212
+ | `--text-ff` | Per-element font family override |
213
+
214
+ To override, set them in your global styles:
215
+
216
+ ```css
217
+ :root {
218
+ --body-text-color-1000: #1a1a1a;
219
+ --link-on-light-bg-color-500: #2563eb;
220
+ }
221
+ ```
222
+
223
+ ## Development
224
+
225
+ ```bash
226
+ bun run lint
227
+ bun run type-check
228
+ bun run test
229
+ bun run build
230
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fvc/typography",
3
- "version": "3.0.1",
3
+ "version": "3.0.2-next-3607140332290efd627f3fac1cb34e4dcb36274e",
4
4
  "main": "./dist/lib/index.js",
5
5
  "types": "./dist/lib/typography/src/index.d.ts",
6
6
  "files": [
@@ -26,8 +26,20 @@
26
26
  "type-check": "tsc --noEmit",
27
27
  "test": "bun test --preload ../../tests/happydom.ts --preload ../../tests/testing-library.tsx"
28
28
  },
29
+ "keywords": [
30
+ "react",
31
+ "react-component",
32
+ "fvc",
33
+ "fe-vis-core",
34
+ "ui",
35
+ "typography",
36
+ "text",
37
+ "font",
38
+ "design-system",
39
+ "antd"
40
+ ],
29
41
  "peerDependencies": {
30
- "@fvc/utils": "^3.0.1",
42
+ "@fvc/utils": "3.0.2-next-3607140332290efd627f3fac1cb34e4dcb36274e",
31
43
  "react": "^18.0.0",
32
44
  "antd": "^5.0.0"
33
45
  }