@synerise/ds-button 1.5.34 → 1.5.35

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 +166 -0
  3. package/package.json +7 -6
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.5.35](https://github.com/synerise/synerise-design/compare/@synerise/ds-button@1.5.34...@synerise/ds-button@1.5.35) (2026-07-23)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-button
9
+
6
10
  ## [1.5.34](https://github.com/synerise/synerise-design/compare/@synerise/ds-button@1.5.33...@synerise/ds-button@1.5.34) (2026-07-16)
7
11
 
8
12
  ### Bug Fixes
package/CLAUDE.md ADDED
@@ -0,0 +1,166 @@
1
+ # Button (`@synerise/ds-button`)
2
+
3
+ > Standalone button component with a DS type/mode/colour system, ripple animation, loading spinner, and specialised sub-variants (Toggle, Creator, Expander, Checkbox, Star).
4
+
5
+ ## Package structure
6
+
7
+ ```
8
+ src/
9
+ BaseButton.tsx — lightweight forwardRef button, generates ant-btn-* class names
10
+ BaseButton.types.ts — BaseButtonProps (extends ButtonHTMLAttributes)
11
+ BaseButton.styles.ts — styled.button with base layout styles, shouldForwardProp filter
12
+ Button.tsx — main DS component (forwardRef), adds ripple, spinner, focus ring
13
+ Button.types.tsx — ButtonProps, ButtonMode, ButtonType, StyledButton
14
+ Button.styles.tsx — StyledButton styled wrapper + variant colours + DS overrides
15
+ Button.variants.ts — 15 colour variant definitions (primary, ghost, danger, etc.)
16
+ index.tsx — public exports; attaches deprecated static sub-components
17
+ ButtonToggle/ — two-state toggle button (activated / default)
18
+ Checkbox/ — checkbox-style icon button (controlled + uncontrolled)
19
+ Creator/ — "add item" dashed button with optional label (uses BaseButton)
20
+ Expander/ — chevron expand/collapse icon button (uses BaseButton)
21
+ Star/ — star favourite toggle icon button
22
+ ```
23
+
24
+ ## Architecture
25
+
26
+ Three-layer styled-components chain:
27
+
28
+ 1. **`BaseButton.styles.ts`** (`styled.button`) — base layout: height, font, border-radius, cursor, disabled, size classes. Single `&` specificity. Uses `shouldForwardProp` to filter DS-specific props from the native `<button>`.
29
+ 2. **`BaseButton.tsx`** — renders `<S.Button>`, generates CSS class names (`ant-btn ant-btn-{type}`), handles loading delay, wraps text children in `<span>`.
30
+ 3. **`Button.styles.tsx`** (`styled(BaseButton)`) — applies variant colours via `getVariantStyles()`, DS overrides (modes, error, custom-color, readOnly, ripple). Double `&&` specificity.
31
+
32
+ Sub-components that don't need ripple/spinner (Expander, Creator) use `BaseButton` directly. Sub-components that need the full DS button (Star, Checkbox) use `Button`.
33
+
34
+ ### CSS class names
35
+
36
+ Preserves `ant-btn ant-btn-{type}` class name convention for compatibility with external packages that target these selectors (`table`, `modal`, `color-picker`, etc.). These are DS-internal conventions — antd is no longer a dependency.
37
+
38
+ ### Icon colour inheritance
39
+
40
+ Icons use `currentColor` for fill/stroke. Button styles only set `color` on the button element — no direct `svg { fill }` overrides. Icons inherit automatically.
41
+
42
+ ### Focus ring
43
+
44
+ Uses `:focus-visible` (not `:focus`) so the focus ring only appears on keyboard navigation, not mouse clicks. The `ButtonFocus` div renders an inset `box-shadow` overlay.
45
+
46
+ ## Public exports
47
+
48
+ ### `Button` (default)
49
+
50
+ `forwardRef<HTMLButtonElement, ButtonProps>`. Extends `BaseButtonProps` (which extends `ButtonHTMLAttributes<HTMLButtonElement>`).
51
+
52
+ | Prop | Type | Default | Description |
53
+ |------|------|---------|-------------|
54
+ | `type` | `LiteralStringUnion<ButtonType>` | `'secondary'` | Visual style variant |
55
+ | `mode` | `LiteralStringUnion<ButtonModes>` | `undefined` | Icon/label layout |
56
+ | `color` | `string` | `'red'` | Colour token for `custom-color` / `custom-color-ghost` types |
57
+ | `iconColor` | `string` | `undefined` | Colour token for icon colour on secondary/tertiary/ghost types |
58
+ | `groupVariant` | `'left-rounded' \| 'squared' \| 'right-rounded'` | `undefined` | Corner rounding for button groups |
59
+ | `justifyContent` | `JustifyContentProperty` | `'center'` | CSS justify-content |
60
+ | `loading` | `boolean \| { delay?: number }` | `false` | Shows spinning overlay |
61
+ | `error` | `boolean` | `undefined` | Red error styling |
62
+ | `readOnly` | `boolean` | `undefined` | Disables ripple, freezes hover/focus styles |
63
+ | `tagProps` | `TagProps` | `undefined` | Renders a pill tag after the label |
64
+ | `tooltipProps` | `TooltipProps` | `undefined` | Wraps label in a tooltip |
65
+ | `onClick` | `(event: MouseEvent<HTMLElement>) => void` | `undefined` | Click handler (also triggers ripple) |
66
+
67
+ #### `ButtonType` values
68
+ `'primary' | 'secondary' | 'tertiary' | 'tertiary-white' | 'ghost-primary' | 'ghost' | 'ghost-white' | 'custom-color' | 'custom-color-ghost'`
69
+
70
+ Additional variant types handled by `Button.variants.ts`: `'danger' | 'success' | 'warning' | 'gray' | 'dark' | 'flat' | 'primary-on-blue'`
71
+
72
+ #### `ButtonMode` values
73
+ | Value | Description |
74
+ |-------|-------------|
75
+ | `'single-icon'` | 32×32px icon-only; no min-width |
76
+ | `'split'` | label + right icon with a divider |
77
+ | `'two-icons'` | left icon + label + right icon |
78
+ | `'label-icon'` | label then icon |
79
+ | `'icon-label'` | icon then label |
80
+
81
+ ### `ButtonToggle`
82
+
83
+ Two-state button. Maps `activated` + `type` to underlying Button `type` internally.
84
+
85
+ | Prop | Type | Default | Description |
86
+ |------|------|---------|-------------|
87
+ | `activated` | `boolean` | `undefined` | Active/selected state |
88
+ | `type` | `'solid' \| 'ghost'` | `'solid'` | Style variant |
89
+
90
+ ### `Creator`
91
+
92
+ "Add item" button with dashed border and `+` icon. Uses `BaseButton` directly. `forwardRef<HTMLButtonElement, CreatorProps>`.
93
+
94
+ | Prop | Type | Default | Description |
95
+ |------|------|---------|-------------|
96
+ | `label` | `ReactNode` | `undefined` | Optional text label |
97
+ | `block` | `boolean` | `undefined` | Full-width layout |
98
+ | `labelAlign` | `'center' \| 'left'` | `'center'` | Label alignment |
99
+ | `status` | `CreatorStatus` | `undefined` | `Default`, `Error`, `Upload` |
100
+
101
+ ### `Expander`
102
+
103
+ Chevron button for expand/collapse. Uses `BaseButton` directly.
104
+
105
+ | Prop | Type | Default | Description |
106
+ |------|------|---------|-------------|
107
+ | `expanded` | `boolean` | `undefined` | Rotates chevron 180° |
108
+ | `size` | `'S' \| 'M'` | `'S'` | S=24px, M=32px |
109
+
110
+ ### `Checkbox` (exported as `CheckboxButton`)
111
+
112
+ Checkbox icon-button. Uses `Button` (needs ripple/focus ring).
113
+
114
+ | Prop | Type | Default | Description |
115
+ |------|------|---------|-------------|
116
+ | `checked` | `boolean` | `undefined` | Controlled state |
117
+ | `defaultChecked` | `boolean` | `false` | Uncontrolled initial state |
118
+ | `indeterminate` | `boolean` | `undefined` | Indeterminate state |
119
+ | `hasError` | `boolean` | `undefined` | Error styling |
120
+ | `onChange` | `(checked: boolean) => void` | `undefined` | Change callback |
121
+
122
+ ### `Star` (exported as `StarButton`)
123
+
124
+ Star favourite toggle. Uses `Button`.
125
+
126
+ | Prop | Type | Default | Description |
127
+ |------|------|---------|-------------|
128
+ | `active` | `boolean` | `undefined` | Filled star |
129
+ | `hasError` | `boolean` | `undefined` | Error styling |
130
+
131
+ ### Types & constants
132
+
133
+ | Export | Description |
134
+ |--------|-------------|
135
+ | `ButtonProps` | Main button props interface |
136
+ | `StyledButton<T>` | Utility type for styled extensions |
137
+ | `ButtonToggleProps` | Props for ButtonToggle |
138
+ | `CreatorProps` | Props for Creator |
139
+ | `CreatorStatus` | Enum: `Default`, `Error`, `Upload` |
140
+ | `StarButtonProps` | Props for Star |
141
+ | `CheckboxButtonProps` | Props for Checkbox |
142
+ | `ExpanderProps` | Props for Expander |
143
+ | `ExpanderSize` | Record: `{ S: 24, M: 32 }` |
144
+ | `ButtonStyles` | Object of all styled-component exports for extension |
145
+
146
+ ## Key dependencies
147
+
148
+ - `@synerise/ds-icon` — `SpinnerM`, `AngleDownS`, `AddM`, `StarM`/`StarFillM`, `CheckboxSelectedFillM`/`CheckboxIndeterminateM`
149
+ - `@synerise/ds-tag` — optional status tag inside button label
150
+ - `@synerise/ds-tooltip` — optional tooltip wrapping button label
151
+ - `classnames` — className composition in Creator and Expander
152
+ - `csstype` — `JustifyContentProperty` type
153
+
154
+ ## Implementation notes
155
+
156
+ - **No antd dependency** — standalone implementation. `BaseButton` generates `ant-btn-*` class names for backward compatibility with external packages.
157
+ - **`LiteralStringUnion<T>`** — `type`, `mode`, `color`, `iconColor`, `groupVariant` use this utility from `ds-utils` (`T | (string & {})`), giving autocomplete while accepting arbitrary strings.
158
+ - **Ripple origin** — click handler computes `x/y` relative to nearest `.ant-btn` ancestor.
159
+ - **`readOnly` vs `disabled`** — `readOnly` keeps the button visually enabled but prevents interaction appearance changes. `disabled` is the standard HTML attribute.
160
+ - **`custom-color-ghost`** — has its own variant entry in `Button.variants.ts` (maps to ghost-primary base styles). Hover preserves the custom color instead of switching to blue.
161
+ - **`ButtonToggle` blurs after pointer-up** — `setTimeout(..., 200)` removes focus after mouse use.
162
+ - **`Checkbox` indeterminate click** — always transitions to `checked=true`.
163
+
164
+ ## Deprecated
165
+
166
+ Static sub-components on the default export (`Button.Creator`, `Button.Expander`, `Button.Star`, `Button.Checkbox`) are deprecated. Use named imports instead.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-button",
3
- "version": "1.5.34",
3
+ "version": "1.5.35",
4
4
  "description": "Button 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"
@@ -38,10 +39,10 @@
38
39
  "sideEffects": false,
39
40
  "types": "dist/index.d.ts",
40
41
  "dependencies": {
41
- "@synerise/ds-icon": "^1.18.4",
42
- "@synerise/ds-tag": "^1.4.31",
43
- "@synerise/ds-tooltip": "^1.5.3",
44
- "@synerise/ds-utils": "^1.10.1",
42
+ "@synerise/ds-icon": "^1.18.5",
43
+ "@synerise/ds-tag": "^1.4.32",
44
+ "@synerise/ds-tooltip": "^1.5.4",
45
+ "@synerise/ds-utils": "^1.10.2",
45
46
  "classnames": "^2.5.1",
46
47
  "csstype": "^2.6.9"
47
48
  },
@@ -51,5 +52,5 @@
51
52
  "styled-components": "^5.3.3",
52
53
  "vitest": "4"
53
54
  },
54
- "gitHead": "a81ab6519d49a3dea9c0cfebcdc9104cbb4f4226"
55
+ "gitHead": "d0a43cc43d8528a36f105aceea52ab470edb71d9"
55
56
  }