@synerise/ds-metric-card 1.2.25 → 1.2.26

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 +79 -0
  3. package/package.json +11 -10
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.2.26](https://github.com/Synerise/synerise-design/compare/@synerise/ds-metric-card@1.2.25...@synerise/ds-metric-card@1.2.26) (2026-07-23)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-metric-card
9
+
6
10
  ## [1.2.25](https://github.com/Synerise/synerise-design/compare/@synerise/ds-metric-card@1.2.24...@synerise/ds-metric-card@1.2.25) (2026-06-27)
7
11
 
8
12
  **Note:** Version bump only for package @synerise/ds-metric-card
package/CLAUDE.md ADDED
@@ -0,0 +1,79 @@
1
+ # MetricCard (`@synerise/ds-metric-card`)
2
+
3
+ > A compact card showing a numeric metric title, value, optional tooltip, and a copy-to-clipboard button that appears on hover. Supports loading skeleton and inline error state.
4
+
5
+ ## Package structure
6
+
7
+ ```
8
+ src/
9
+ MetricCard.tsx — main component
10
+ MetricCard.types.ts — MetricCardProps, CopyTexts
11
+ MetricCard.styles.tsx — all styled components
12
+ index.ts — public exports
13
+ __specs__/
14
+ MetricCard.spec.tsx — Vitest tests (title, hover reveal, inlineAlert, copyIcon)
15
+ ```
16
+
17
+ ## Public exports
18
+
19
+ ### `MetricCard` (default export)
20
+
21
+ `MetricCardProps = WithHTMLAttributes<HTMLDivElement, { … }>`
22
+
23
+ | Prop | Type | Default | Description |
24
+ |------|------|---------|-------------|
25
+ | `title` | `ReactNode` | — | Card heading; truncated with tooltip on overflow |
26
+ | `headerRightSide` | `ReactNode` | — | Rendered right of the title (e.g. an options button) |
27
+ | `displayValue` | `ReactNode` | — | Value shown at rest (e.g. compact-formatted number) |
28
+ | `hoverValue` | `ReactNode` | — | Value shown on hover (e.g. full unformatted number); falls back to `displayValue` if absent |
29
+ | `tooltip` | `ReactNode` | — | Text for the info icon tooltip next to the title |
30
+ | `tooltipConfig` | `TooltipProps` | — | Spreads all `ds-tooltip` props onto the title info tooltip; takes priority over `tooltip` |
31
+ | `greyBackground` | `boolean` | — | Applies grey background to the `Panel` wrapper |
32
+ | `isLoading` | `boolean` | — | Shows a skeleton instead of the value area |
33
+ | `errorMessage` | `ReactNode` | — | Renders an `InlineAlert type="alert"` instead of the value area |
34
+ | `copyValue` | `string` | — | String to copy; when provided, hovering the card reveals the `CopyIcon` |
35
+ | `texts` | `CopyTexts` | — | `{ copyTooltip?, copiedTooltip? }` — labels for the copy icon |
36
+
37
+ Accepts all standard `<div>` HTML attributes via `WithHTMLAttributes`.
38
+
39
+ ### `MetricCardProps`
40
+
41
+ Full props type re-export.
42
+
43
+ ## Usage patterns
44
+
45
+ ```tsx
46
+ import MetricCard from '@synerise/ds-metric-card';
47
+
48
+ <MetricCard
49
+ title="Revenue"
50
+ displayValue={<FormattedNumber options={compactOptions} value={12345} />}
51
+ hoverValue={<FormattedNumber value={12345} />}
52
+ copyValue="12345"
53
+ texts={{ copyTooltip: 'Copy', copiedTooltip: 'Copied!' }}
54
+ headerRightSide={<Button type="ghost" mode="single-icon">…</Button>}
55
+ />
56
+ ```
57
+
58
+ ## Styling
59
+
60
+ `MetricCard.styles.tsx`. Root is a `Panel` with `p="8px 8px 14px 24px"` and `radius={3}`. Value font size is `32px`, `font-weight: 500`, colour `grey-800`.
61
+
62
+ Hover behaviour is pure CSS class toggle: `MetricContent.hovered` class shows `WrapperNumber` and hides `WrapperFormattedNumber` (and vice versa). The `CopyIcon` uses `visibility + opacity` transition so it doesn't shift layout.
63
+
64
+ ## Key dependencies
65
+
66
+ - `@synerise/ds-panel` — outer container card
67
+ - `@synerise/ds-inline-alert` — error state (`type="alert"`)
68
+ - `@synerise/ds-skeleton` — loading state (`size="S" width="M" height={32}`)
69
+ - `@synerise/ds-copy-icon` — copy-to-clipboard button
70
+ - `@synerise/ds-tooltip` — title info tooltip
71
+ - `@synerise/ds-typography` — `Text` component with ellipsis tooltip for title and value
72
+ - `@synerise/ds-utils` — `WithHTMLAttributes`
73
+
74
+ ## Implementation notes
75
+
76
+ - **`isLoading` and `errorMessage` are mutually exclusive** — `isLoading` takes priority; the `useMemo` returns the skeleton first, then the inline alert, then the value nodes.
77
+ - **`hoverValue` fallback** — if only `displayValue` is provided and no `hoverValue`, `WrapperNumber` still renders `displayValue` on hover.
78
+ - **Copy icon visibility** — the icon is only mounted when `hover && typeof copyValue === 'string'`; it is not shown at all when `copyValue` is absent.
79
+ - **Uses Vitest**.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-metric-card",
3
- "version": "1.2.25",
3
+ "version": "1.2.26",
4
4
  "description": "MetricCard 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,16 +42,16 @@
41
42
  ],
42
43
  "types": "dist/index.d.ts",
43
44
  "dependencies": {
44
- "@synerise/ds-copy-icon": "^1.2.15",
45
- "@synerise/ds-icon": "^1.18.4",
46
- "@synerise/ds-inline-alert": "^1.1.27",
47
- "@synerise/ds-panel": "^1.2.16",
48
- "@synerise/ds-skeleton": "^1.0.59",
49
- "@synerise/ds-tooltip": "^1.5.3",
50
- "@synerise/ds-typography": "^1.1.26"
45
+ "@synerise/ds-copy-icon": "^1.2.16",
46
+ "@synerise/ds-icon": "^1.18.5",
47
+ "@synerise/ds-inline-alert": "^1.1.28",
48
+ "@synerise/ds-panel": "^1.2.17",
49
+ "@synerise/ds-skeleton": "^1.0.60",
50
+ "@synerise/ds-tooltip": "^1.5.4",
51
+ "@synerise/ds-typography": "^1.1.27"
51
52
  },
52
53
  "devDependencies": {
53
- "@synerise/ds-utils": "^1.10.1"
54
+ "@synerise/ds-utils": "^1.10.2"
54
55
  },
55
56
  "peerDependencies": {
56
57
  "@synerise/ds-core": "*",
@@ -59,5 +60,5 @@
59
60
  "styled-components": "^5.3.3",
60
61
  "vitest": "4"
61
62
  },
62
- "gitHead": "dfd892acc1d02abebcf661db3fb32f0fc4b6c354"
63
+ "gitHead": "d0a43cc43d8528a36f105aceea52ab470edb71d9"
63
64
  }