@pushwoosh/kit-typography 1.7.3 → 1.7.5
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/ai-documentation.md +243 -0
- package/package.json +2 -2
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
# @pushwoosh/kit-typography - AI Agent Documentation
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
React typography component library for Pushwoosh products. Provides styled-components based typography components with consistent design system.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
```bash
|
|
8
|
+
npm install @pushwoosh/kit-typography
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Core Dependencies
|
|
12
|
+
- **react**: >= 16.14.0 (peer dependency)
|
|
13
|
+
- **styled-components**: >= 5.3.3 (peer dependency)
|
|
14
|
+
- **@pushwoosh/kit-constants**: Typography constants (fonts, sizes, weights, line-heights, colors)
|
|
15
|
+
|
|
16
|
+
## Available Components
|
|
17
|
+
|
|
18
|
+
### Heading Components
|
|
19
|
+
- **H1**: Main page heading (`<h1>`)
|
|
20
|
+
- **H2**: Section heading (`<h2>`)
|
|
21
|
+
- **H3**: Subsection heading (`<h3>`)
|
|
22
|
+
- **H4**: Small heading (`<h4>`)
|
|
23
|
+
- **H5**: Smallest heading (`<h5>`)
|
|
24
|
+
|
|
25
|
+
All heading components accept:
|
|
26
|
+
- `boxRef`: React ref for the HTML element
|
|
27
|
+
- `children`: React.ReactNode
|
|
28
|
+
- All standard HTML heading attributes
|
|
29
|
+
|
|
30
|
+
### Text Components
|
|
31
|
+
|
|
32
|
+
#### Paragraph
|
|
33
|
+
Standard paragraph component (`<p>`)
|
|
34
|
+
```tsx
|
|
35
|
+
import { Paragraph } from '@pushwoosh/kit-typography';
|
|
36
|
+
<Paragraph>Your text content</Paragraph>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
#### Footnote
|
|
40
|
+
Small text for footnotes/captions
|
|
41
|
+
```tsx
|
|
42
|
+
import { Footnote } from '@pushwoosh/kit-typography';
|
|
43
|
+
<Footnote>Small text content</Footnote>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
#### Code
|
|
47
|
+
Monospace text for code snippets (`<code>`)
|
|
48
|
+
```tsx
|
|
49
|
+
import { Code } from '@pushwoosh/kit-typography';
|
|
50
|
+
<Code>console.log('Hello')</Code>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Universal Text Component
|
|
54
|
+
|
|
55
|
+
#### Text
|
|
56
|
+
Flexible styled span component with variant support
|
|
57
|
+
```tsx
|
|
58
|
+
import { Text } from '@pushwoosh/kit-typography';
|
|
59
|
+
|
|
60
|
+
// Basic usage
|
|
61
|
+
<Text>Default text</Text>
|
|
62
|
+
|
|
63
|
+
// With variant
|
|
64
|
+
<Text $variant="h1">Large heading text</Text>
|
|
65
|
+
<Text $variant="footnote">Small text</Text>
|
|
66
|
+
<Text $variant="code">Monospace text</Text>
|
|
67
|
+
|
|
68
|
+
// With props
|
|
69
|
+
<Text $color="#FF0000">Red text</Text>
|
|
70
|
+
<Text $uppercase>UPPERCASE TEXT</Text>
|
|
71
|
+
<Text $ellipsis>Long text with ellipsis...</Text>
|
|
72
|
+
|
|
73
|
+
// Combined
|
|
74
|
+
<Text $variant="h2" $color="#0066CC" $uppercase>BLUE HEADING</Text>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Props:**
|
|
78
|
+
- `$variant`: TypographyVariant - style preset ('standard' | 'footnote' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'code')
|
|
79
|
+
- `$color`: string - custom text color
|
|
80
|
+
- `$uppercase`: boolean - transform text to uppercase
|
|
81
|
+
- `$ellipsis`: boolean - add text overflow ellipsis
|
|
82
|
+
|
|
83
|
+
### Global Styles
|
|
84
|
+
|
|
85
|
+
Apply consistent typography and base styles across the application:
|
|
86
|
+
```tsx
|
|
87
|
+
import { GlobalStyles } from '@pushwoosh/kit-typography';
|
|
88
|
+
|
|
89
|
+
// In your app root
|
|
90
|
+
function App() {
|
|
91
|
+
return (
|
|
92
|
+
<>
|
|
93
|
+
<GlobalStyles />
|
|
94
|
+
{/* Your app components */}
|
|
95
|
+
</>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Sets:
|
|
101
|
+
- Box-sizing: border-box for all elements
|
|
102
|
+
- Body typography: main font, regular size/weight
|
|
103
|
+
- Link styles: primary color with hover effects
|
|
104
|
+
- Focus outline removal on buttons/links
|
|
105
|
+
- Font smoothing for better rendering
|
|
106
|
+
|
|
107
|
+
## Typography Variants
|
|
108
|
+
|
|
109
|
+
Available through `TypographyVariant` type and used in Text component:
|
|
110
|
+
|
|
111
|
+
| Variant | Font Family | Size | Weight | Line Height |
|
|
112
|
+
|---------|------------|------|--------|-------------|
|
|
113
|
+
| standard | MAIN | REGULAR | REGULAR | REGULAR |
|
|
114
|
+
| footnote | MAIN | SMALL | REGULAR | SMALL |
|
|
115
|
+
| h1 | MAIN | HEADING1 | BOLD | HEADING1 |
|
|
116
|
+
| h2 | MAIN | HEADING2 | BOLD | HEADING2 |
|
|
117
|
+
| h3 | MAIN | HEADING3 | BOLD | HEADING3 |
|
|
118
|
+
| h4 | MAIN | HEADING4 | MEDIUM | HEADING4 |
|
|
119
|
+
| h5 | MAIN | HEADING5 | MEDIUM | HEADING5 |
|
|
120
|
+
| code | MONO | REGULAR | REGULAR | REGULAR |
|
|
121
|
+
|
|
122
|
+
## Usage Examples
|
|
123
|
+
|
|
124
|
+
### Complete page structure
|
|
125
|
+
```tsx
|
|
126
|
+
import {
|
|
127
|
+
GlobalStyles,
|
|
128
|
+
H1,
|
|
129
|
+
H2,
|
|
130
|
+
Paragraph,
|
|
131
|
+
Text,
|
|
132
|
+
Code,
|
|
133
|
+
Footnote
|
|
134
|
+
} from '@pushwoosh/kit-typography';
|
|
135
|
+
|
|
136
|
+
function Page() {
|
|
137
|
+
return (
|
|
138
|
+
<>
|
|
139
|
+
<GlobalStyles />
|
|
140
|
+
<H1>Page Title</H1>
|
|
141
|
+
<Paragraph>
|
|
142
|
+
Introduction paragraph with <Text $color="#0066CC">highlighted</Text> text.
|
|
143
|
+
</Paragraph>
|
|
144
|
+
|
|
145
|
+
<H2>Section Title</H2>
|
|
146
|
+
<Paragraph>
|
|
147
|
+
Section content with <Code>inline code</Code> example.
|
|
148
|
+
</Paragraph>
|
|
149
|
+
|
|
150
|
+
<Text $variant="h3" $uppercase>SUBSECTION</Text>
|
|
151
|
+
<Footnote>Note: Additional information</Footnote>
|
|
152
|
+
</>
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Dynamic text styling
|
|
158
|
+
```tsx
|
|
159
|
+
import { Text } from '@pushwoosh/kit-typography';
|
|
160
|
+
|
|
161
|
+
function StatusText({ status, message }) {
|
|
162
|
+
const color = status === 'error' ? '#FF0000' : '#00AA00';
|
|
163
|
+
return (
|
|
164
|
+
<Text
|
|
165
|
+
$color={color}
|
|
166
|
+
$variant={status === 'error' ? 'h4' : 'standard'}
|
|
167
|
+
$uppercase={status === 'error'}
|
|
168
|
+
>
|
|
169
|
+
{message}
|
|
170
|
+
</Text>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Text truncation
|
|
176
|
+
```tsx
|
|
177
|
+
import { Text } from '@pushwoosh/kit-typography';
|
|
178
|
+
|
|
179
|
+
function UserCard({ userName, userEmail }) {
|
|
180
|
+
return (
|
|
181
|
+
<div style={{ width: '200px' }}>
|
|
182
|
+
<Text $variant="h5">{userName}</Text>
|
|
183
|
+
<Text $ellipsis $color="#666">{userEmail}</Text>
|
|
184
|
+
</div>
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Development Scripts
|
|
190
|
+
|
|
191
|
+
- `npm start` / `npm run playground`: Start development playground
|
|
192
|
+
- `npm run build`: Build the library
|
|
193
|
+
- `npm run check`: Run linting and type checking
|
|
194
|
+
- `npm run check:lint`: Run ESLint
|
|
195
|
+
- `npm run check:types`: Check TypeScript types
|
|
196
|
+
|
|
197
|
+
## File Structure
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
src/
|
|
201
|
+
├── index.tsx # Main exports
|
|
202
|
+
├── map.ts # Typography variants configuration
|
|
203
|
+
├── text/
|
|
204
|
+
│ └── Text.ts # Universal Text component
|
|
205
|
+
├── global-styles/ # Global CSS styles
|
|
206
|
+
├── h1-h5/ # Heading components
|
|
207
|
+
├── paragraph/ # Paragraph component
|
|
208
|
+
├── footnote/ # Footnote component
|
|
209
|
+
└── code/ # Code component
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Each component folder contains:
|
|
213
|
+
- `index.tsx`: Component export
|
|
214
|
+
- `[name].component.tsx`: React component
|
|
215
|
+
- `[name].styles.tsx`: Styled-components styles
|
|
216
|
+
- `[name].types.tsx`: TypeScript types
|
|
217
|
+
|
|
218
|
+
## Best Practices
|
|
219
|
+
|
|
220
|
+
1. **Always include GlobalStyles** in your app root for consistent base styling
|
|
221
|
+
2. **Use semantic components** (H1, Paragraph) for better HTML structure
|
|
222
|
+
3. **Use Text component** for inline styling needs and dynamic variants
|
|
223
|
+
4. **Leverage $ellipsis** for text truncation in constrained layouts
|
|
224
|
+
5. **Import from package root**: `import { H1, Text } from '@pushwoosh/kit-typography'`
|
|
225
|
+
6. **Maintain hierarchy**: Use heading levels (H1→H2→H3) in proper order
|
|
226
|
+
|
|
227
|
+
## TypeScript Support
|
|
228
|
+
|
|
229
|
+
Full TypeScript support with exported types:
|
|
230
|
+
- Component props types for all components
|
|
231
|
+
- `TypographyVariant` type for Text component variants
|
|
232
|
+
- Proper HTML element attribute inheritance
|
|
233
|
+
|
|
234
|
+
## Integration with Pushwoosh Design System
|
|
235
|
+
|
|
236
|
+
This library uses `@pushwoosh/kit-constants` for all design tokens:
|
|
237
|
+
- **FontFamily**: MAIN, MONO
|
|
238
|
+
- **FontSize**: SMALL, REGULAR, HEADING1-5
|
|
239
|
+
- **FontWeight**: REGULAR, MEDIUM, BOLD
|
|
240
|
+
- **LineHeight**: SMALL, REGULAR, HEADING1-5
|
|
241
|
+
- **Color**: MAIN, PRIMARY, PRIMARY_HOVER
|
|
242
|
+
|
|
243
|
+
Ensures consistency across all Pushwoosh products.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pushwoosh/kit-typography",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.5",
|
|
4
4
|
"description": "React component for build Pushwoosh products",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"scripts": {
|
|
10
10
|
"start": "npm run playground",
|
|
11
|
-
"build": "pushwoosh-engine lib:build",
|
|
11
|
+
"build": "pushwoosh-engine lib:build && cp ai-documentation.md dist/ai-documentation.md",
|
|
12
12
|
"playground": "pushwoosh-engine lib:playground",
|
|
13
13
|
"check": "npm run check:lint && npm run check:types",
|
|
14
14
|
"check:lint": "echo \"Run check:lint\" && eslint .",
|