@synerise/ds-typography 1.1.26 → 1.1.27

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 (3) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/CLAUDE.md +199 -0
  3. package/package.json +5 -4
package/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.1.27](https://github.com/synerise/synerise-design/compare/@synerise/ds-typography@1.1.26...@synerise/ds-typography@1.1.27) (2026-07-23)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-typography
9
+
6
10
  ## [1.1.26](https://github.com/synerise/synerise-design/compare/@synerise/ds-typography@1.1.25...@synerise/ds-typography@1.1.26) (2026-06-17)
7
11
 
8
12
  **Note:** Version bump only for package @synerise/ds-typography
package/CLAUDE.md ADDED
@@ -0,0 +1,199 @@
1
+ # Typography (`@synerise/ds-typography`)
2
+
3
+ > Collection of typography primitives: a custom `Title` (h1–h7), `Text` and `Paragraph` size variants, form-label helpers (`Description`, `ErrorText`, `Label`), an `Ellipsis` wrapper, and a `macro` namespace of reusable styled-components CSS snippets.
4
+
5
+ ## Package structure
6
+
7
+ ```
8
+ src/
9
+ Title.tsx — DS Title component (h1–h7 levels, ellipsis support)
10
+ Title.types.ts — Title Props interface
11
+ Text.tsx — DS Text component (medium/small/xsmall spans) + Ellipsis
12
+ Paragraph.tsx — DS Paragraph component (medium/small/xsmall spans)
13
+ Ellipsis.tsx — Overflow-detection wrapper that shows a tooltip when truncated
14
+ CommonElements.ts — All styled-component primitives (H1–H7, Text variants, Description, ErrorText, Label, EllipsisText)
15
+ Typography.ts — DS-composed default export: `{ Title, Text, Paragraph }` (antd-free)
16
+ index.ts — Public exports
17
+ style/
18
+ macro-utils.ts — CSS snippet exports for use in consumer styled-components
19
+ ```
20
+
21
+ ## Public exports
22
+
23
+ ### `default` (DS-composed `Typography` namespace)
24
+
25
+ A plain object `{ Title, Text, Paragraph }` whose members are the **DS-implemented** components below
26
+ (not antd). It exists so existing `import Typography from '@synerise/ds-typography'` +
27
+ `<Typography.Title>` / `<Typography.Text>` / `<Typography.Paragraph>` call sites keep working without
28
+ antd. antd-only members (`Typography.Link`, `copyable`, `editable`, `code`, `ellipsis`) are **dropped** —
29
+ a repo-wide audit (portal-ui-bridge, portal-next, universal-list) found zero usages.
30
+
31
+ ### `Title`
32
+
33
+ DS-customised heading. Renders `<h1>`–`<h6>` elements (level 7 renders as `<h6>`). Accepts standard
34
+ heading HTML attributes (`HTMLAttributes<HTMLHeadingElement>`) plus the props below.
35
+
36
+ | Prop | Type | Default | Description |
37
+ |------|------|---------|-------------|
38
+ | `level` | `1 \| 2 \| 3 \| 4 \| 5 \| 6 \| 7` | `1` | Heading level. Maps to DS type scale (h700–h100). Level 7 renders as `<h6>`. |
39
+ | `withoutMargin` | `boolean` | `undefined` | Removes the default `margin-bottom` (`0.5em`) from the heading element. |
40
+ | `ellipsis` | `EllipsisProps` | `undefined` | When provided, wraps the title in an `Ellipsis` component. |
41
+ | `className` | `string` | `undefined` | Merged with `'ds-title'`. |
42
+ | `data-*` | `string` | — | Any `data-*` attribute is forwarded onto the heading element (typed via `DataAttributes`). |
43
+ | `...rest` | `HTMLAttributes<HTMLHeadingElement>` | — | All remaining heading attributes pass through (e.g. `style`, `id`). |
44
+
45
+ Type scale mapping:
46
+
47
+ | level | macro | font-size |
48
+ |-------|-------|-----------|
49
+ | 1 | h700 | 24px |
50
+ | 2 | h600 | 21px |
51
+ | 3 | h500 | 18px |
52
+ | 4 | h400 | 16px |
53
+ | 5 | h300 | 14px |
54
+ | 6 | h200 | 13px |
55
+ | 7 | h100 | 10px |
56
+
57
+ ### `Text`
58
+
59
+ Inline text span in three sizes. Renders a styled `<span>`.
60
+
61
+ | Prop | Type | Default | Description |
62
+ |------|------|---------|-------------|
63
+ | `size` | `'medium' \| 'small' \| 'xsmall'` | `'medium'` | Font size variant (14px / 13px / 11px). |
64
+ | `ellipsis` | `EllipsisProps` | `undefined` | When provided, wraps content in `Ellipsis`. |
65
+ | `className` | `string` | `undefined` | Applied to the `Ellipsis` wrapper when `ellipsis` is set; otherwise appended to the span (`'ds-text'`). |
66
+ | `style` | `CSSProperties` | `undefined` | Applied to the `Ellipsis` wrapper when `ellipsis` is set; otherwise applied to the span. |
67
+ | `data-*` | `string` | — | Forwarded onto the outer element — the `Ellipsis` wrapper when `ellipsis` is set, otherwise the span (typed via `DataAttributes`). |
68
+ | `children` | `ReactNode` | — | |
69
+
70
+ > When `ellipsis` is set, `style` / `className` / `data-*` are applied to the outer `Ellipsis`
71
+ > wrapper (so e.g. `style={{ maxWidth }}` still constrains the truncation box) — colocated with where
72
+ > truncation is measured.
73
+
74
+ ### `TextSize`
75
+
76
+ Type alias exported from `Text.tsx`: `'medium' | 'small' | 'xsmall'`.
77
+
78
+ ### `Paragraph`
79
+
80
+ Block text element in three sizes. Renders a styled `<span>` with class `ds-paragraph`.
81
+
82
+ | Prop | Type | Default | Description |
83
+ |------|------|---------|-------------|
84
+ | `size` | `'medium' \| 'small' \| 'xsmall'` | `'medium'` | Font size variant. |
85
+ | `className` | `string` | `undefined` | Merged with `'ds-paragraph'`. |
86
+ | `style` | `CSSProperties` | `undefined` | Applied to the paragraph span. |
87
+ | `data-*` | `string` | — | Any `data-*` attribute is forwarded onto the paragraph span (typed via `DataAttributes`). |
88
+ | `children` | `ReactNode` | — | |
89
+
90
+ > Note: `Paragraph` supports `className` / `style` / `data-*` but (unlike `Text`) has no `ellipsis` prop.
91
+
92
+ ### `Ellipsis`
93
+
94
+ Overflow-detection wrapper that conditionally shows a tooltip when text is truncated.
95
+
96
+ | Prop | Type | Default | Description |
97
+ |------|------|---------|-------------|
98
+ | `tooltip` | `ReactNode` | `undefined` | Tooltip content — only shown when text is actually truncated. |
99
+ | `tooltipProps` | `TooltipProps` | `undefined` | Extra props forwarded to `@synerise/ds-tooltip` — only applied when truncated. |
100
+ | `className` | `string` | `undefined` | Applied to the outer `EllipsisText` div. |
101
+ | `style` | `CSSProperties` | `undefined` | Applied to the outer `EllipsisText` div. |
102
+ | `data-*` | `string` | — | Any `data-*` attribute is forwarded onto the outer `EllipsisText` div (typed via `DataAttributes`). |
103
+ | `children` | `ReactNode` | — | |
104
+
105
+ ### `EllipsisProps`
106
+
107
+ Type exported from `Ellipsis.tsx` (re-exported via `export * from './Text'`).
108
+
109
+ ### `Description`
110
+
111
+ Styled `<div>` for secondary/help text. Props: `disabled?: boolean` (reduces opacity to 0.4). Color: `grey-600`.
112
+
113
+ ### `ErrorText`
114
+
115
+ Styled `<div>` for field error messages. Color: `red-600`, bottom margin 4px. No custom props.
116
+
117
+ ### `Label`
118
+
119
+ Styled `<label>` for form field labels. Color: `grey-800`, font-weight 500, `display: block`, `cursor: pointer`. No custom props.
120
+
121
+ ### `macro`
122
+
123
+ Namespace of reusable styled-components CSS snippets for typography styling in consumer components:
124
+
125
+ | Export | Description |
126
+ |--------|-------------|
127
+ | `h700`–`h100` | Heading scales (font-size, line-height, letter-spacing, grey-800 color) |
128
+ | `medium`, `small`, `xsmall` | Body text scales |
129
+ | `link` | Blue-600 link style with hover |
130
+ | `linkbutton` | Grey link variant |
131
+ | `heading`, `regular` | Base weight/color mixins used by heading/body macros |
132
+ | `tag`, `tooltip`, `xsAvatar`, `xlAvatar`, `xlAvatarIcon` | Specific UI element sizes |
133
+ | `flexCentered` | Flex centering utility |
134
+
135
+ ## Usage patterns
136
+
137
+ ```tsx
138
+ import Typography, { Title, Text, Paragraph, Description, ErrorText, Label, macro } from '@synerise/ds-typography';
139
+
140
+ // DS Title (h1–h7)
141
+ <Title level={4} withoutMargin>Section heading</Title>
142
+
143
+ // DS Title with overflow tooltip
144
+ <Title level={3} ellipsis={{ tooltip: 'Full title text' }}>Long title that may truncate</Title>
145
+
146
+ // DS Text
147
+ <Text size="small">Helper text</Text>
148
+
149
+ // DS Text with ellipsis
150
+ <Text size="medium" ellipsis={{ tooltip: 'Full content' }} style={{ maxWidth: 200 }}>
151
+ Long inline text
152
+ </Text>
153
+
154
+ // DS Paragraph
155
+ <Paragraph size="medium">Body copy</Paragraph>
156
+
157
+ // Form helpers
158
+ <Label htmlFor="field">Field name</Label>
159
+ <Description>Secondary info</Description>
160
+ <Description disabled>Disabled info</Description>
161
+ <ErrorText>Validation error</ErrorText>
162
+
163
+ // Default export namespace — DS Title/Text/Paragraph (antd-free)
164
+ import Typography from '@synerise/ds-typography';
165
+ <Typography.Title level={4}>Heading</Typography.Title>
166
+ <Typography.Text strong>Bold</Typography.Text>
167
+
168
+ // macro — for use inside styled-components definitions
169
+ import styled from 'styled-components';
170
+ import { macro } from '@synerise/ds-typography';
171
+
172
+ const MyHeading = styled.div`
173
+ ${macro.h400};
174
+ `;
175
+ ```
176
+
177
+ ## Styling
178
+
179
+ All styled primitives live in `CommonElements.ts`. Typography tokens come from `macro-utils.ts` (hardcoded scale values using `theme.palette` for colour). No variant prop on styled elements — size is selected by mapping to a different component.
180
+
181
+ `EllipsisText` sets `overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 100%` on a `<div>`, and makes inner heading/text elements `display: inline` or inherit parent styles.
182
+
183
+ ## Key dependencies
184
+
185
+ - `@synerise/ds-tooltip` — used by `Ellipsis` to show the overflow tooltip (regular dependency, not peer)
186
+ - `lodash.debounce` — debounces the `ResizeObserver` callback in `Ellipsis` (100ms, leading + trailing)
187
+ - `classnames` — used in `Title`/`Text` to merge `'ds-title'`/`'ds-text'` with consumer `className`
188
+ - **No antd** — the package is antd-free. The default export is a DS-composed `{ Title, Text, Paragraph }`.
189
+
190
+ ## Implementation notes
191
+
192
+ - **Default export is DS, not antd** — `import Typography from '@synerise/ds-typography'` now gives a DS-composed `{ Title, Text, Paragraph }` namespace (the same DS components as the named exports). antd-only members (`Link`, `copyable`, `editable`, `code`, antd `ellipsis`) were dropped after a repo-wide audit found zero usages.
193
+ - **`Text` `strong`** — `strong` renders the span at `font-weight: 500`. When `ellipsis` is unset, `style` / `className` / `data-*` are applied to the rendered span. When `ellipsis` is set, they are applied to the outer `Ellipsis` wrapper (the `EllipsisText` div that measures truncation), so `style={{ maxWidth }}` keeps constraining the truncation box.
194
+ - **`data-*` forwarding** — `Title`, `Text`, `Paragraph` and `Ellipsis` accept arbitrary `data-*` attributes (typed via the shared `DataAttributes` from `@synerise/ds-utils`) and forward them onto their outer element. For `Title` the heading carries `style`/`data-*` (via `...rest`); for `Text`/`Paragraph` the rendered span, or the `Ellipsis` wrapper when `ellipsis` is set.
195
+ - **`Title` default margin** — headings have `margin-bottom: 0.5em` by default (own styled-component value, no longer reliant on antd's global reset); `withoutMargin` sets it to `0`.
196
+ - **`Title` level 7 renders as `<h6>`** — there is no `<h7>` in HTML. `H7` in `CommonElements.ts` is `styled.h6`. Intentional for the h100 scale.
197
+ - **`Paragraph`** — renders block-level styled spans (`display: block`) in medium/small/xsmall; no `className`/`style`/`ellipsis` support (unlike `Text`).
198
+ - **`Ellipsis` uses `ResizeObserver`** — observes both the text element and `document.body` to detect layout changes. Cleans up observer and debounce on unmount.
199
+ - **Uses Vitest** — `"test": "vitest run"`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-typography",
3
- "version": "1.1.26",
3
+ "version": "1.1.27",
4
4
  "description": "Typography UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "synerise/synerise-design",
@@ -17,6 +17,7 @@
17
17
  "files": [
18
18
  "/dist",
19
19
  "CHANGELOG.md",
20
+ "CLAUDE.md",
20
21
  "README.md",
21
22
  "package.json",
22
23
  "LICENSE.md"
@@ -41,8 +42,8 @@
41
42
  ],
42
43
  "types": "dist/index.d.ts",
43
44
  "dependencies": {
44
- "@synerise/ds-tooltip": "^1.5.3",
45
- "@synerise/ds-utils": "^1.10.1",
45
+ "@synerise/ds-tooltip": "^1.5.4",
46
+ "@synerise/ds-utils": "^1.10.2",
46
47
  "classnames": "^2.5.1",
47
48
  "lodash.debounce": "^4.0.8"
48
49
  },
@@ -55,5 +56,5 @@
55
56
  "styled-components": "^5.3.3",
56
57
  "vitest": "4"
57
58
  },
58
- "gitHead": "d8c64070f58f14e3fb1bfbcbf00d1e3b8fd51eb8"
59
+ "gitHead": "d0a43cc43d8528a36f105aceea52ab470edb71d9"
59
60
  }