create-modoock-app 1.0.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/dist/cli.js +52 -0
- package/package.json +21 -0
- package/template/.cursor/agents/code-reviewer.md +25 -0
- package/template/.cursor/rules/agents.mdc +9 -0
- package/template/.cursor/rules/honey.mdc +226 -0
- package/template/.cursor/rules/ui.mdc +18 -0
- package/template/.cursor/skills/debug/SKILL.md +29 -0
- package/template/.dcdignore +3 -0
- package/template/AGENTS.md +89 -0
- package/template/CLAUDE.md +2 -0
- package/template/README.md +339 -0
- package/template/app/(local)/components/page.tsx +886 -0
- package/template/app/(local)/design-system/page.tsx +1140 -0
- package/template/app/(local)/layout.tsx +5 -0
- package/template/app/(local)/page.tsx +59 -0
- package/template/app/auth/layout.tsx +7 -0
- package/template/app/auth/login/page.tsx +76 -0
- package/template/app/favicon.ico +0 -0
- package/template/app/globals.css +365 -0
- package/template/app/layout.tsx +28 -0
- package/template/components/layout/app-layout.tsx +30 -0
- package/template/components/layout/header.tsx +72 -0
- package/template/components/layout/index.ts +3 -0
- package/template/components/layout/side-nav.tsx +163 -0
- package/template/components/shared/detail-header.tsx +39 -0
- package/template/components/shared/index.ts +8 -0
- package/template/components/shared/info-card.tsx +75 -0
- package/template/components/shared/summary-card.tsx +31 -0
- package/template/components/shared/table-section.tsx +38 -0
- package/template/components/shared/timeline-list.tsx +31 -0
- package/template/components/ui/action-stack.tsx +42 -0
- package/template/components/ui/badge.tsx +43 -0
- package/template/components/ui/button.tsx +104 -0
- package/template/components/ui/icon.tsx +78 -0
- package/template/components/ui/index.ts +28 -0
- package/template/components/ui/input.tsx +376 -0
- package/template/components/ui/loader.tsx +78 -0
- package/template/components/ui/metric-bar.tsx +49 -0
- package/template/components/ui/modal.tsx +177 -0
- package/template/components/ui/select.tsx +458 -0
- package/template/components/ui/stepper.tsx +96 -0
- package/template/components/ui/tab.tsx +85 -0
- package/template/components/ui/user-table.tsx +806 -0
- package/template/eslint.config.mjs +18 -0
- package/template/knowledge-base/design-system/components/action-stack.mdc +17 -0
- package/template/knowledge-base/design-system/components/badges.mdc +16 -0
- package/template/knowledge-base/design-system/components/buttons.mdc +21 -0
- package/template/knowledge-base/design-system/components/detail-header.mdc +17 -0
- package/template/knowledge-base/design-system/components/dropdowns.mdc +12 -0
- package/template/knowledge-base/design-system/components/info-list.mdc +17 -0
- package/template/knowledge-base/design-system/components/inputs.mdc +23 -0
- package/template/knowledge-base/design-system/components/menu.mdc +20 -0
- package/template/knowledge-base/design-system/components/modals.mdc +24 -0
- package/template/knowledge-base/design-system/components/selects.mdc +39 -0
- package/template/knowledge-base/design-system/components/stepper.mdc +18 -0
- package/template/knowledge-base/design-system/components/tables.mdc +59 -0
- package/template/knowledge-base/design-system/components/tabs.mdc +17 -0
- package/template/knowledge-base/design-system/components.mdc +91 -0
- package/template/knowledge-base/design-system/tokens.mdc +24 -0
- package/template/knowledge-base/examples/bad/README.md +8 -0
- package/template/knowledge-base/examples/good/README.md +13 -0
- package/template/knowledge-base/metadata/catalog.yaml +245 -0
- package/template/knowledge-base/patterns/components/reuse-existing.mdc +26 -0
- package/template/knowledge-base/patterns/data-fetching/local-data.mdc +20 -0
- package/template/knowledge-base/patterns/layouts/app-shell.mdc +20 -0
- package/template/knowledge-base/patterns/pages/data-table-page.mdc +31 -0
- package/template/knowledge-base/patterns/pages/workflow-page.mdc +27 -0
- package/template/knowledge-base/rules/accessibility/responsive.mdc +31 -0
- package/template/knowledge-base/rules/architecture/layout.mdc +52 -0
- package/template/knowledge-base/rules/architecture/single-screen.mdc +62 -0
- package/template/knowledge-base/rules/code-quality/jsx.mdc +19 -0
- package/template/knowledge-base/rules/global/naming.mdc +12 -0
- package/template/knowledge-base/rules/global/technology.mdc +19 -0
- package/template/knowledge-base/rules/global/ui-copy.mdc +20 -0
- package/template/knowledge-base/rules/performance/client.mdc +20 -0
- package/template/knowledge-base/rules/ui/information-density.mdc +36 -0
- package/template/knowledge-base/rules/ui/interaction.mdc +47 -0
- package/template/knowledge-base/rules/ui/simple-ui.mdc +58 -0
- package/template/knowledge-base/validation/accessibility.mdc +13 -0
- package/template/knowledge-base/validation/architecture.mdc +10 -0
- package/template/knowledge-base/validation/ast-grep/do-what-brooooooklyn-said.yml +15 -0
- package/template/knowledge-base/validation/ast-grep/no-nested-links.yml +12 -0
- package/template/knowledge-base/validation/ast-grep/rewrite-svg-attribute.yml +19 -0
- package/template/knowledge-base/validation/code-quality.mdc +18 -0
- package/template/knowledge-base/validation/performance.mdc +11 -0
- package/template/knowledge-base/validation/ui.mdc +26 -0
- package/template/next.config.ts +21 -0
- package/template/package-lock.json +6938 -0
- package/template/package.json +30 -0
- package/template/postcss.config.mjs +7 -0
- package/template/public/identity/full_logo_black.svg +27 -0
- package/template/public/identity/full_logo_color.svg +38 -0
- package/template/public/identity/full_logo_white.svg +34 -0
- package/template/public/identity/logo_icon_black.svg +6 -0
- package/template/public/identity/logo_icon_color.svg +13 -0
- package/template/public/identity/logo_icon_white.svg +13 -0
- package/template/public/login-hero.png +0 -0
- package/template/sgconfig.yml +11 -0
- package/template/tsconfig.json +43 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { usePathname, useRouter } from "next/navigation";
|
|
5
|
+
import { Icon } from "@/components/ui";
|
|
6
|
+
import type { IconName } from "@/components/ui";
|
|
7
|
+
|
|
8
|
+
const DESKTOP_NAV = "(min-width: 1024px)";
|
|
9
|
+
|
|
10
|
+
interface NavChild {
|
|
11
|
+
label: string;
|
|
12
|
+
href: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface NavItem {
|
|
16
|
+
label: string;
|
|
17
|
+
href: string;
|
|
18
|
+
icon: IconName;
|
|
19
|
+
children?: NavChild[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const NAV_ITEMS: NavItem[] = [
|
|
23
|
+
{ label: "Beginning", href: "/", icon: "Flame" },
|
|
24
|
+
{ label: "Design System", href: "/design-system", icon: "Palette" },
|
|
25
|
+
{ label: "Components", href: "/components", icon: "Puzzle" }
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
export default function SideNav() {
|
|
29
|
+
const [collapsed, setCollapsed] = useState(true);
|
|
30
|
+
const [expanded, setExpanded] = useState<Record<string, boolean>>({});
|
|
31
|
+
const pathname = usePathname();
|
|
32
|
+
const router = useRouter();
|
|
33
|
+
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const media = window.matchMedia(DESKTOP_NAV);
|
|
36
|
+
const sync = () => setCollapsed(!media.matches);
|
|
37
|
+
sync();
|
|
38
|
+
media.addEventListener("change", sync);
|
|
39
|
+
return () => media.removeEventListener("change", sync);
|
|
40
|
+
}, []);
|
|
41
|
+
|
|
42
|
+
const handleNavigate = (href: string) => {
|
|
43
|
+
router.push(href);
|
|
44
|
+
if (!window.matchMedia(DESKTOP_NAV).matches) {
|
|
45
|
+
setCollapsed(true);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const toggleGroup = (href: string) => {
|
|
50
|
+
setExpanded((prev) => ({ ...prev, [href]: !prev[href] }));
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<>
|
|
55
|
+
{/* Below lg: icon-rail slot in flow; the panel overlays content before md. */}
|
|
56
|
+
<div className="w-16 shrink-0 lg:hidden" aria-hidden="true" />
|
|
57
|
+
<nav
|
|
58
|
+
className={`flex h-full shrink-0 flex-col bg-primary text-primary-foreground transition-[width] duration-300 max-lg:fixed max-lg:inset-y-0 max-lg:left-0 max-lg:z-30 max-lg:shadow-lg max-lg:overscroll-contain ${
|
|
59
|
+
collapsed ? "w-16" : "w-64"
|
|
60
|
+
}`}
|
|
61
|
+
aria-label="Menu principal"
|
|
62
|
+
>
|
|
63
|
+
{/* Header / toggle */}
|
|
64
|
+
<div
|
|
65
|
+
className={`flex items-center justify-between p-4 ${
|
|
66
|
+
collapsed ? "justify-center" : ""
|
|
67
|
+
}`}
|
|
68
|
+
>
|
|
69
|
+
{!collapsed && (
|
|
70
|
+
<span className="text-component-title font-semibold text-white">
|
|
71
|
+
Modoock
|
|
72
|
+
</span>
|
|
73
|
+
)}
|
|
74
|
+
<button
|
|
75
|
+
type="button"
|
|
76
|
+
onClick={() => setCollapsed((c) => !c)}
|
|
77
|
+
aria-label={collapsed ? "Ouvrir le menu" : "Fermer le menu"}
|
|
78
|
+
className="grid size-8 place-items-center rounded-small text-white/80 transition-colors hover:bg-white/10 hover:text-white focus-visible:ring-2 focus-visible:ring-white [&_svg]:shrink-0 [&_svg]:text-current"
|
|
79
|
+
>
|
|
80
|
+
{collapsed ? (
|
|
81
|
+
<Icon name="PanelLeftOpen" aria-hidden="true" />
|
|
82
|
+
) : (
|
|
83
|
+
<Icon name="PanelLeftClose" aria-hidden="true" />
|
|
84
|
+
)}
|
|
85
|
+
</button>
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
{/* Navigation items */}
|
|
89
|
+
<div className="nav-scrollbar flex flex-1 flex-col gap-1 overflow-y-auto px-2 py-2">
|
|
90
|
+
{NAV_ITEMS.map((item) => {
|
|
91
|
+
const hasChildren = !!item.children?.length;
|
|
92
|
+
const isOpen = expanded[item.href];
|
|
93
|
+
const isActive =
|
|
94
|
+
pathname === item.href ||
|
|
95
|
+
(item.children ?? []).some((child) => child.href === pathname);
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<div key={item.href} className="flex flex-col gap-1">
|
|
99
|
+
<button
|
|
100
|
+
type="button"
|
|
101
|
+
onClick={() =>
|
|
102
|
+
hasChildren && !collapsed
|
|
103
|
+
? toggleGroup(item.href)
|
|
104
|
+
: handleNavigate(item.href)
|
|
105
|
+
}
|
|
106
|
+
title={item.label}
|
|
107
|
+
aria-label={collapsed ? item.label : undefined}
|
|
108
|
+
aria-expanded={hasChildren && !collapsed ? isOpen : undefined}
|
|
109
|
+
className={`flex items-center gap-3 rounded-small px-3 py-2 text-left text-body-medium transition-colors focus-visible:ring-2 focus-visible:ring-white [&_svg]:shrink-0 [&_svg]:text-current ${
|
|
110
|
+
isActive
|
|
111
|
+
? "bg-white/15 text-white"
|
|
112
|
+
: "text-white/80 hover:bg-white/10 hover:text-white"
|
|
113
|
+
} ${collapsed ? "justify-center" : ""}`}
|
|
114
|
+
>
|
|
115
|
+
<Icon name={item.icon} aria-hidden="true" />
|
|
116
|
+
{!collapsed && <span className="truncate">{item.label}</span>}
|
|
117
|
+
{hasChildren && !collapsed && (
|
|
118
|
+
<Icon
|
|
119
|
+
name="ChevronDown"
|
|
120
|
+
aria-hidden="true"
|
|
121
|
+
className={`ml-auto transition-transform ${
|
|
122
|
+
isOpen ? "rotate-180" : ""
|
|
123
|
+
}`}
|
|
124
|
+
/>
|
|
125
|
+
)}
|
|
126
|
+
</button>
|
|
127
|
+
|
|
128
|
+
{hasChildren && !collapsed && isOpen && (
|
|
129
|
+
<div className="ml-9 flex flex-col gap-1 border-l border-white/20 pl-2">
|
|
130
|
+
{item.children!.map((child) => {
|
|
131
|
+
const isChildActive = pathname === child.href;
|
|
132
|
+
return (
|
|
133
|
+
<button
|
|
134
|
+
key={child.href}
|
|
135
|
+
type="button"
|
|
136
|
+
onClick={() => handleNavigate(child.href)}
|
|
137
|
+
title={child.label}
|
|
138
|
+
className={`flex items-center rounded-small px-3 py-2 text-left text-body-medium transition-colors focus-visible:ring-2 focus-visible:ring-white ${
|
|
139
|
+
isChildActive
|
|
140
|
+
? "bg-white/15 text-white"
|
|
141
|
+
: "text-white/70 hover:bg-white/10 hover:text-white"
|
|
142
|
+
}`}
|
|
143
|
+
>
|
|
144
|
+
<span className="truncate">{child.label}</span>
|
|
145
|
+
</button>
|
|
146
|
+
);
|
|
147
|
+
})}
|
|
148
|
+
</div>
|
|
149
|
+
)}
|
|
150
|
+
</div>
|
|
151
|
+
);
|
|
152
|
+
})}
|
|
153
|
+
</div>
|
|
154
|
+
|
|
155
|
+
{/* Footer placeholder */}
|
|
156
|
+
<div className="p-4 text-small text-white/60">
|
|
157
|
+
{!collapsed && <span>v1.0.0</span>}
|
|
158
|
+
</div>
|
|
159
|
+
</nav>
|
|
160
|
+
</>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { Icon } from "@/components/ui";
|
|
3
|
+
import type { IconName } from "@/components/ui";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* En-tête d'identité d'une fiche : icône, titre, description, badges ou actions.
|
|
7
|
+
*/
|
|
8
|
+
export default function DetailHeader({
|
|
9
|
+
icon,
|
|
10
|
+
title,
|
|
11
|
+
description,
|
|
12
|
+
children,
|
|
13
|
+
}: {
|
|
14
|
+
icon: IconName;
|
|
15
|
+
title: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
}) {
|
|
19
|
+
return (
|
|
20
|
+
<header className="flex flex-wrap items-start justify-between gap-inline">
|
|
21
|
+
<div className="flex min-w-0 items-start gap-inline">
|
|
22
|
+
<div className="flex size-14 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary">
|
|
23
|
+
<Icon name={icon} size="large" aria-hidden="true" />
|
|
24
|
+
</div>
|
|
25
|
+
<div className="min-w-0">
|
|
26
|
+
<h2 className="text-section-title text-foreground">{title}</h2>
|
|
27
|
+
{description ? (
|
|
28
|
+
<p className="mt-micro text-small text-muted-foreground">
|
|
29
|
+
{description}
|
|
30
|
+
</p>
|
|
31
|
+
) : null}
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
{children ? (
|
|
35
|
+
<div className="flex flex-wrap items-center gap-inline">{children}</div>
|
|
36
|
+
) : null}
|
|
37
|
+
</header>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default as SummaryCard } from "./summary-card";
|
|
2
|
+
export { default as InfoCard, InfoList } from "./info-card";
|
|
3
|
+
export type { InfoListLayout } from "./info-card";
|
|
4
|
+
export { default as DetailHeader } from "./detail-header";
|
|
5
|
+
export { default as TableSection } from "./table-section";
|
|
6
|
+
export { default as TimelineList } from "./timeline-list";
|
|
7
|
+
export type { TimelineEntry } from "./timeline-list";
|
|
8
|
+
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { Icon } from "@/components/ui";
|
|
3
|
+
import type { IconName } from "@/components/ui";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Carte d'information des fiches détail : en-tête icône + titre, corps libre.
|
|
7
|
+
* Réutilisée par les fiches équipement, service et incident.
|
|
8
|
+
*/
|
|
9
|
+
export default function InfoCard({
|
|
10
|
+
icon,
|
|
11
|
+
title,
|
|
12
|
+
children,
|
|
13
|
+
scrollable = false,
|
|
14
|
+
}: {
|
|
15
|
+
icon: IconName;
|
|
16
|
+
title: string;
|
|
17
|
+
children: ReactNode;
|
|
18
|
+
/** At md+, the body scrolls inside the card. Below md, the page scrolls instead. */
|
|
19
|
+
scrollable?: boolean;
|
|
20
|
+
}) {
|
|
21
|
+
return (
|
|
22
|
+
<section className={scrollable ? "flex min-h-0 flex-col rounded-large border border-border bg-surface p-component" : "rounded-large border border-border bg-surface p-component"}>
|
|
23
|
+
<header className={scrollable ? "shrink-0 flex items-center gap-inline" : "flex items-center gap-inline"}>
|
|
24
|
+
<Icon name={icon} variant="muted" aria-hidden="true" />
|
|
25
|
+
<h3 className="text-component-title text-foreground">{title}</h3>
|
|
26
|
+
</header>
|
|
27
|
+
<div
|
|
28
|
+
className={scrollable ? "mt-component min-h-0 flex-1 md:overflow-y-auto" : "mt-component"}
|
|
29
|
+
>
|
|
30
|
+
{children}
|
|
31
|
+
</div>
|
|
32
|
+
</section>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type InfoListLayout = "inline" | "stacked";
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Liste label/valeur compacte affichée dans les cartes d'information.
|
|
40
|
+
* `inline` : valeur à droite (fiches courtes). `stacked` : label au-dessus (textes longs).
|
|
41
|
+
*/
|
|
42
|
+
export function InfoList({
|
|
43
|
+
rows,
|
|
44
|
+
layout = "inline",
|
|
45
|
+
}: {
|
|
46
|
+
rows: { label: string; value: ReactNode }[];
|
|
47
|
+
layout?: InfoListLayout;
|
|
48
|
+
}) {
|
|
49
|
+
const stacked = layout === "stacked";
|
|
50
|
+
return (
|
|
51
|
+
<dl>
|
|
52
|
+
{rows.map((row) => (
|
|
53
|
+
<div
|
|
54
|
+
key={row.label}
|
|
55
|
+
className={
|
|
56
|
+
stacked
|
|
57
|
+
? "border-b border-border py-inline last:border-b-0"
|
|
58
|
+
: "flex items-start justify-between gap-inline border-b border-border py-inline last:border-b-0"
|
|
59
|
+
}
|
|
60
|
+
>
|
|
61
|
+
<dt className="text-label text-muted-foreground">{row.label}</dt>
|
|
62
|
+
<dd
|
|
63
|
+
className={
|
|
64
|
+
stacked
|
|
65
|
+
? "mt-micro text-body-medium text-foreground"
|
|
66
|
+
: "max-w-[60%] text-right text-body-medium text-foreground break-all"
|
|
67
|
+
}
|
|
68
|
+
>
|
|
69
|
+
{row.value}
|
|
70
|
+
</dd>
|
|
71
|
+
</div>
|
|
72
|
+
))}
|
|
73
|
+
</dl>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Icon } from "@/components/ui";
|
|
2
|
+
import type { IconName, IconVariant } from "@/components/ui";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Carte de synthèse compacte des pages dashboard : une icône, un chiffre clé
|
|
6
|
+
* et son libellé. Réutilisée par les pages équipements, infrastructure et
|
|
7
|
+
* incidents.
|
|
8
|
+
*/
|
|
9
|
+
export default function SummaryCard({
|
|
10
|
+
icon,
|
|
11
|
+
iconVariant,
|
|
12
|
+
label,
|
|
13
|
+
count,
|
|
14
|
+
}: {
|
|
15
|
+
icon: IconName;
|
|
16
|
+
iconVariant: IconVariant;
|
|
17
|
+
label: string;
|
|
18
|
+
count: number | string;
|
|
19
|
+
}) {
|
|
20
|
+
return (
|
|
21
|
+
<div className="rounded-large border border-border bg-surface p-component">
|
|
22
|
+
<div className="flex items-center gap-inline">
|
|
23
|
+
<Icon name={icon} variant={iconVariant} size="large" aria-hidden="true" />
|
|
24
|
+
<p className="text-component-title leading-none text-foreground">
|
|
25
|
+
{count}
|
|
26
|
+
</p>
|
|
27
|
+
</div>
|
|
28
|
+
<p className="mt-micro text-small text-muted-foreground">{label}</p>
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { Badge, Icon } from "@/components/ui";
|
|
3
|
+
import type { IconName } from "@/components/ui";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Section de page avec en-tête (icône + titre + compteur) et contenu libre.
|
|
7
|
+
* Réutilisée par les onglets équipement et autres sections de tableau.
|
|
8
|
+
*/
|
|
9
|
+
export default function TableSection({
|
|
10
|
+
icon,
|
|
11
|
+
title,
|
|
12
|
+
count,
|
|
13
|
+
children,
|
|
14
|
+
className,
|
|
15
|
+
}: {
|
|
16
|
+
icon: IconName;
|
|
17
|
+
title: string;
|
|
18
|
+
count?: number;
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
className?: string;
|
|
21
|
+
}) {
|
|
22
|
+
return (
|
|
23
|
+
<section className={`flex min-h-0 flex-1 flex-col ${className ?? ""}`}>
|
|
24
|
+
<div className="flex items-center justify-between gap-inline">
|
|
25
|
+
<div className="flex items-center gap-inline">
|
|
26
|
+
<Icon name={icon} variant="muted" aria-hidden="true" />
|
|
27
|
+
<h3 className="text-component-title text-foreground">{title}</h3>
|
|
28
|
+
</div>
|
|
29
|
+
{typeof count === "number" ? (
|
|
30
|
+
<Badge variant="secondary">{count}</Badge>
|
|
31
|
+
) : null}
|
|
32
|
+
</div>
|
|
33
|
+
<div className="mt-component flex min-h-0 flex-1 flex-col">
|
|
34
|
+
{children}
|
|
35
|
+
</div>
|
|
36
|
+
</section>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entrée de timeline avec heure formatée et texte descriptif.
|
|
3
|
+
*/
|
|
4
|
+
export interface TimelineEntry {
|
|
5
|
+
time: string;
|
|
6
|
+
text: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Liste d'historique avec heure et texte descriptif.
|
|
11
|
+
* Réutilisée par les fiches incident et autres vues temporelles.
|
|
12
|
+
*/
|
|
13
|
+
export default function TimelineList({ entries }: { entries: TimelineEntry[] }) {
|
|
14
|
+
return (
|
|
15
|
+
<ul className="space-y-component">
|
|
16
|
+
{entries.map((entry, i) => (
|
|
17
|
+
<li
|
|
18
|
+
key={entry.time + "-" + entry.text + "-" + i}
|
|
19
|
+
className="flex items-start gap-inline border-b border-border py-inline last:border-b-0"
|
|
20
|
+
>
|
|
21
|
+
<span className="w-20 shrink-0 font-mono text-body-medium text-muted-foreground">
|
|
22
|
+
{entry.time}
|
|
23
|
+
</span>
|
|
24
|
+
<span className="min-w-0 flex-1 text-body-medium text-foreground">
|
|
25
|
+
{entry.text}
|
|
26
|
+
</span>
|
|
27
|
+
</li>
|
|
28
|
+
))}
|
|
29
|
+
</ul>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import ClickableButton from "./button";
|
|
2
|
+
import type { ButtonVariant } from "./button";
|
|
3
|
+
|
|
4
|
+
export interface ActionStackItem {
|
|
5
|
+
key: string;
|
|
6
|
+
label: string;
|
|
7
|
+
variant?: ButtonVariant;
|
|
8
|
+
onClick: () => void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Pile verticale de boutons d'action, avec message si aucune action n'est disponible.
|
|
13
|
+
*/
|
|
14
|
+
export default function ActionStack({
|
|
15
|
+
actions,
|
|
16
|
+
emptyMessage,
|
|
17
|
+
}: {
|
|
18
|
+
actions: ActionStackItem[];
|
|
19
|
+
emptyMessage?: string;
|
|
20
|
+
}) {
|
|
21
|
+
if (actions.length === 0) {
|
|
22
|
+
return emptyMessage ? (
|
|
23
|
+
<p className="text-body text-muted-foreground">{emptyMessage}</p>
|
|
24
|
+
) : null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<div className="flex flex-col gap-inline">
|
|
29
|
+
{actions.map((action) => (
|
|
30
|
+
<ClickableButton
|
|
31
|
+
key={action.key}
|
|
32
|
+
type="button"
|
|
33
|
+
variant={action.variant}
|
|
34
|
+
fullWidth
|
|
35
|
+
onClick={action.onClick}
|
|
36
|
+
>
|
|
37
|
+
{action.label}
|
|
38
|
+
</ClickableButton>
|
|
39
|
+
))}
|
|
40
|
+
</div>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
type BadgeVariant =
|
|
4
|
+
| "default"
|
|
5
|
+
| "primary"
|
|
6
|
+
| "secondary"
|
|
7
|
+
| "success"
|
|
8
|
+
| "warning"
|
|
9
|
+
| "danger"
|
|
10
|
+
| "info"
|
|
11
|
+
| "accent";
|
|
12
|
+
|
|
13
|
+
export interface BadgeProps {
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
variant?: BadgeVariant;
|
|
16
|
+
className?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const badgeStyles: Record<BadgeVariant, string> = {
|
|
20
|
+
default: "bg-surface-muted text-muted-foreground",
|
|
21
|
+
primary: "bg-primary-light text-primary",
|
|
22
|
+
secondary: "bg-surface text-foreground border border-border",
|
|
23
|
+
success: "bg-success-light text-success-foreground",
|
|
24
|
+
warning: "bg-warning-light text-warning-foreground",
|
|
25
|
+
danger: "bg-danger-light text-danger-foreground",
|
|
26
|
+
info: "bg-info-light text-info-foreground",
|
|
27
|
+
accent: "bg-accent-light text-accent",
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default function Badge({
|
|
31
|
+
children,
|
|
32
|
+
variant = "default",
|
|
33
|
+
className = "",
|
|
34
|
+
}: BadgeProps) {
|
|
35
|
+
return (
|
|
36
|
+
<span
|
|
37
|
+
className={`inline-flex items-center justify-center rounded-full px-component py-micro text-label whitespace-nowrap ${badgeStyles[variant]} ${className}`}
|
|
38
|
+
>
|
|
39
|
+
{children}
|
|
40
|
+
</span>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes, ReactNode } from "react";
|
|
2
|
+
import Icon from "./icon";
|
|
3
|
+
|
|
4
|
+
export type ButtonVariant =
|
|
5
|
+
| "primary"
|
|
6
|
+
| "secondary"
|
|
7
|
+
| "ghost"
|
|
8
|
+
| "bare"
|
|
9
|
+
| "success"
|
|
10
|
+
| "warning"
|
|
11
|
+
| "danger"
|
|
12
|
+
| "info"
|
|
13
|
+
| "accent";
|
|
14
|
+
|
|
15
|
+
export type ButtonSize = "sm" | "md" | "lg" | "icon";
|
|
16
|
+
|
|
17
|
+
export interface ClickableButtonProps
|
|
18
|
+
extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
variant?: ButtonVariant;
|
|
21
|
+
/** Controls the height, padding and radius of the button. */
|
|
22
|
+
size?: ButtonSize;
|
|
23
|
+
/** Optional leading icon (replaced by a spinner while `loading`). */
|
|
24
|
+
leftIcon?: ReactNode;
|
|
25
|
+
/** Optional trailing icon. */
|
|
26
|
+
rightIcon?: ReactNode;
|
|
27
|
+
/** Shows a spinner, disables the button and prevents interactions. */
|
|
28
|
+
loading?: boolean;
|
|
29
|
+
/** Text displayed while `loading` (defaults to `children`). */
|
|
30
|
+
loadingText?: string;
|
|
31
|
+
/** Expands the button to fill the available width. */
|
|
32
|
+
fullWidth?: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const BASE_CLASS =
|
|
36
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-medium text-sm font-medium outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-60 [&_svg]:size-[var(--icon-small)] [&_svg]:shrink-0 [&_svg]:text-current";
|
|
37
|
+
|
|
38
|
+
const SIZE_CLASS: Record<ButtonSize, string> = {
|
|
39
|
+
sm: "h-9 px-3",
|
|
40
|
+
md: "h-10 px-4",
|
|
41
|
+
lg: "h-11 px-5",
|
|
42
|
+
/* Icon-only button: square, no horizontal padding. */
|
|
43
|
+
icon: "h-10 w-10 px-0",
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const VARIANT_CLASS: Record<ButtonVariant, string> = {
|
|
47
|
+
primary:
|
|
48
|
+
"bg-primary text-white hover:bg-primary-hover active:bg-primary-active focus-visible:ring-primary",
|
|
49
|
+
secondary:
|
|
50
|
+
"border border-border bg-surface text-foreground hover:border-primary hover:text-primary focus-visible:ring-primary",
|
|
51
|
+
ghost:
|
|
52
|
+
"bg-transparent text-muted-foreground hover:text-primary focus-visible:ring-primary",
|
|
53
|
+
success:
|
|
54
|
+
"bg-success text-white hover:brightness-90 active:brightness-80 focus-visible:ring-success",
|
|
55
|
+
warning:
|
|
56
|
+
"bg-warning text-white hover:brightness-90 active:brightness-80 focus-visible:ring-warning",
|
|
57
|
+
danger:
|
|
58
|
+
"bg-danger text-white hover:brightness-90 active:brightness-80 focus-visible:ring-danger",
|
|
59
|
+
info: "bg-info text-white hover:brightness-90 active:brightness-80 focus-visible:ring-info",
|
|
60
|
+
accent:
|
|
61
|
+
"bg-accent text-accent-foreground hover:bg-accent-hover active:brightness-80 focus-visible:ring-accent",
|
|
62
|
+
/* No built-in styles: the caller provides everything via className. */
|
|
63
|
+
bare: "",
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export default function ClickableButton({
|
|
67
|
+
children,
|
|
68
|
+
variant = "primary",
|
|
69
|
+
size = "md",
|
|
70
|
+
leftIcon,
|
|
71
|
+
rightIcon,
|
|
72
|
+
loading = false,
|
|
73
|
+
loadingText,
|
|
74
|
+
fullWidth = false,
|
|
75
|
+
disabled,
|
|
76
|
+
className = "",
|
|
77
|
+
...props
|
|
78
|
+
}: ClickableButtonProps) {
|
|
79
|
+
const isDisabled = disabled || loading;
|
|
80
|
+
const resolvedLabel = loading && loadingText ? loadingText : children;
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<button
|
|
84
|
+
type="button"
|
|
85
|
+
aria-busy={loading || undefined}
|
|
86
|
+
disabled={isDisabled}
|
|
87
|
+
className={`${BASE_CLASS} ${VARIANT_CLASS[variant]} ${SIZE_CLASS[size]} ${fullWidth ? "w-full" : ""} ${className}`}
|
|
88
|
+
{...props}
|
|
89
|
+
>
|
|
90
|
+
{loading ? (
|
|
91
|
+
<Icon
|
|
92
|
+
name="LoaderCircle"
|
|
93
|
+
size="small"
|
|
94
|
+
className="animate-spin"
|
|
95
|
+
aria-hidden="true"
|
|
96
|
+
/>
|
|
97
|
+
) : (
|
|
98
|
+
leftIcon
|
|
99
|
+
)}
|
|
100
|
+
{resolvedLabel}
|
|
101
|
+
{!loading && rightIcon}
|
|
102
|
+
</button>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { SVGProps } from "react";
|
|
2
|
+
import { icons, type LucideIcon } from "lucide-react";
|
|
3
|
+
|
|
4
|
+
/* ------------------------------------------------------------------ */
|
|
5
|
+
/* Icon - centralized interface icon */
|
|
6
|
+
/* */
|
|
7
|
+
/* Single source of truth for icons. Only pick `name`, `variant` and */
|
|
8
|
+
/* `size` from the allowed values defined by the Design System. */
|
|
9
|
+
/* ------------------------------------------------------------------ */
|
|
10
|
+
|
|
11
|
+
/** Available icon sizes from the Iconography section. */
|
|
12
|
+
export type IconSize = "small" | "default" | "large" | "display";
|
|
13
|
+
|
|
14
|
+
/** Available icon variants, aligned with the Design System colors. */
|
|
15
|
+
export type IconVariant =
|
|
16
|
+
| "default"
|
|
17
|
+
| "muted"
|
|
18
|
+
| "primary"
|
|
19
|
+
| "success"
|
|
20
|
+
| "warning"
|
|
21
|
+
| "danger"
|
|
22
|
+
| "white";
|
|
23
|
+
|
|
24
|
+
/** Every exported Lucide icon name (e.g. "Search", "ArrowRight"). */
|
|
25
|
+
export type IconName = keyof typeof icons;
|
|
26
|
+
|
|
27
|
+
export interface IconProps extends Omit<SVGProps<SVGSVGElement>, "size"> {
|
|
28
|
+
/** The Lucide icon name to render. */
|
|
29
|
+
name: IconName;
|
|
30
|
+
/** Color variant; defaults to a neutral foreground icon. */
|
|
31
|
+
variant?: IconVariant;
|
|
32
|
+
/** Size variant following the Iconography tokens. */
|
|
33
|
+
size?: IconSize;
|
|
34
|
+
/** Overrides the Design System default stroke weight (1.8). */
|
|
35
|
+
strokeWidth?: number;
|
|
36
|
+
className?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Fallback base class: keeps the icon from shrinking inside flex rows. */
|
|
40
|
+
const BASE_CLASS = "shrink-0";
|
|
41
|
+
|
|
42
|
+
const SIZE_CLASS: Record<IconSize, string> = {
|
|
43
|
+
small: "size-[var(--icon-small)]",
|
|
44
|
+
default: "size-[var(--icon-default)]",
|
|
45
|
+
large: "size-[var(--icon-large)]",
|
|
46
|
+
display: "size-[var(--icon-display)]",
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const VARIANT_CLASS: Record<IconVariant, string> = {
|
|
50
|
+
default: "text-foreground",
|
|
51
|
+
muted: "text-muted-foreground",
|
|
52
|
+
primary: "text-primary",
|
|
53
|
+
success: "text-success",
|
|
54
|
+
warning: "text-warning",
|
|
55
|
+
danger: "text-danger",
|
|
56
|
+
/* White icon intended for colored surfaces (nav items, brand badges). */
|
|
57
|
+
white: "text-white",
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export default function Icon({
|
|
61
|
+
name,
|
|
62
|
+
variant = "default",
|
|
63
|
+
size = "default",
|
|
64
|
+
strokeWidth = 1.8,
|
|
65
|
+
className = "",
|
|
66
|
+
...props
|
|
67
|
+
}: IconProps) {
|
|
68
|
+
const IconComponent: LucideIcon = icons[name];
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<IconComponent
|
|
72
|
+
aria-hidden="true"
|
|
73
|
+
strokeWidth={strokeWidth}
|
|
74
|
+
className={`${BASE_CLASS} ${SIZE_CLASS[size]} ${VARIANT_CLASS[variant]} ${className}`}
|
|
75
|
+
{...props}
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export { default as ClickableButton } from "./button";
|
|
2
|
+
export type {
|
|
3
|
+
ClickableButtonProps,
|
|
4
|
+
ButtonVariant,
|
|
5
|
+
ButtonSize,
|
|
6
|
+
} from "./button";
|
|
7
|
+
export { default as Input, Textarea } from "./input";
|
|
8
|
+
export type { InputState, InputProps, TextareaProps } from "./input";
|
|
9
|
+
export {default as Badge} from "./badge";
|
|
10
|
+
export type {BadgeProps} from "./badge";
|
|
11
|
+
export {default as UserTable} from "./user-table";
|
|
12
|
+
export type {Column, CardAction, UserTableCardActions} from "./user-table";
|
|
13
|
+
export { Select, MultiSelect, SelectWithSearch, MultiSelectWithSearch, SelectFilter } from "./select";
|
|
14
|
+
export type { SelectOption } from "./select";
|
|
15
|
+
export { default as Modal } from "./modal";
|
|
16
|
+
export { default as Tabs } from "./tab";
|
|
17
|
+
export type { Tab } from "./tab";
|
|
18
|
+
export { default as Icon } from "./icon";
|
|
19
|
+
export type { IconName, IconVariant, IconSize, IconProps } from "./icon";
|
|
20
|
+
export { default as Loader } from "./loader";
|
|
21
|
+
export type { LoaderProps } from "./loader";
|
|
22
|
+
export { default as MetricBar } from "./metric-bar";
|
|
23
|
+
export type { MetricTone } from "./metric-bar";
|
|
24
|
+
export { default as Stepper } from "./stepper";
|
|
25
|
+
export type { StepperStepState } from "./stepper";
|
|
26
|
+
export { default as ActionStack } from "./action-stack";
|
|
27
|
+
export type { ActionStackItem } from "./action-stack";
|
|
28
|
+
|