create-modoock-app 2.3.1 → 2.5.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/README.md +19 -7
- package/package.json +1 -1
- package/template/app/(main)/components/_shared.tsx +602 -0
- package/template/app/(main)/components/agenda/page.tsx +48 -0
- package/template/app/(main)/components/badges/page.tsx +42 -0
- package/template/app/(main)/components/barres-de-metrique/page.tsx +40 -0
- package/template/app/(main)/components/boutons/page.tsx +142 -0
- package/template/app/(main)/components/champs/page.tsx +175 -0
- package/template/app/(main)/components/date-picker/page.tsx +48 -0
- package/template/app/(main)/components/icones/page.tsx +96 -0
- package/template/app/(main)/components/loader/page.tsx +81 -0
- package/template/app/(main)/components/modale/page.tsx +48 -0
- package/template/app/(main)/components/onglets/page.tsx +36 -0
- package/template/app/(main)/components/page.tsx +130 -825
- package/template/app/(main)/components/selecteurs/page.tsx +49 -0
- package/template/app/(main)/components/stepper/page.tsx +69 -0
- package/template/app/(main)/components/tableau/page.tsx +67 -0
- package/template/app/(main)/design-system/page.tsx +15 -3
- package/template/app/(main)/documentation/page.tsx +413 -0
- package/template/app/(main)/layout.tsx +2 -0
- package/template/app/globals.css +3 -3
- package/template/app/layout.tsx +1 -1
- package/template/components/layout/side-nav.tsx +118 -61
- package/template/lib/scroll-to-section.ts +38 -0
- package/template/next.config.ts +0 -17
- package/template/package-lock.json +459 -314
- package/template/package.json +2 -0
- package/template/sgconfig.yml +1 -1
- package/template/tsconfig.json +41 -71
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { useEffect, useRef, useState, type KeyboardEvent as ReactKeyboardEvent } from "react";
|
|
4
|
+
import Image from "next/image";
|
|
4
5
|
import { usePathname, useRouter } from "next/navigation";
|
|
5
6
|
import { Icon } from "@modoock/components";
|
|
6
7
|
import type { IconName } from "@modoock/components";
|
|
8
|
+
import { scrollAppMainToIdWhenReady } from "@/lib/scroll-to-section";
|
|
7
9
|
|
|
8
10
|
const MD_NAV = "(min-width: 56rem)";
|
|
9
11
|
const DESKTOP_NAV = "(min-width: 1024px)";
|
|
@@ -24,10 +26,63 @@ interface NavItem {
|
|
|
24
26
|
|
|
25
27
|
const NAV_ITEMS: NavItem[] = [
|
|
26
28
|
{ label: "Accueil", href: "/", icon: "Flame" },
|
|
27
|
-
{
|
|
28
|
-
|
|
29
|
+
{
|
|
30
|
+
label: "Documentation",
|
|
31
|
+
href: "/documentation",
|
|
32
|
+
icon: "BookOpen",
|
|
33
|
+
children: [
|
|
34
|
+
{ label: "Fondations", href: "/documentation#fondations" },
|
|
35
|
+
{ label: "Approche", href: "/documentation#approche" },
|
|
36
|
+
{ label: "Parcours", href: "/documentation#parcours" },
|
|
37
|
+
{ label: "Principes", href: "/documentation#principes" },
|
|
38
|
+
{ label: "Suite", href: "/documentation#suite" },
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
{ label: "Design System", href: "/design-system", icon: "Palette",
|
|
42
|
+
children: [
|
|
43
|
+
{ label: "Couleurs", href: "/design-system#colors" },
|
|
44
|
+
{ label: "Typographie", href: "/design-system#typography" },
|
|
45
|
+
{ label: "Espacements", href: "/design-system#spacing" },
|
|
46
|
+
{ label: "Rayons", href: "/design-system#border-radius" },
|
|
47
|
+
{ label: "Iconographie", href: "/design-system#iconography" },
|
|
48
|
+
{ label: "Mise en page", href: "/design-system#layout-rules" },
|
|
49
|
+
{ label: "Tailles", href: "/design-system#sizing-principle" },
|
|
50
|
+
{ label: "Hiérarchie", href: "/design-system#visual-hierarchy" },
|
|
51
|
+
{ label: "États sémantiques", href: "/design-system#semantic-states" },
|
|
52
|
+
{ label: "Exemple complet", href: "/design-system#complete-example" },
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
label: "Composants",
|
|
57
|
+
href: "/components",
|
|
58
|
+
icon: "Puzzle",
|
|
59
|
+
children: [
|
|
60
|
+
{ label: "Champs de saisie", href: "/components/champs" },
|
|
61
|
+
{ label: "Boutons", href: "/components/boutons" },
|
|
62
|
+
{ label: "Icônes", href: "/components/icones" },
|
|
63
|
+
{ label: "Loader", href: "/components/loader" },
|
|
64
|
+
{ label: "Badges", href: "/components/badges" },
|
|
65
|
+
{ label: "Sélecteurs", href: "/components/selecteurs" },
|
|
66
|
+
{ label: "Sélecteurs de date", href: "/components/date-picker" },
|
|
67
|
+
{ label: "Agenda", href: "/components/agenda" },
|
|
68
|
+
{ label: "Onglets", href: "/components/onglets" },
|
|
69
|
+
{ label: "Modale", href: "/components/modale" },
|
|
70
|
+
{ label: "Barres de métrique", href: "/components/barres-de-metrique" },
|
|
71
|
+
{ label: "Stepper", href: "/components/stepper" },
|
|
72
|
+
{ label: "Tableau", href: "/components/tableau" },
|
|
73
|
+
],
|
|
74
|
+
},
|
|
29
75
|
];
|
|
30
76
|
|
|
77
|
+
function pathOf(href: string) {
|
|
78
|
+
return href.split("#")[0] || href;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function hashOf(href: string) {
|
|
82
|
+
const i = href.indexOf("#");
|
|
83
|
+
return i === -1 ? "" : href.slice(i);
|
|
84
|
+
}
|
|
85
|
+
|
|
31
86
|
interface SideNavProps {
|
|
32
87
|
collapsed: boolean;
|
|
33
88
|
onCollapsedChange: (collapsed: boolean) => void;
|
|
@@ -38,6 +93,7 @@ export default function SideNav({
|
|
|
38
93
|
onCollapsedChange,
|
|
39
94
|
}: SideNavProps) {
|
|
40
95
|
const [expanded, setExpanded] = useState<Record<string, boolean>>({});
|
|
96
|
+
const [hash, setHash] = useState("");
|
|
41
97
|
const [isMdUp, setIsMdUp] = useState(true);
|
|
42
98
|
const navRef = useRef<HTMLElement>(null);
|
|
43
99
|
const previousFocusRef = useRef<HTMLElement | null>(null);
|
|
@@ -46,6 +102,13 @@ export default function SideNav({
|
|
|
46
102
|
const drawerOpen = !collapsed && !isMdUp;
|
|
47
103
|
const showLabels = !collapsed || !isMdUp;
|
|
48
104
|
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
const syncHash = () => setHash(window.location.hash);
|
|
107
|
+
syncHash();
|
|
108
|
+
window.addEventListener("hashchange", syncHash);
|
|
109
|
+
return () => window.removeEventListener("hashchange", syncHash);
|
|
110
|
+
}, []);
|
|
111
|
+
|
|
49
112
|
useEffect(() => {
|
|
50
113
|
const desktop = window.matchMedia(DESKTOP_NAV);
|
|
51
114
|
const md = window.matchMedia(MD_NAV);
|
|
@@ -102,6 +165,11 @@ export default function SideNav({
|
|
|
102
165
|
|
|
103
166
|
const handleNavigate = (href: string) => {
|
|
104
167
|
router.push(href);
|
|
168
|
+
const sectionHash = hashOf(href);
|
|
169
|
+
if (sectionHash) {
|
|
170
|
+
setHash(sectionHash);
|
|
171
|
+
scrollAppMainToIdWhenReady(sectionHash.slice(1));
|
|
172
|
+
}
|
|
105
173
|
if (!window.matchMedia(DESKTOP_NAV).matches) {
|
|
106
174
|
onCollapsedChange(true);
|
|
107
175
|
}
|
|
@@ -111,19 +179,6 @@ export default function SideNav({
|
|
|
111
179
|
setExpanded((prev) => ({ ...prev, [href]: !prev[href] }));
|
|
112
180
|
};
|
|
113
181
|
|
|
114
|
-
useEffect(() => {
|
|
115
|
-
const parent = NAV_ITEMS.find(
|
|
116
|
-
(item) =>
|
|
117
|
-
!!item.children?.length &&
|
|
118
|
-
(item.href === pathname ||
|
|
119
|
-
item.children.some((child) => child.href === pathname)),
|
|
120
|
-
);
|
|
121
|
-
if (!parent) return;
|
|
122
|
-
setExpanded((prev) =>
|
|
123
|
-
prev[parent.href] ? prev : { ...prev, [parent.href]: true },
|
|
124
|
-
);
|
|
125
|
-
}, [pathname]);
|
|
126
|
-
|
|
127
182
|
return (
|
|
128
183
|
<>
|
|
129
184
|
<div
|
|
@@ -154,9 +209,14 @@ export default function SideNav({
|
|
|
154
209
|
}`}
|
|
155
210
|
>
|
|
156
211
|
{showLabels ? (
|
|
157
|
-
<
|
|
158
|
-
|
|
159
|
-
|
|
212
|
+
<Image
|
|
213
|
+
src="/identity/full_logo_white.svg"
|
|
214
|
+
alt="Modoock"
|
|
215
|
+
width={168}
|
|
216
|
+
height={46}
|
|
217
|
+
className="h-9 w-auto"
|
|
218
|
+
priority
|
|
219
|
+
/>
|
|
160
220
|
) : null}
|
|
161
221
|
<button
|
|
162
222
|
type="button"
|
|
@@ -165,9 +225,9 @@ export default function SideNav({
|
|
|
165
225
|
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"
|
|
166
226
|
>
|
|
167
227
|
{collapsed ? (
|
|
168
|
-
<Icon name="PanelLeftOpen"
|
|
228
|
+
<Icon name="PanelLeftOpen" aria-hidden="true" />
|
|
169
229
|
) : (
|
|
170
|
-
<Icon name="PanelLeftClose"
|
|
230
|
+
<Icon name="PanelLeftClose" aria-hidden="true" />
|
|
171
231
|
)}
|
|
172
232
|
</button>
|
|
173
233
|
</div>
|
|
@@ -176,57 +236,54 @@ export default function SideNav({
|
|
|
176
236
|
<div className="nav-scrollbar flex flex-1 flex-col gap-1 overflow-y-auto overscroll-contain px-2 py-2">
|
|
177
237
|
{NAV_ITEMS.map((item) => {
|
|
178
238
|
const hasChildren = !!item.children?.length;
|
|
179
|
-
const
|
|
180
|
-
const isActive =
|
|
239
|
+
const isRouteActive =
|
|
181
240
|
pathname === item.href ||
|
|
182
|
-
(item.
|
|
241
|
+
(item.href !== "/" && pathname.startsWith(`${item.href}/`)) ||
|
|
242
|
+
(item.children ?? []).some(
|
|
243
|
+
(child) => pathOf(child.href) === pathname,
|
|
244
|
+
);
|
|
245
|
+
const isOpen = expanded[item.href] ?? isRouteActive;
|
|
246
|
+
const isActive = isRouteActive;
|
|
183
247
|
|
|
184
248
|
return (
|
|
185
249
|
<div key={item.href} className="flex flex-col gap-1">
|
|
186
|
-
<
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
250
|
+
<button
|
|
251
|
+
type="button"
|
|
252
|
+
onClick={() => {
|
|
253
|
+
if (hasChildren && showLabels) {
|
|
254
|
+
toggleGroup(item.href);
|
|
255
|
+
}
|
|
256
|
+
handleNavigate(item.href);
|
|
257
|
+
}}
|
|
258
|
+
title={item.label}
|
|
259
|
+
aria-label={showLabels ? undefined : item.label}
|
|
260
|
+
aria-expanded={hasChildren && showLabels ? isOpen : undefined}
|
|
261
|
+
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 ${
|
|
262
|
+
isActive
|
|
263
|
+
? "bg-white/15 text-white"
|
|
264
|
+
: "text-white/80 hover:bg-white/10 hover:text-white"
|
|
265
|
+
} ${showLabels ? "" : "justify-center"}`}
|
|
190
266
|
>
|
|
191
|
-
<
|
|
192
|
-
|
|
193
|
-
onClick={() => {
|
|
194
|
-
if (hasChildren) {
|
|
195
|
-
setExpanded((prev) => ({ ...prev, [item.href]: true }));
|
|
196
|
-
}
|
|
197
|
-
handleNavigate(item.href);
|
|
198
|
-
}}
|
|
199
|
-
title={item.label}
|
|
200
|
-
aria-label={showLabels ? undefined : item.label}
|
|
201
|
-
className={`flex min-w-0 flex-1 items-center gap-3 rounded-small px-3 py-2 text-left text-body-medium transition-colors hover:bg-white/10 hover:text-white focus-visible:ring-2 focus-visible:ring-white [&_svg]:shrink-0 [&_svg]:text-current ${
|
|
202
|
-
showLabels ? "" : "justify-center"
|
|
203
|
-
}`}
|
|
204
|
-
>
|
|
205
|
-
<Icon name={item.icon} variant="white" aria-hidden="true" />
|
|
206
|
-
{showLabels ? <span className="truncate">{item.label}</span> : null}
|
|
207
|
-
</button>
|
|
267
|
+
<Icon name={item.icon} aria-hidden="true" />
|
|
268
|
+
{showLabels ? <span className="truncate">{item.label}</span> : null}
|
|
208
269
|
{hasChildren && showLabels ? (
|
|
209
|
-
<
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
<Icon
|
|
217
|
-
name="ChevronDown"
|
|
218
|
-
variant="white"
|
|
219
|
-
aria-hidden="true"
|
|
220
|
-
className={`transition-transform ${isOpen ? "rotate-180" : ""}`}
|
|
221
|
-
/>
|
|
222
|
-
</button>
|
|
270
|
+
<Icon
|
|
271
|
+
name="ChevronDown"
|
|
272
|
+
aria-hidden="true"
|
|
273
|
+
className={`ml-auto transition-transform ${
|
|
274
|
+
isOpen ? "rotate-180" : ""
|
|
275
|
+
}`}
|
|
276
|
+
/>
|
|
223
277
|
) : null}
|
|
224
|
-
</
|
|
278
|
+
</button>
|
|
225
279
|
|
|
226
280
|
{hasChildren && showLabels && isOpen ? (
|
|
227
281
|
<div className="ml-5 flex flex-col gap-1 border-l border-white/20 pl-2">
|
|
228
282
|
{item.children!.map((child) => {
|
|
229
|
-
const
|
|
283
|
+
const childHash = hashOf(child.href);
|
|
284
|
+
const isChildActive = childHash
|
|
285
|
+
? pathname === pathOf(child.href) && hash === childHash
|
|
286
|
+
: pathname === child.href;
|
|
230
287
|
return (
|
|
231
288
|
<button
|
|
232
289
|
key={child.href}
|
|
@@ -252,7 +309,7 @@ export default function SideNav({
|
|
|
252
309
|
|
|
253
310
|
{/* Footer placeholder */}
|
|
254
311
|
<div className="p-4 text-small text-white/60">
|
|
255
|
-
{showLabels ? <span>
|
|
312
|
+
{showLabels ? <span>v2.4.0</span> : null}
|
|
256
313
|
</div>
|
|
257
314
|
</nav>
|
|
258
315
|
</>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** Scroll `#app-main` to an element id with an eased animation. */
|
|
2
|
+
export function scrollAppMainToId(id: string, durationMs = 700) {
|
|
3
|
+
const main = document.getElementById("app-main");
|
|
4
|
+
const el = document.getElementById(id);
|
|
5
|
+
if (!main || !el) return false;
|
|
6
|
+
|
|
7
|
+
const target =
|
|
8
|
+
el.getBoundingClientRect().top -
|
|
9
|
+
main.getBoundingClientRect().top +
|
|
10
|
+
main.scrollTop -
|
|
11
|
+
12;
|
|
12
|
+
const start = main.scrollTop;
|
|
13
|
+
const delta = Math.max(0, target) - start;
|
|
14
|
+
if (Math.abs(delta) < 1) return true;
|
|
15
|
+
|
|
16
|
+
const startTime = performance.now();
|
|
17
|
+
const easeInOutCubic = (t: number) =>
|
|
18
|
+
t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
|
|
19
|
+
|
|
20
|
+
const step = (now: number) => {
|
|
21
|
+
const t = Math.min(1, (now - startTime) / durationMs);
|
|
22
|
+
main.scrollTop = start + delta * easeInOutCubic(t);
|
|
23
|
+
if (t < 1) requestAnimationFrame(step);
|
|
24
|
+
};
|
|
25
|
+
requestAnimationFrame(step);
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Retry until the section exists (e.g. after a route change). */
|
|
30
|
+
export function scrollAppMainToIdWhenReady(id: string, durationMs = 700) {
|
|
31
|
+
if (scrollAppMainToId(id, durationMs)) return;
|
|
32
|
+
let tries = 0;
|
|
33
|
+
const tick = () => {
|
|
34
|
+
if (scrollAppMainToId(id, durationMs) || ++tries > 20) return;
|
|
35
|
+
requestAnimationFrame(tick);
|
|
36
|
+
};
|
|
37
|
+
requestAnimationFrame(tick);
|
|
38
|
+
}
|
package/template/next.config.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { NextConfig } from "next";
|
|
2
|
-
import path from "node:path";
|
|
3
2
|
import { networkInterfaces } from "node:os";
|
|
4
3
|
|
|
5
4
|
function lanHostnames(): string[] {
|
|
@@ -15,24 +14,8 @@ function lanHostnames(): string[] {
|
|
|
15
14
|
return [...hosts];
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
const monorepoRoot = path.join(__dirname, "..", "..");
|
|
19
|
-
|
|
20
17
|
const nextConfig: NextConfig = {
|
|
21
18
|
allowedDevOrigins: lanHostnames(),
|
|
22
|
-
experimental: {
|
|
23
|
-
externalDir: true,
|
|
24
|
-
},
|
|
25
|
-
turbopack: {
|
|
26
|
-
root: monorepoRoot,
|
|
27
|
-
resolveAlias: {
|
|
28
|
-
"@/components/ui": "../../components/components/ui",
|
|
29
|
-
react: "./node_modules/react",
|
|
30
|
-
"react/jsx-runtime": "./node_modules/react/jsx-runtime.js",
|
|
31
|
-
"react/jsx-dev-runtime": "./node_modules/react/jsx-dev-runtime.js",
|
|
32
|
-
"react-dom": "./node_modules/react-dom",
|
|
33
|
-
"lucide-react": "./node_modules/lucide-react",
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
19
|
};
|
|
37
20
|
|
|
38
21
|
export default nextConfig;
|