@synerise/ds-badge 1.0.57 → 1.0.58
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/CHANGELOG.md +4 -0
- package/CLAUDE.md +138 -0
- package/package.json +6 -5
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.0.58](https://github.com/Synerise/synerise-design/compare/@synerise/ds-badge@1.0.57...@synerise/ds-badge@1.0.58) (2026-07-23)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-badge
|
|
9
|
+
|
|
6
10
|
## [1.0.57](https://github.com/Synerise/synerise-design/compare/@synerise/ds-badge@1.0.56...@synerise/ds-badge@1.0.57) (2026-06-17)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @synerise/ds-badge
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# Badge (`@synerise/ds-badge`)
|
|
2
|
+
|
|
3
|
+
> DS-native badge (status dot, flag/pulsing dot, count badge). **antd-free** — exposes `ds-badge*`
|
|
4
|
+
> DOM/class hooks so downstream styled-overrides (e.g. ds-avatar) keep working. The legacy
|
|
5
|
+
> `ant-badge*` hooks have been dropped (so a parent app on the old antd-based badge can't leak its
|
|
6
|
+
> global `.ant-badge*` styles onto this one). Colour is driven by `status` (or `customColor`); there
|
|
7
|
+
> is no antd dependency.
|
|
8
|
+
|
|
9
|
+
## Package structure
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
src/
|
|
13
|
+
Badge.tsx — public entry: `text` → BadgeWithLabel, otherwise BadgeCore
|
|
14
|
+
BadgeCore.tsx — dot/count renderer (derives dot/count mode, renders the styled-components tree)
|
|
15
|
+
Badge.styles.tsx — styled-components (Wrapper, CountSup, ScrollNumberOnly, Current, DotSup, CustomCountSup) + colour helpers
|
|
16
|
+
Badge.types.ts — BadgeProps, Color, ColorHue, Status
|
|
17
|
+
BadgeWithLabel.tsx — status dot aligned next to a text label (powers the `text` prop; also exported)
|
|
18
|
+
BadgeWithLabel.styles.ts — inline-flex alignment for dot↔label
|
|
19
|
+
Badge.figma.tsx — Code Connect mappings (status-driven)
|
|
20
|
+
index.ts — public exports
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
> No `style/` LESS folder — the antd badge LESS base was inlined into `Badge.styles.tsx`. Styling uses
|
|
24
|
+
> first-class styled-components with transient `$`-props; the elements carry `ds-badge-*` class names
|
|
25
|
+
> (for DS consumers / ui-tests / external CSS) but they are not used as styling selectors.
|
|
26
|
+
|
|
27
|
+
## Public exports
|
|
28
|
+
|
|
29
|
+
### `Badge` (default)
|
|
30
|
+
|
|
31
|
+
| Prop | Type | Default | Description |
|
|
32
|
+
|------|------|---------|-------------|
|
|
33
|
+
| `status` | `BadgeStatus` | `undefined` | DS status — drives the dot/count colour: `active`→green-600, `inactive`→grey-400, `blocked`→red-600, `processing`→blue-600, `warning`→yellow-600. Auto-enables dot mode. |
|
|
34
|
+
| `flag` | `boolean` | `undefined` | Renders the dot with `::before`/`::after` halos. Requires dot/status. |
|
|
35
|
+
| `pulsing` | `boolean` | `undefined` | Pulse animation on the halos. Only visible when `flag` or `status` is set. |
|
|
36
|
+
| `outlined` | `boolean` | `undefined` | White `box-shadow` ring around the count badge. |
|
|
37
|
+
| `customColor` | `LiteralStringUnion<BadgeColor \| DefaultColor>` | `undefined` | Overrides the badge colour. Palette token → resolved via `theme.palette` (`'blue'` → `blue-600`, or full key `'blue-600'`); any other value is used as a **raw CSS colour** (`'#FF0000'`, `'rgb(…)'`, …), so colours outside the palette work. |
|
|
38
|
+
| `count` | `ReactNode` | `undefined` | Number/node in the count badge. Hidden when `0`. |
|
|
39
|
+
| `dot` | `boolean` | `undefined` | Forces dot mode (auto-enabled by `status`). |
|
|
40
|
+
| `overflowCount` | `number` | `99` | Max number before `N+`. |
|
|
41
|
+
| `offset` | `[number\|string, number\|string]` | `undefined` | `[x, y]` offset of the badge relative to its children. |
|
|
42
|
+
| `children` | `ReactNode` | `undefined` | When omitted, the badge renders inline (standalone). |
|
|
43
|
+
| `text` | `ReactNode` | `undefined` | When set, renders a status/dot badge next to this label (delegates to `BadgeWithLabel`) — the legacy antd `status` + `text` API. Takes precedence over `count`/`children`; only `status`/`customColor`/`flag`/`pulsing`/`dot`/`className`/`style` apply in this mode. |
|
|
44
|
+
| `className`, `style` | — | — | Applied to the outer wrapper. |
|
|
45
|
+
| `data-*`, `aria-*` | — | — | Forwarded to the outermost wrapper (`PassthroughAttributes` from `@synerise/ds-utils`). |
|
|
46
|
+
|
|
47
|
+
### `BadgeWithLabel` (named export)
|
|
48
|
+
|
|
49
|
+
A status/dot `Badge` aligned next to a text label. Owns the dot↔label alignment (inline-flex, 8px
|
|
50
|
+
gap) so consumers don't carry that CSS. It powers the `Badge` `text` prop and is also exported for
|
|
51
|
+
direct use.
|
|
52
|
+
|
|
53
|
+
| Prop | Type | Description |
|
|
54
|
+
|------|------|-------------|
|
|
55
|
+
| `status` / `customColor` / `flag` / `pulsing` / `dot` | — | Forwarded to the inner `Badge`. |
|
|
56
|
+
| `children` | `ReactNode` | The label rendered next to the dot. |
|
|
57
|
+
| `className`, `style` | — | Applied to the wrapper. |
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import { BadgeWithLabel } from '@synerise/ds-badge';
|
|
61
|
+
<BadgeWithLabel status="warning">Needs review</BadgeWithLabel>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Types
|
|
65
|
+
|
|
66
|
+
| Export | Description |
|
|
67
|
+
|--------|-------------|
|
|
68
|
+
| `BadgeProps` | Full props type (`BadgeOwnProps & PassthroughAttributes`) |
|
|
69
|
+
| `BadgeWithLabelProps` | Props for `BadgeWithLabel` |
|
|
70
|
+
| `BadgeStatus` | `'active' \| 'inactive' \| 'blocked' \| 'processing' \| 'warning' \| undefined` |
|
|
71
|
+
| `BadgeColor` | `'red' \| 'green' \| 'grey' \| 'yellow' \| 'blue' \| 'pink' \| 'mars' \| 'orange' \| 'fern' \| 'cyan' \| 'purple' \| 'violet' \| 'white' \| 'transparent'` |
|
|
72
|
+
| `BadgeColorHue` | `'900' \| '800' \| '700' \| '600' \| '500' \| '400' \| '300' \| '200' \| '100' \| '050'` |
|
|
73
|
+
|
|
74
|
+
## Usage patterns
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
import Badge from '@synerise/ds-badge';
|
|
78
|
+
|
|
79
|
+
// Count badge (red by default; colour with status/customColor, or override via `style`)
|
|
80
|
+
<Badge count={5}><Avatar /></Badge>
|
|
81
|
+
<Badge count={3} status="blocked" />
|
|
82
|
+
<Badge count={3} customColor="blue" />
|
|
83
|
+
|
|
84
|
+
// Status dot (dot auto-enabled by status).
|
|
85
|
+
<Badge status="active" />
|
|
86
|
+
|
|
87
|
+
// Status dot + label — pass `text` (legacy API) or use BadgeWithLabel directly.
|
|
88
|
+
<Badge status="active" text="Online" />
|
|
89
|
+
|
|
90
|
+
// Flag dot with pulse
|
|
91
|
+
<Badge status="processing" flag pulsing><Avatar /></Badge>
|
|
92
|
+
|
|
93
|
+
// Custom dot colour (arbitrary, non-status colour)
|
|
94
|
+
<Badge status="active" customColor="purple-700" />
|
|
95
|
+
|
|
96
|
+
// data-* passthrough on the wrapper
|
|
97
|
+
<Badge status="active" data-testid="presence" />
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Styling
|
|
101
|
+
|
|
102
|
+
`Badge.styles.tsx` is `styled(BadgeBase)`. It **inlines the base badge CSS** that antd's LESS used to
|
|
103
|
+
provide (wrapper positioning, count pill, dot, `.ds-badge-not-a-wrapper` standalone layout) and adds
|
|
104
|
+
the DS overrides. DS-only styling props (`flag`, `pulsing`, `outlined`, `customColor`) are stripped in
|
|
105
|
+
the wrapper before reaching `BadgeBase`'s DOM; they are still read by the CSS interpolations.
|
|
106
|
+
|
|
107
|
+
Colours come from `@synerise/ds-core` theme palette tokens (`resolveColor`): `customColor` → `status`
|
|
108
|
+
colour → **red** default (count text is white). Consumers wanting a different look (e.g. a neutral
|
|
109
|
+
count chip) override it with an inline `style`/`styled(Badge)` — and, matching antd, the consumer's
|
|
110
|
+
`style` is applied to the **indicator element** (count/dot), not the wrapper, so
|
|
111
|
+
`style={{ backgroundColor: 'transparent', color: ... }}` recolours the count (e.g. the Tabs counter).
|
|
112
|
+
A custom-node `count` (e.g. an icon) renders bare via `.ds-badge-scroll-number-custom-component` — no pill
|
|
113
|
+
background. Count badge is 16px tall; count text uses `macro.h200` from `@synerise/ds-typography`. The
|
|
114
|
+
theme type is `ThemeProps` from `@synerise/ds-core` (not styled-components' `DefaultTheme`, unaugmented here).
|
|
115
|
+
|
|
116
|
+
## Key dependencies
|
|
117
|
+
|
|
118
|
+
- `@synerise/ds-core` — theme palette tokens, `ThemeProps`, `DefaultColor`
|
|
119
|
+
- `@synerise/ds-typography` — `macro.h200` for count text
|
|
120
|
+
- `@synerise/ds-utils` — `PassthroughAttributes` (data-*/aria-* type)
|
|
121
|
+
|
|
122
|
+
## Implementation notes
|
|
123
|
+
|
|
124
|
+
- **No antd.** `BadgeBase` renders the DOM with `ds-badge` / `ds-badge-count` / `ds-badge-dot` /
|
|
125
|
+
`ds-badge-status-dot` / `ds-badge-status-<status>` class hooks, which the DS consumers' selectors
|
|
126
|
+
target (e.g. ds-avatar's `& ~ .ds-badge-dot`). The dot `sup` carries `ds-badge-dot` **and**
|
|
127
|
+
`ds-badge-status-dot ds-badge-status-<status>` when `status` is set. The legacy `ant-badge-*` /
|
|
128
|
+
`ant-scroll-number-*` hooks were removed so a parent app still on the old antd-based badge can't
|
|
129
|
+
leak its global `.ant-badge*` styles onto the new one.
|
|
130
|
+
- **Colour is status-driven.** The old `backgroundColor` / `backgroundColorHue` / `textColor` /
|
|
131
|
+
`textColorHue` props and the antd-passthrough `color` / `text` props were **removed**; `showZero` /
|
|
132
|
+
`size` / `title` / `id` and the antd `Omit<AntBadgeProps>` inheritance are gone too. `customColor`
|
|
133
|
+
is kept for arbitrary per-item colours (segment lists, status-label table cells).
|
|
134
|
+
- **`dot` is auto-derived from `status`** — set `status` and you get a dot without `dot={true}`.
|
|
135
|
+
- **Standalone vs wrapping** — with no `children` the wrapper gets `ds-badge-not-a-wrapper` and the
|
|
136
|
+
badge renders inline (no absolute positioning / offset).
|
|
137
|
+
- **`text` restored** — when `text` is set, `Badge` delegates to `BadgeWithLabel` (status dot + label), so the legacy `status` + `text` API keeps working without switching components; `BadgeWithLabel` is still exported for direct use. To avoid a `Badge ↔ BadgeWithLabel` import cycle, the dot/count renderer lives in `BadgeCore.tsx` — both `Badge` (text mode) and `BadgeWithLabel` render `BadgeCore`.
|
|
138
|
+
- Tests: Vitest (`src/__specs__/Badge.spec.tsx`).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-badge",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.58",
|
|
4
4
|
"description": "Badge 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,9 +42,9 @@
|
|
|
41
42
|
],
|
|
42
43
|
"types": "dist/index.d.ts",
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"@synerise/ds-icon": "^1.18.
|
|
45
|
-
"@synerise/ds-typography": "^1.1.
|
|
46
|
-
"@synerise/ds-utils": "^1.10.
|
|
45
|
+
"@synerise/ds-icon": "^1.18.5",
|
|
46
|
+
"@synerise/ds-typography": "^1.1.27",
|
|
47
|
+
"@synerise/ds-utils": "^1.10.2"
|
|
47
48
|
},
|
|
48
49
|
"peerDependencies": {
|
|
49
50
|
"@synerise/ds-core": "*",
|
|
@@ -51,5 +52,5 @@
|
|
|
51
52
|
"styled-components": "^5.3.3",
|
|
52
53
|
"vitest": "4"
|
|
53
54
|
},
|
|
54
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "d0a43cc43d8528a36f105aceea52ab470edb71d9"
|
|
55
56
|
}
|