Compare commits

...

5 Commits

Author SHA1 Message Date
hsiegeln
232868b9e7 feat: responsive charts with timestamp tooltips
All checks were successful
Build & Publish / publish (push) Successful in 1m43s
Charts (LineChart, AreaChart, BarChart) now fill their container
width instead of using a fixed 400px default. SVGs use width=100%
with preserveAspectRatio=none.

LineChart and AreaChart tooltips now show the data point timestamp
when x-values are Date objects, displayed as a header row above
the series values.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 18:50:50 +02:00
hsiegeln
8b32fe3994 chore: bump version to 0.1.45
All checks were successful
Build & Publish / publish (push) Successful in 1m40s
2026-04-12 17:24:58 +02:00
hsiegeln
250cbec7b7 fix: reduce version text size and increase separation from brand name
Version in sidebar header now 10px (was 12px), 8px margin (was 4px),
with reduced opacity for visual hierarchy.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 17:24:42 +02:00
hsiegeln
dfac0db564 chore: bump version to 0.1.44
All checks were successful
Build & Publish / publish (push) Successful in 1m32s
SonarQube Analysis / sonarqube (push) Successful in 2m33s
2026-04-11 10:59:10 +02:00
hsiegeln
bb8e6d9d65 fix: error toasts persist until manually dismissed
All checks were successful
Build & Publish / publish (push) Successful in 1m11s
Error variant toasts no longer auto-close after 5 seconds. Duration 0
means "no auto-dismiss". Other variants unchanged.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 10:56:39 +02:00
10 changed files with 73 additions and 19 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "@cameleer/design-system", "name": "@cameleer/design-system",
"version": "0.1.7", "version": "0.1.44",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@cameleer/design-system", "name": "@cameleer/design-system",
"version": "0.1.7", "version": "0.1.44",
"dependencies": { "dependencies": {
"lucide-react": "^1.7.0", "lucide-react": "^1.7.0",
"react": "^19.0.0", "react": "^19.0.0",

View File

@@ -1,6 +1,6 @@
{ {
"name": "@cameleer/design-system", "name": "@cameleer/design-system",
"version": "0.1.42", "version": "0.1.46",
"type": "module", "type": "module",
"main": "./dist/index.es.js", "main": "./dist/index.es.js",
"module": "./dist/index.es.js", "module": "./dist/index.es.js",

View File

@@ -1,8 +1,9 @@
.wrapper { .wrapper {
position: relative; position: relative;
display: inline-flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 4px; gap: 4px;
width: 100%;
} }
.svg { .svg {
@@ -78,6 +79,15 @@
white-space: nowrap; white-space: nowrap;
} }
.tooltipTime {
font-family: var(--font-mono);
font-size: 10px;
color: var(--text-muted);
margin-bottom: 4px;
padding-bottom: 3px;
border-bottom: 1px solid var(--border-subtle);
}
.tooltipRow { .tooltipRow {
display: flex; display: flex;
align-items: center; align-items: center;

View File

@@ -45,6 +45,7 @@ export function AreaChart({
const [tooltip, setTooltip] = useState<{ const [tooltip, setTooltip] = useState<{
x: number x: number
y: number y: number
xLabel: string
values: { label: string; value: number; color: string }[] values: { label: string; value: number; color: string }[]
} | null>(null) } | null>(null)
@@ -84,6 +85,15 @@ export function AreaChart({
// Find closest x value // Find closest x value
const pctX = (mx - dims.paddingLeft) / plotW const pctX = (mx - dims.paddingLeft) / plotW
const firstS = series[0]
const idx0 = Math.max(0, Math.min(firstS.data.length - 1, Math.round(pctX * (firstS.data.length - 1))))
const xVal = firstS.data[idx0]?.x
const xLabel = xVal instanceof Date
? xVal.toLocaleString([], { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit' })
: typeof xVal === 'number' && xVal > 1e10
? new Date(xVal).toLocaleString([], { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit' })
: String(xVal ?? '')
const values = series.map((s, i) => { const values = series.map((s, i) => {
const idx = Math.round(pctX * (s.data.length - 1)) const idx = Math.round(pctX * (s.data.length - 1))
const clamped = Math.max(0, Math.min(s.data.length - 1, idx)) const clamped = Math.max(0, Math.min(s.data.length - 1, idx))
@@ -95,16 +105,17 @@ export function AreaChart({
} }
}) })
setTooltip({ x: mx, y: my, values }) setTooltip({ x: mx, y: my, xLabel, values })
} }
return ( return (
<div className={`${styles.wrapper} ${className ?? ''}`}> <div className={`${styles.wrapper} ${className ?? ''}`}>
{yLabel && <div className={styles.yLabel}>{yLabel}</div>} {yLabel && <div className={styles.yLabel}>{yLabel}</div>}
<svg <svg
width={width} width="100%"
height={height} height={height}
viewBox={`0 0 ${width} ${height}`} viewBox={`0 0 ${width} ${height}`}
preserveAspectRatio="none"
className={styles.svg} className={styles.svg}
onMouseMove={handleMouseMove} onMouseMove={handleMouseMove}
onMouseLeave={() => setTooltip(null)} onMouseLeave={() => setTooltip(null)}
@@ -223,6 +234,9 @@ export function AreaChart({
top: tooltip.y, top: tooltip.y,
}} }}
> >
{tooltip.xLabel && (
<div className={styles.tooltipTime}>{tooltip.xLabel}</div>
)}
{tooltip.values.map((v) => ( {tooltip.values.map((v) => (
<div key={v.label} className={styles.tooltipRow}> <div key={v.label} className={styles.tooltipRow}>
<span className={styles.tooltipDot} style={{ background: v.color }} /> <span className={styles.tooltipDot} style={{ background: v.color }} />

View File

@@ -1,8 +1,9 @@
.wrapper { .wrapper {
position: relative; position: relative;
display: inline-flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 4px; gap: 4px;
width: 100%;
} }
.svg { .svg {

View File

@@ -101,9 +101,10 @@ export function BarChart({
<div className={`${styles.wrapper} ${className ?? ''}`}> <div className={`${styles.wrapper} ${className ?? ''}`}>
{yLabel && <div className={styles.yLabel}>{yLabel}</div>} {yLabel && <div className={styles.yLabel}>{yLabel}</div>}
<svg <svg
width={width} width="100%"
height={height} height={height}
viewBox={`0 0 ${width} ${height}`} viewBox={`0 0 ${width} ${height}`}
preserveAspectRatio="none"
className={styles.svg} className={styles.svg}
onMouseLeave={() => setTooltip(null)} onMouseLeave={() => setTooltip(null)}
aria-label="Bar chart" aria-label="Bar chart"

View File

@@ -1,8 +1,9 @@
.wrapper { .wrapper {
position: relative; position: relative;
display: inline-flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 4px; gap: 4px;
width: 100%;
} }
.svg { .svg {
@@ -69,6 +70,15 @@
white-space: nowrap; white-space: nowrap;
} }
.tooltipTime {
font-family: var(--font-mono);
font-size: 10px;
color: var(--text-muted);
margin-bottom: 4px;
padding-bottom: 3px;
border-bottom: 1px solid var(--border-subtle);
}
.tooltipRow { .tooltipRow {
display: flex; display: flex;
align-items: center; align-items: center;

View File

@@ -44,6 +44,7 @@ export function LineChart({
const [tooltip, setTooltip] = useState<{ const [tooltip, setTooltip] = useState<{
x: number x: number
y: number y: number
xLabel: string
values: { label: string; value: number; color: string }[] values: { label: string; value: number; color: string }[]
} | null>(null) } | null>(null)
@@ -80,6 +81,15 @@ export function LineChart({
const my = e.clientY - rect.top const my = e.clientY - rect.top
const pctX = (mx - dims.paddingLeft) / plotW const pctX = (mx - dims.paddingLeft) / plotW
const firstS = series[0]
const idx0 = Math.max(0, Math.min(firstS.data.length - 1, Math.round(pctX * (firstS.data.length - 1))))
const xVal = firstS.data[idx0]?.x
const xLabel = xVal instanceof Date
? xVal.toLocaleString([], { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit' })
: typeof xVal === 'number' && xVal > 1e10
? new Date(xVal).toLocaleString([], { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit' })
: String(xVal ?? '')
const values = series.map((s, i) => { const values = series.map((s, i) => {
const idx = Math.round(pctX * (s.data.length - 1)) const idx = Math.round(pctX * (s.data.length - 1))
const clamped = Math.max(0, Math.min(s.data.length - 1, idx)) const clamped = Math.max(0, Math.min(s.data.length - 1, idx))
@@ -91,16 +101,17 @@ export function LineChart({
} }
}) })
setTooltip({ x: mx, y: my, values }) setTooltip({ x: mx, y: my, xLabel, values })
} }
return ( return (
<div className={`${styles.wrapper} ${className ?? ''}`}> <div className={`${styles.wrapper} ${className ?? ''}`}>
{yLabel && <div className={styles.yLabel}>{yLabel}</div>} {yLabel && <div className={styles.yLabel}>{yLabel}</div>}
<svg <svg
width={width} width="100%"
height={height} height={height}
viewBox={`0 0 ${width} ${height}`} viewBox={`0 0 ${width} ${height}`}
preserveAspectRatio="none"
className={styles.svg} className={styles.svg}
onMouseMove={handleMouseMove} onMouseMove={handleMouseMove}
onMouseLeave={() => setTooltip(null)} onMouseLeave={() => setTooltip(null)}
@@ -202,6 +213,9 @@ export function LineChart({
className={styles.tooltip} className={styles.tooltip}
style={{ left: tooltip.x + 12, top: tooltip.y }} style={{ left: tooltip.x + 12, top: tooltip.y }}
> >
{tooltip.xLabel && (
<div className={styles.tooltipTime}>{tooltip.xLabel}</div>
)}
{tooltip.values.map((v) => ( {tooltip.values.map((v) => (
<div key={v.label} className={styles.tooltipRow}> <div key={v.label} className={styles.tooltipRow}>
<span className={styles.tooltipDot} style={{ background: v.color }} /> <span className={styles.tooltipDot} style={{ background: v.color }} />

View File

@@ -81,8 +81,9 @@ export function ToastProvider({ children }: { children: ReactNode }) {
const toast = useCallback( const toast = useCallback(
(options: ToastOptions): string => { (options: ToastOptions): string => {
const id = `toast-${Date.now()}-${Math.random().toString(36).slice(2, 7)}` const id = `toast-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`
const duration = options.duration ?? DEFAULT_DURATION
const variant = options.variant ?? 'info' const variant = options.variant ?? 'info'
// Error toasts persist until manually dismissed; others auto-close after DEFAULT_DURATION
const duration = options.duration ?? (variant === 'error' ? 0 : DEFAULT_DURATION)
const newToast: ToastItem = { const newToast: ToastItem = {
id, id,
@@ -99,11 +100,13 @@ export function ToastProvider({ children }: { children: ReactNode }) {
return next.slice(-MAX_TOASTS) return next.slice(-MAX_TOASTS)
}) })
// Schedule auto-dismiss // Schedule auto-dismiss (duration 0 = persist until manual dismiss)
const timer = setTimeout(() => { if (duration > 0) {
dismiss(id) const timer = setTimeout(() => {
}, duration) dismiss(id)
timersRef.current.set(id, timer) }, duration)
timersRef.current.set(id, timer)
}
return id return id
}, },

View File

@@ -70,9 +70,10 @@
.version { .version {
font-family: var(--font-mono); font-family: var(--font-mono);
font-size: 12px; font-size: 10px;
color: var(--sidebar-muted); color: var(--sidebar-muted);
margin-left: 4px; margin-left: 8px;
opacity: 0.6;
} }
/* Search */ /* Search */