@umituz/web-dashboard 8.1.2 → 8.2.0
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/package.json +1 -1
- package/src/domains/charts/components.test.tsx +18 -1
- package/src/domains/charts/components.tsx +59 -0
- package/src/domains/charts/index.ts +3 -1
- package/src/domains/layouts/components/NextSteps.test.tsx +25 -0
- package/src/domains/layouts/components/NextSteps.tsx +36 -0
- package/src/domains/layouts/components/index.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/web-dashboard",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.2.0",
|
|
4
4
|
"description": "Installable app skeleton for the fleet — layouts, analytics (dependency-free SVG charts), calendar, onboarding flow permissions/module registry; udb-* stylesheet on design-system tokens",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
|
2
2
|
import { renderToString } from 'react-dom/server';
|
|
3
|
-
import { BarChart, Donut, Legend, LineChart, Sparkline } from './components';
|
|
3
|
+
import { ActivityHeatmap, BarChart, Donut, Legend, LineChart, Sparkline } from './components';
|
|
4
4
|
|
|
5
5
|
describe('charts markup smoke', () => {
|
|
6
6
|
it('Sparkline renders an svg path for enough data and null for less', () => {
|
|
@@ -121,4 +121,21 @@ describe('charts markup smoke', () => {
|
|
|
121
121
|
expect(html).toContain('(per month)');
|
|
122
122
|
expect(html).toContain('#333333');
|
|
123
123
|
});
|
|
124
|
+
|
|
125
|
+
it('ActivityHeatmap renders 7 rows and cells with aria-label', () => {
|
|
126
|
+
const html = renderToString(
|
|
127
|
+
<ActivityHeatmap
|
|
128
|
+
cells={[
|
|
129
|
+
{ day: '2026-10-01', value: 0 },
|
|
130
|
+
{ day: '2026-10-02', value: 5 },
|
|
131
|
+
{ day: '2026-10-03', value: 10 },
|
|
132
|
+
]}
|
|
133
|
+
ariaLabel="Activity Grid"
|
|
134
|
+
/>
|
|
135
|
+
);
|
|
136
|
+
expect(html).toContain('role="img"');
|
|
137
|
+
expect(html).toContain('aria-label="Activity Grid"');
|
|
138
|
+
expect(html).toContain('grid-rows-7');
|
|
139
|
+
expect(html).toContain('2026-10-02: 5');
|
|
140
|
+
});
|
|
124
141
|
});
|
|
@@ -621,3 +621,62 @@ export function LineChart({
|
|
|
621
621
|
|
|
622
622
|
);
|
|
623
623
|
}
|
|
624
|
+
|
|
625
|
+
export interface HeatmapCell {
|
|
626
|
+
day: string;
|
|
627
|
+
value: number;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
export interface ActivityHeatmapProps {
|
|
631
|
+
cells: HeatmapCell[];
|
|
632
|
+
max?: number;
|
|
633
|
+
titleFor?: (cell: HeatmapCell) => string;
|
|
634
|
+
ariaLabel?: string;
|
|
635
|
+
className?: string;
|
|
636
|
+
levelClassNames?: string[];
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
const DEFAULT_HEATMAP_LEVELS = [
|
|
640
|
+
'bg-muted/40 dark:bg-muted/30',
|
|
641
|
+
'bg-primary/20 text-primary',
|
|
642
|
+
'bg-primary/40 text-primary',
|
|
643
|
+
'bg-primary/70 text-primary-foreground',
|
|
644
|
+
'bg-primary text-primary-foreground',
|
|
645
|
+
];
|
|
646
|
+
|
|
647
|
+
export function ActivityHeatmap({
|
|
648
|
+
cells,
|
|
649
|
+
max,
|
|
650
|
+
titleFor,
|
|
651
|
+
ariaLabel = 'Activity heatmap',
|
|
652
|
+
className = '',
|
|
653
|
+
levelClassNames = DEFAULT_HEATMAP_LEVELS,
|
|
654
|
+
}: ActivityHeatmapProps) {
|
|
655
|
+
const peak = Math.max(1, max ?? Math.max(0, ...cells.map((cell) => cell.value)));
|
|
656
|
+
const maxIntensity = levelClassNames.length - 1;
|
|
657
|
+
|
|
658
|
+
return (
|
|
659
|
+
<div
|
|
660
|
+
className={`grid grid-flow-col grid-rows-7 gap-1 ${className}`.trim()}
|
|
661
|
+
role="img"
|
|
662
|
+
aria-label={ariaLabel}
|
|
663
|
+
>
|
|
664
|
+
{cells.map((cell, index) => {
|
|
665
|
+
const intensity =
|
|
666
|
+
cell.value <= 0 ? 0 : Math.min(maxIntensity, Math.ceil((cell.value / peak) * maxIntensity));
|
|
667
|
+
const cellClass = levelClassNames[intensity] ?? levelClassNames[0];
|
|
668
|
+
const cellTitle = titleFor ? titleFor(cell) : `${cell.day}: ${cell.value}`;
|
|
669
|
+
|
|
670
|
+
return (
|
|
671
|
+
<span
|
|
672
|
+
key={`${cell.day}-${index}`}
|
|
673
|
+
className={`h-3.5 w-3.5 rounded-[3px] transition-colors ${cellClass}`}
|
|
674
|
+
title={cellTitle}
|
|
675
|
+
>
|
|
676
|
+
<span className="sr-only">{cellTitle}</span>
|
|
677
|
+
</span>
|
|
678
|
+
);
|
|
679
|
+
})}
|
|
680
|
+
</div>
|
|
681
|
+
);
|
|
682
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { PALETTE, useTip, niceMax, gridTicks } from './utils';
|
|
2
2
|
export type { TipRow, TipState } from './utils';
|
|
3
|
-
export { ChartTip, ChartCard, Legend, Sparkline, HBars, BarChart, Donut, LineChart } from './components';
|
|
3
|
+
export { ChartTip, ChartCard, Legend, Sparkline, HBars, BarChart, Donut, LineChart, ActivityHeatmap } from './components';
|
|
4
4
|
export type {
|
|
5
5
|
ChartCardProps,
|
|
6
6
|
LegendItem,
|
|
@@ -9,4 +9,6 @@ export type {
|
|
|
9
9
|
DonutSegment,
|
|
10
10
|
LineSeries,
|
|
11
11
|
LineChartPoint,
|
|
12
|
+
HeatmapCell,
|
|
13
|
+
ActivityHeatmapProps,
|
|
12
14
|
} from './components';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { renderToString } from 'react-dom/server';
|
|
3
|
+
import { MemoryRouter } from 'react-router';
|
|
4
|
+
import { NextSteps } from './NextSteps';
|
|
5
|
+
|
|
6
|
+
describe('NextSteps component', () => {
|
|
7
|
+
it('renders lead text and action links', () => {
|
|
8
|
+
const html = renderToString(
|
|
9
|
+
<MemoryRouter>
|
|
10
|
+
<NextSteps
|
|
11
|
+
lead="Önerilen Adımlar"
|
|
12
|
+
links={[
|
|
13
|
+
{ to: '/app/practice', label: 'Alıştırma Yap' },
|
|
14
|
+
{ to: '/app/exams', label: 'Sınavları Gör' },
|
|
15
|
+
]}
|
|
16
|
+
/>
|
|
17
|
+
</MemoryRouter>
|
|
18
|
+
);
|
|
19
|
+
expect(html).toContain('Önerilen Adımlar');
|
|
20
|
+
expect(html).toContain('Alıştırma Yap');
|
|
21
|
+
expect(html).toContain('href="/app/practice"');
|
|
22
|
+
expect(html).toContain('Sınavları Gör');
|
|
23
|
+
expect(html).toContain('href="/app/exams"');
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { Link } from "react-router";
|
|
3
|
+
import { ArrowRight } from "lucide-react";
|
|
4
|
+
|
|
5
|
+
export interface NextStepLink {
|
|
6
|
+
to: string;
|
|
7
|
+
label: ReactNode;
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface NextStepsProps {
|
|
12
|
+
lead?: ReactNode;
|
|
13
|
+
links: readonly NextStepLink[];
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const NextSteps = ({ lead, links, className }: NextStepsProps) => {
|
|
18
|
+
return (
|
|
19
|
+
<div className={`flex flex-wrap items-center gap-x-4 gap-y-2${className ? ` ${className}` : ""}`}>
|
|
20
|
+
{lead && (
|
|
21
|
+
<span className="text-xs font-bold uppercase tracking-wider text-muted-foreground">
|
|
22
|
+
{lead}
|
|
23
|
+
</span>
|
|
24
|
+
)}
|
|
25
|
+
{links.map((link) => (
|
|
26
|
+
<Link
|
|
27
|
+
key={link.to}
|
|
28
|
+
to={link.to}
|
|
29
|
+
className="inline-flex items-center gap-1.5 rounded-full border border-border bg-card px-3.5 py-2 text-xs font-semibold text-foreground transition-colors hover:border-primary/50 hover:text-primary"
|
|
30
|
+
>
|
|
31
|
+
{link.label} {link.icon ?? <ArrowRight size={12} aria-hidden="true" />}
|
|
32
|
+
</Link>
|
|
33
|
+
))}
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
};
|