create-modoock-app 2.5.0 → 2.7.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/commands/update.js +118 -78
- package/dist/constants.js +6 -1
- package/dist/utils/metadata.js +26 -4
- package/package.json +1 -1
- package/template/app/(main)/components/avatar/page.tsx +106 -0
- package/template/app/(main)/components/graphiques/page.tsx +219 -0
- package/template/app/(main)/components/infobulle/page.tsx +99 -0
- package/template/app/(main)/components/interrupteur/page.tsx +92 -0
- package/template/app/(main)/components/page.tsx +36 -0
- package/template/app/(main)/components/tiroir/page.tsx +100 -0
- package/template/app/(main)/components/toasts/page.tsx +165 -0
- package/template/app/(main)/design-system/page.tsx +1 -1
- package/template/app/globals.css +2 -4
- package/template/app/layout.tsx +2 -0
- package/template/components/layout/header.tsx +337 -6
- package/template/components/layout/index.ts +1 -0
- package/template/components/layout/side-nav.tsx +243 -105
- package/template/components/layout/toaster-host.tsx +8 -0
- package/template/next.config.ts +12 -0
- package/template/package-lock.json +425 -17
- package/template/package.json +4 -3
package/dist/commands/update.js
CHANGED
|
@@ -27,24 +27,111 @@ function askQuestion(question) {
|
|
|
27
27
|
function getTemplateDirectory() {
|
|
28
28
|
return node_path_1.default.resolve(__dirname, "..", "..", "template");
|
|
29
29
|
}
|
|
30
|
+
function normalizePath(relativePath) {
|
|
31
|
+
return relativePath.replace(/\\/g, "/");
|
|
32
|
+
}
|
|
30
33
|
function shouldIgnorePath(relativePath) {
|
|
31
|
-
const normalized = relativePath
|
|
32
|
-
|
|
33
|
-
constants_1.MODOOCK_DIRECTORY)
|
|
34
|
-
|
|
34
|
+
const normalized = normalizePath(relativePath);
|
|
35
|
+
return (normalized === constants_1.MODOOCK_DIRECTORY ||
|
|
36
|
+
normalized.startsWith(`${constants_1.MODOOCK_DIRECTORY}/`) ||
|
|
37
|
+
normalized === "package.json" ||
|
|
38
|
+
normalized === "package-lock.json" ||
|
|
39
|
+
normalized === "node_modules" ||
|
|
40
|
+
normalized.startsWith("node_modules/"));
|
|
41
|
+
}
|
|
42
|
+
function isManagedDirectory(relativePath) {
|
|
43
|
+
const normalized = normalizePath(relativePath);
|
|
44
|
+
return constants_1.MANAGED_DIRECTORIES.some((directory) => {
|
|
45
|
+
const managed = normalizePath(directory);
|
|
46
|
+
return (normalized === managed ||
|
|
47
|
+
normalized.startsWith(`${managed}/`));
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function copyTemplateFile(templatePath, projectPath) {
|
|
51
|
+
node_fs_1.default.mkdirSync(node_path_1.default.dirname(projectPath), {
|
|
52
|
+
recursive: true,
|
|
53
|
+
});
|
|
54
|
+
node_fs_1.default.copyFileSync(templatePath, projectPath);
|
|
55
|
+
}
|
|
56
|
+
async function syncManagedFile(targetDirectory, relativePath, managedFiles) {
|
|
57
|
+
const templatePath = node_path_1.default.join(getTemplateDirectory(), relativePath);
|
|
58
|
+
const projectPath = node_path_1.default.join(targetDirectory, relativePath);
|
|
59
|
+
if (!node_fs_1.default.existsSync(templatePath)) {
|
|
60
|
+
// Never delete project files when the template file disappears.
|
|
61
|
+
return;
|
|
35
62
|
}
|
|
36
|
-
if (
|
|
37
|
-
|
|
63
|
+
if (!node_fs_1.default.existsSync(projectPath)) {
|
|
64
|
+
copyTemplateFile(templatePath, projectPath);
|
|
65
|
+
console.log(`Added: ${relativePath}`);
|
|
66
|
+
return;
|
|
38
67
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
68
|
+
const originalHash = managedFiles[relativePath];
|
|
69
|
+
const currentHash = (0, files_1.getFileHash)(projectPath);
|
|
70
|
+
const templateHash = (0, files_1.getFileHash)(templatePath);
|
|
71
|
+
// Nothing changed in the template.
|
|
72
|
+
if (currentHash === templateHash) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
// The project file matches the last recorded baseline,
|
|
76
|
+
// so it is safe to update automatically.
|
|
77
|
+
if (originalHash && currentHash === originalHash) {
|
|
78
|
+
copyTemplateFile(templatePath, projectPath);
|
|
79
|
+
console.log(`Updated: ${relativePath}`);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
console.log("");
|
|
83
|
+
console.log(`⚠️ Local changes detected: ${relativePath}`);
|
|
84
|
+
console.log("[1] Keep my version");
|
|
85
|
+
console.log("[2] Replace with Modoock version");
|
|
86
|
+
console.log("");
|
|
87
|
+
const answer = await askQuestion("Choose an option (1/2): ");
|
|
88
|
+
if (answer === "1") {
|
|
89
|
+
console.log(`Kept local version: ${relativePath}`);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (answer !== "2") {
|
|
93
|
+
console.log(`Skipped: ${relativePath}`);
|
|
94
|
+
return;
|
|
42
95
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
96
|
+
console.log("");
|
|
97
|
+
console.log("⚠️ Your local file will be replaced.");
|
|
98
|
+
console.log("A backup will be created before replacement.");
|
|
99
|
+
const confirmation = await askQuestion("Continue? (y/N): ");
|
|
100
|
+
if (confirmation.toLowerCase() !== "y") {
|
|
101
|
+
console.log(`Skipped: ${relativePath}`);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const backupPath = (0, backup_1.createBackup)(targetDirectory, relativePath);
|
|
105
|
+
copyTemplateFile(templatePath, projectPath);
|
|
106
|
+
console.log(`Backup created: ${node_path_1.default.relative(targetDirectory, backupPath)}`);
|
|
107
|
+
console.log(`Updated: ${relativePath}`);
|
|
108
|
+
}
|
|
109
|
+
async function syncManagedDirectory(targetDirectory, relativeDirectory, managedFiles) {
|
|
110
|
+
const templateDirectory = node_path_1.default.join(getTemplateDirectory(), relativeDirectory);
|
|
111
|
+
const projectDirectory = node_path_1.default.join(targetDirectory, relativeDirectory);
|
|
112
|
+
if (!node_fs_1.default.existsSync(templateDirectory)) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
node_fs_1.default.mkdirSync(projectDirectory, { recursive: true });
|
|
116
|
+
const entries = node_fs_1.default.readdirSync(templateDirectory, {
|
|
117
|
+
withFileTypes: true,
|
|
118
|
+
});
|
|
119
|
+
for (const entry of entries) {
|
|
120
|
+
const relativePath = normalizePath(node_path_1.default.join(relativeDirectory, entry.name));
|
|
121
|
+
if (shouldIgnorePath(relativePath)) {
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
const templatePath = node_path_1.default.join(templateDirectory, entry.name);
|
|
125
|
+
const projectPath = node_path_1.default.join(projectDirectory, entry.name);
|
|
126
|
+
if (entry.isDirectory()) {
|
|
127
|
+
await syncManagedDirectory(targetDirectory, relativePath, managedFiles);
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
if (!entry.isFile()) {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
await syncManagedFile(targetDirectory, relativePath, managedFiles);
|
|
46
134
|
}
|
|
47
|
-
return false;
|
|
48
135
|
}
|
|
49
136
|
function syncNewFilesAndFolders(targetDirectory) {
|
|
50
137
|
const templateDirectory = getTemplateDirectory();
|
|
@@ -55,10 +142,12 @@ function syncNewFilesAndFolders(targetDirectory) {
|
|
|
55
142
|
for (const entry of node_fs_1.default.readdirSync(templateDirectoryPath, {
|
|
56
143
|
withFileTypes: true,
|
|
57
144
|
})) {
|
|
58
|
-
const relativePath = relativeDirectory
|
|
145
|
+
const relativePath = normalizePath(relativeDirectory
|
|
59
146
|
? node_path_1.default.join(relativeDirectory, entry.name)
|
|
60
|
-
: entry.name;
|
|
61
|
-
if (shouldIgnorePath(relativePath)
|
|
147
|
+
: entry.name);
|
|
148
|
+
if (shouldIgnorePath(relativePath) ||
|
|
149
|
+
isManagedDirectory(relativePath) ||
|
|
150
|
+
isManagedDirectory(`${relativePath}/placeholder`)) {
|
|
62
151
|
continue;
|
|
63
152
|
}
|
|
64
153
|
const templatePath = node_path_1.default.join(templateDirectoryPath, entry.name);
|
|
@@ -75,70 +164,13 @@ function syncNewFilesAndFolders(targetDirectory) {
|
|
|
75
164
|
continue;
|
|
76
165
|
}
|
|
77
166
|
if (!node_fs_1.default.existsSync(projectPath)) {
|
|
78
|
-
|
|
79
|
-
recursive: true,
|
|
80
|
-
});
|
|
81
|
-
node_fs_1.default.copyFileSync(templatePath, projectPath);
|
|
167
|
+
copyTemplateFile(templatePath, projectPath);
|
|
82
168
|
console.log(`Added file: ${relativePath}`);
|
|
83
169
|
}
|
|
84
170
|
}
|
|
85
171
|
}
|
|
86
172
|
syncDirectory(templateDirectory, targetDirectory, "");
|
|
87
173
|
}
|
|
88
|
-
async function updateManagedFiles(targetDirectory, metadata) {
|
|
89
|
-
const templateDirectory = getTemplateDirectory();
|
|
90
|
-
for (const relativePath of constants_1.MANAGED_FILES) {
|
|
91
|
-
const templatePath = node_path_1.default.join(templateDirectory, relativePath);
|
|
92
|
-
const projectPath = node_path_1.default.join(targetDirectory, relativePath);
|
|
93
|
-
if (!node_fs_1.default.existsSync(templatePath)) {
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
if (!node_fs_1.default.existsSync(projectPath)) {
|
|
97
|
-
node_fs_1.default.mkdirSync(node_path_1.default.dirname(projectPath), {
|
|
98
|
-
recursive: true,
|
|
99
|
-
});
|
|
100
|
-
node_fs_1.default.copyFileSync(templatePath, projectPath);
|
|
101
|
-
console.log(`Added: ${relativePath}`);
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
const originalHash = metadata.managedFiles?.[relativePath];
|
|
105
|
-
const currentHash = (0, files_1.getFileHash)(projectPath);
|
|
106
|
-
if (originalHash &&
|
|
107
|
-
currentHash ===
|
|
108
|
-
originalHash) {
|
|
109
|
-
node_fs_1.default.copyFileSync(templatePath, projectPath);
|
|
110
|
-
console.log(`Updated: ${relativePath}`);
|
|
111
|
-
continue;
|
|
112
|
-
}
|
|
113
|
-
console.log("");
|
|
114
|
-
console.log(`⚠️ Local changes detected: ${relativePath}`);
|
|
115
|
-
console.log("[1] Keep my version");
|
|
116
|
-
console.log("[2] Replace with Modoock version");
|
|
117
|
-
console.log("");
|
|
118
|
-
const answer = await askQuestion("Choose an option (1/2): ");
|
|
119
|
-
if (answer === "1") {
|
|
120
|
-
console.log(`Kept local version: ${relativePath}`);
|
|
121
|
-
continue;
|
|
122
|
-
}
|
|
123
|
-
if (answer === "2") {
|
|
124
|
-
console.log("");
|
|
125
|
-
console.log("⚠️ Your local file will be replaced.");
|
|
126
|
-
console.log("A backup will be created before replacement.");
|
|
127
|
-
const confirmation = await askQuestion("Continue? (y/N): ");
|
|
128
|
-
if (confirmation.toLowerCase() !==
|
|
129
|
-
"y") {
|
|
130
|
-
console.log(`Skipped: ${relativePath}`);
|
|
131
|
-
continue;
|
|
132
|
-
}
|
|
133
|
-
const backupPath = (0, backup_1.createBackup)(targetDirectory, relativePath);
|
|
134
|
-
node_fs_1.default.copyFileSync(templatePath, projectPath);
|
|
135
|
-
console.log(`Backup created: ${node_path_1.default.relative(targetDirectory, backupPath)}`);
|
|
136
|
-
console.log(`Updated: ${relativePath}`);
|
|
137
|
-
continue;
|
|
138
|
-
}
|
|
139
|
-
console.log(`Skipped: ${relativePath}`);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
174
|
function updateProjectPackageJson(targetDirectory) {
|
|
143
175
|
const packageJsonPath = node_path_1.default.join(targetDirectory, "package.json");
|
|
144
176
|
const packageJson = JSON.parse(node_fs_1.default.readFileSync(packageJsonPath, "utf8"));
|
|
@@ -156,11 +188,19 @@ async function updateProject() {
|
|
|
156
188
|
const metadata = (0, metadata_1.readModoockMetadata)(targetDirectory);
|
|
157
189
|
console.log(`Current Modoock generator version: ${metadata.generatorVersion}`);
|
|
158
190
|
console.log("");
|
|
159
|
-
//
|
|
160
|
-
|
|
191
|
+
// Sync files inside the explicitly managed directories.
|
|
192
|
+
for (const directory of constants_1.MANAGED_DIRECTORIES) {
|
|
193
|
+
await syncManagedDirectory(targetDirectory, directory, metadata.managedFiles ?? {});
|
|
194
|
+
}
|
|
195
|
+
// Preserve the existing behavior for other new template files.
|
|
161
196
|
syncNewFilesAndFolders(targetDirectory);
|
|
162
|
-
// Update explicitly managed files.
|
|
163
|
-
|
|
197
|
+
// Update explicitly managed standalone files.
|
|
198
|
+
for (const relativePath of constants_1.MANAGED_FILES) {
|
|
199
|
+
if (isManagedDirectory(relativePath)) {
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
await syncManagedFile(targetDirectory, relativePath, metadata.managedFiles ?? {});
|
|
203
|
+
}
|
|
164
204
|
console.log("");
|
|
165
205
|
console.log("Updating Modoock dependencies...");
|
|
166
206
|
updateProjectPackageJson(targetDirectory);
|
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.METADATA_FILE = exports.MODOOCK_DIRECTORY = exports.MANAGED_FILES = exports.MODOOCK_PACKAGES = void 0;
|
|
3
|
+
exports.METADATA_FILE = exports.MODOOCK_DIRECTORY = exports.MANAGED_DIRECTORIES = exports.MANAGED_FILES = exports.MODOOCK_PACKAGES = void 0;
|
|
4
4
|
exports.MODOOCK_PACKAGES = [
|
|
5
5
|
"@modoock/components",
|
|
6
6
|
"@modoock/knowledge-base",
|
|
@@ -19,5 +19,10 @@ exports.MANAGED_FILES = [
|
|
|
19
19
|
"README.md",
|
|
20
20
|
"tsconfig.json"
|
|
21
21
|
];
|
|
22
|
+
exports.MANAGED_DIRECTORIES = [
|
|
23
|
+
"app/(main)/components",
|
|
24
|
+
"app/(main)/design-system",
|
|
25
|
+
"app/(main)/documentation",
|
|
26
|
+
];
|
|
22
27
|
exports.MODOOCK_DIRECTORY = ".modoock";
|
|
23
28
|
exports.METADATA_FILE = "project.json";
|
package/dist/utils/metadata.js
CHANGED
|
@@ -18,13 +18,35 @@ function getPackageVersion() {
|
|
|
18
18
|
}
|
|
19
19
|
function getManagedFileHashes(targetDirectory) {
|
|
20
20
|
const hashes = {};
|
|
21
|
-
|
|
21
|
+
function addFileHash(relativePath) {
|
|
22
22
|
const filePath = node_path_1.default.join(targetDirectory, relativePath);
|
|
23
|
-
if (node_fs_1.default.existsSync(filePath)) {
|
|
24
|
-
hashes[relativePath] =
|
|
25
|
-
|
|
23
|
+
if (node_fs_1.default.existsSync(filePath) && node_fs_1.default.statSync(filePath).isFile()) {
|
|
24
|
+
hashes[relativePath] = (0, files_1.getFileHash)(filePath);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function scanDirectory(relativeDirectory) {
|
|
28
|
+
const directoryPath = node_path_1.default.join(targetDirectory, relativeDirectory);
|
|
29
|
+
if (!node_fs_1.default.existsSync(directoryPath)) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
for (const entry of node_fs_1.default.readdirSync(directoryPath, {
|
|
33
|
+
withFileTypes: true,
|
|
34
|
+
})) {
|
|
35
|
+
const relativePath = node_path_1.default.join(relativeDirectory, entry.name);
|
|
36
|
+
if (entry.isDirectory()) {
|
|
37
|
+
scanDirectory(relativePath);
|
|
38
|
+
}
|
|
39
|
+
else if (entry.isFile()) {
|
|
40
|
+
addFileHash(relativePath);
|
|
41
|
+
}
|
|
26
42
|
}
|
|
27
43
|
}
|
|
44
|
+
for (const relativePath of constants_1.MANAGED_FILES) {
|
|
45
|
+
addFileHash(relativePath);
|
|
46
|
+
}
|
|
47
|
+
for (const relativeDirectory of constants_1.MANAGED_DIRECTORIES) {
|
|
48
|
+
scanDirectory(relativeDirectory);
|
|
49
|
+
}
|
|
28
50
|
return hashes;
|
|
29
51
|
}
|
|
30
52
|
function writeModoockMetadata(targetDirectory) {
|
package/package.json
CHANGED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Avatar, AvatarGroup } from "@modoock/components";
|
|
4
|
+
import { DemoCard, ShowcaseShell } from "../_shared";
|
|
5
|
+
|
|
6
|
+
export default function AvatarPage() {
|
|
7
|
+
return (
|
|
8
|
+
<ShowcaseShell
|
|
9
|
+
title="Avatar"
|
|
10
|
+
subtitle="Image, initiales et groupe"
|
|
11
|
+
usage="Utilisez Avatar pour représenter une personne ou une entité. Passez src pour une photo, name ou initials pour le repli textuel. AvatarGroup empile plusieurs avatars avec un débordement « +N »."
|
|
12
|
+
importCode={`import { Avatar, AvatarGroup } from "@modoock/components";`}
|
|
13
|
+
>
|
|
14
|
+
<div className="grid gap-component md:grid-cols-2">
|
|
15
|
+
<DemoCard
|
|
16
|
+
title="Tailles"
|
|
17
|
+
code={`<Avatar name="Amine Berrada" size="sm" />
|
|
18
|
+
<Avatar name="Amine Berrada" size="md" />
|
|
19
|
+
<Avatar name="Amine Berrada" size="lg" />
|
|
20
|
+
<Avatar name="Amine Berrada" size="xl" />`}
|
|
21
|
+
>
|
|
22
|
+
<div className="flex flex-wrap items-end gap-component">
|
|
23
|
+
<Avatar name="Amine Berrada" size="sm" variant="primary" />
|
|
24
|
+
<Avatar name="Amine Berrada" size="md" variant="primary" />
|
|
25
|
+
<Avatar name="Amine Berrada" size="lg" variant="primary" />
|
|
26
|
+
<Avatar name="Amine Berrada" size="xl" variant="primary" />
|
|
27
|
+
</div>
|
|
28
|
+
</DemoCard>
|
|
29
|
+
|
|
30
|
+
<DemoCard
|
|
31
|
+
title="Variants"
|
|
32
|
+
code={`<Avatar name="AB" variant="default" />
|
|
33
|
+
<Avatar name="AB" variant="primary" />
|
|
34
|
+
<Avatar name="AB" variant="success" />
|
|
35
|
+
<Avatar name="AB" variant="info" />`}
|
|
36
|
+
>
|
|
37
|
+
<div className="flex flex-wrap gap-inline">
|
|
38
|
+
<Avatar name="Default" variant="default" />
|
|
39
|
+
<Avatar name="Primary" variant="primary" />
|
|
40
|
+
<Avatar name="Success" variant="success" />
|
|
41
|
+
<Avatar name="Warning" variant="warning" />
|
|
42
|
+
<Avatar name="Danger" variant="danger" />
|
|
43
|
+
<Avatar name="Info" variant="info" />
|
|
44
|
+
<Avatar name="Accent" variant="accent" />
|
|
45
|
+
</div>
|
|
46
|
+
</DemoCard>
|
|
47
|
+
|
|
48
|
+
<DemoCard
|
|
49
|
+
title="Image et repli"
|
|
50
|
+
description="Photo, initiales, ou icône si aucune donnée."
|
|
51
|
+
code={`<Avatar
|
|
52
|
+
src="/photos/amine.jpg"
|
|
53
|
+
name="Amine Berrada"
|
|
54
|
+
/>
|
|
55
|
+
<Avatar name="Sarah El Fassi" variant="info" />
|
|
56
|
+
<Avatar />`}
|
|
57
|
+
>
|
|
58
|
+
<div className="flex flex-wrap items-center gap-component">
|
|
59
|
+
<Avatar
|
|
60
|
+
src="https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=96&h=96&fit=crop"
|
|
61
|
+
name="Sarah El Fassi"
|
|
62
|
+
/>
|
|
63
|
+
<Avatar name="Youssef Amrani" variant="info" />
|
|
64
|
+
<Avatar initials="KB" variant="accent" />
|
|
65
|
+
<Avatar />
|
|
66
|
+
</div>
|
|
67
|
+
</DemoCard>
|
|
68
|
+
|
|
69
|
+
<DemoCard
|
|
70
|
+
title="Statut"
|
|
71
|
+
code={`<Avatar name="Amine" status="online" />
|
|
72
|
+
<Avatar name="Sarah" status="busy" />
|
|
73
|
+
<Avatar name="Karim" status="away" />
|
|
74
|
+
<Avatar name="Nadia" status="offline" />`}
|
|
75
|
+
>
|
|
76
|
+
<div className="flex flex-wrap gap-component">
|
|
77
|
+
<Avatar name="Amine Berrada" variant="primary" status="online" />
|
|
78
|
+
<Avatar name="Sarah El Fassi" variant="info" status="busy" />
|
|
79
|
+
<Avatar name="Karim Tazi" variant="warning" status="away" />
|
|
80
|
+
<Avatar name="Nadia Chraibi" variant="default" status="offline" />
|
|
81
|
+
</div>
|
|
82
|
+
</DemoCard>
|
|
83
|
+
|
|
84
|
+
<DemoCard
|
|
85
|
+
title="Groupe"
|
|
86
|
+
description="Empilement avec débordement."
|
|
87
|
+
code={`<AvatarGroup max={3}>
|
|
88
|
+
<Avatar name="Amine Berrada" variant="primary" />
|
|
89
|
+
<Avatar name="Sarah El Fassi" variant="info" />
|
|
90
|
+
<Avatar name="Youssef Amrani" variant="success" />
|
|
91
|
+
<Avatar name="Leïla Benkirane" variant="accent" />
|
|
92
|
+
<Avatar name="Karim Tazi" variant="warning" />
|
|
93
|
+
</AvatarGroup>`}
|
|
94
|
+
>
|
|
95
|
+
<AvatarGroup max={3} size="md">
|
|
96
|
+
<Avatar name="Amine Berrada" variant="primary" />
|
|
97
|
+
<Avatar name="Sarah El Fassi" variant="info" />
|
|
98
|
+
<Avatar name="Youssef Amrani" variant="success" />
|
|
99
|
+
<Avatar name="Leïla Benkirane" variant="accent" />
|
|
100
|
+
<Avatar name="Karim Tazi" variant="warning" />
|
|
101
|
+
</AvatarGroup>
|
|
102
|
+
</DemoCard>
|
|
103
|
+
</div>
|
|
104
|
+
</ShowcaseShell>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Chart } from "@modoock/components";
|
|
4
|
+
import { DemoCard, ShowcaseShell } from "../_shared";
|
|
5
|
+
|
|
6
|
+
const REVENUE = [
|
|
7
|
+
{ mois: "Jan", revenus: 42, depenses: 28 },
|
|
8
|
+
{ mois: "Fév", revenus: 48, depenses: 31 },
|
|
9
|
+
{ mois: "Mar", revenus: 51, depenses: 29 },
|
|
10
|
+
{ mois: "Avr", revenus: 46, depenses: 34 },
|
|
11
|
+
{ mois: "Mai", revenus: 58, depenses: 33 },
|
|
12
|
+
{ mois: "Juin", revenus: 62, depenses: 36 },
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
const GLUCOSE = [
|
|
16
|
+
{ jour: "Lun", valeur: 1.05 },
|
|
17
|
+
{ jour: "Mar", valeur: 1.12 },
|
|
18
|
+
{ jour: "Mer", valeur: 0.98 },
|
|
19
|
+
{ jour: "Jeu", valeur: 1.08 },
|
|
20
|
+
{ jour: "Ven", valeur: 1.15 },
|
|
21
|
+
{ jour: "Sam", valeur: 1.02 },
|
|
22
|
+
{ jour: "Dim", valeur: 0.96 },
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
const BUDGET = [
|
|
26
|
+
{ categorie: "Personnel", montant: 45 },
|
|
27
|
+
{ categorie: "Équipement", montant: 22 },
|
|
28
|
+
{ categorie: "Médicaments", montant: 18 },
|
|
29
|
+
{ categorie: "Autres", montant: 15 },
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
const VISITS = [
|
|
33
|
+
{ mois: "Jan", consultations: 120, urgences: 34 },
|
|
34
|
+
{ mois: "Fév", consultations: 132, urgences: 28 },
|
|
35
|
+
{ mois: "Mar", consultations: 141, urgences: 31 },
|
|
36
|
+
{ mois: "Avr", consultations: 128, urgences: 37 },
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
const SPARKLINE = [
|
|
40
|
+
{ t: 1, v: 12 },
|
|
41
|
+
{ t: 2, v: 15 },
|
|
42
|
+
{ t: 3, v: 11 },
|
|
43
|
+
{ t: 4, v: 18 },
|
|
44
|
+
{ t: 5, v: 16 },
|
|
45
|
+
{ t: 6, v: 21 },
|
|
46
|
+
{ t: 7, v: 19 },
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
export default function GraphiquesPage() {
|
|
50
|
+
return (
|
|
51
|
+
<ShowcaseShell
|
|
52
|
+
title="Graphiques"
|
|
53
|
+
subtitle={
|
|
54
|
+
<>
|
|
55
|
+
Composant <code className="font-mono">Chart</code>
|
|
56
|
+
</>
|
|
57
|
+
}
|
|
58
|
+
usage="Utilisez Chart pour les tendances et répartitions (argent, santé, tableaux de bord). Choisissez le type selon le besoin : line/area pour le temps, bar/stacked-bar pour comparer des périodes, donut pour une composition à peu de parts, sparkline pour un indicateur compact."
|
|
59
|
+
importCode={`import { Chart } from "@modoock/components";`}
|
|
60
|
+
>
|
|
61
|
+
<div className="grid gap-component md:grid-cols-2">
|
|
62
|
+
<DemoCard
|
|
63
|
+
title="Courbe — trésorerie"
|
|
64
|
+
code={`<Chart
|
|
65
|
+
type="line"
|
|
66
|
+
data={revenue}
|
|
67
|
+
categoryKey="mois"
|
|
68
|
+
series={[
|
|
69
|
+
{ key: "revenus", label: "Revenus" },
|
|
70
|
+
{ key: "depenses", label: "Dépenses" },
|
|
71
|
+
]}
|
|
72
|
+
aria-label="Revenus et dépenses"
|
|
73
|
+
/>`}
|
|
74
|
+
>
|
|
75
|
+
<Chart
|
|
76
|
+
type="line"
|
|
77
|
+
data={REVENUE}
|
|
78
|
+
categoryKey="mois"
|
|
79
|
+
series={[
|
|
80
|
+
{ key: "revenus", label: "Revenus" },
|
|
81
|
+
{ key: "depenses", label: "Dépenses" },
|
|
82
|
+
]}
|
|
83
|
+
aria-label="Revenus et dépenses mensuels"
|
|
84
|
+
/>
|
|
85
|
+
</DemoCard>
|
|
86
|
+
|
|
87
|
+
<DemoCard
|
|
88
|
+
title="Aire — glycémie"
|
|
89
|
+
code={`<Chart
|
|
90
|
+
type="area"
|
|
91
|
+
data={glucose}
|
|
92
|
+
categoryKey="jour"
|
|
93
|
+
series={[{ key: "valeur", label: "Glycémie (g/L)" }]}
|
|
94
|
+
/>`}
|
|
95
|
+
>
|
|
96
|
+
<Chart
|
|
97
|
+
type="area"
|
|
98
|
+
data={GLUCOSE}
|
|
99
|
+
categoryKey="jour"
|
|
100
|
+
series={[{ key: "valeur", label: "Glycémie (g/L)" }]}
|
|
101
|
+
showLegend={false}
|
|
102
|
+
aria-label="Glycémie sur la semaine"
|
|
103
|
+
/>
|
|
104
|
+
</DemoCard>
|
|
105
|
+
|
|
106
|
+
<DemoCard
|
|
107
|
+
title="Barres — activité"
|
|
108
|
+
code={`<Chart
|
|
109
|
+
type="bar"
|
|
110
|
+
data={visits}
|
|
111
|
+
categoryKey="mois"
|
|
112
|
+
series={[
|
|
113
|
+
{ key: "consultations", label: "Consultations" },
|
|
114
|
+
{ key: "urgences", label: "Urgences" },
|
|
115
|
+
]}
|
|
116
|
+
/>`}
|
|
117
|
+
>
|
|
118
|
+
<Chart
|
|
119
|
+
type="bar"
|
|
120
|
+
data={VISITS}
|
|
121
|
+
categoryKey="mois"
|
|
122
|
+
series={[
|
|
123
|
+
{ key: "consultations", label: "Consultations" },
|
|
124
|
+
{ key: "urgences", label: "Urgences" },
|
|
125
|
+
]}
|
|
126
|
+
aria-label="Consultations et urgences"
|
|
127
|
+
/>
|
|
128
|
+
</DemoCard>
|
|
129
|
+
|
|
130
|
+
<DemoCard
|
|
131
|
+
title="Barres empilées — volume"
|
|
132
|
+
code={`<Chart
|
|
133
|
+
type="stacked-bar"
|
|
134
|
+
data={visits}
|
|
135
|
+
categoryKey="mois"
|
|
136
|
+
series={[
|
|
137
|
+
{ key: "consultations", label: "Consultations" },
|
|
138
|
+
{ key: "urgences", label: "Urgences" },
|
|
139
|
+
]}
|
|
140
|
+
/>`}
|
|
141
|
+
>
|
|
142
|
+
<Chart
|
|
143
|
+
type="stacked-bar"
|
|
144
|
+
data={VISITS}
|
|
145
|
+
categoryKey="mois"
|
|
146
|
+
series={[
|
|
147
|
+
{ key: "consultations", label: "Consultations" },
|
|
148
|
+
{ key: "urgences", label: "Urgences" },
|
|
149
|
+
]}
|
|
150
|
+
aria-label="Volume total par mois"
|
|
151
|
+
/>
|
|
152
|
+
</DemoCard>
|
|
153
|
+
|
|
154
|
+
<DemoCard
|
|
155
|
+
title="Donut — budget"
|
|
156
|
+
code={`<Chart
|
|
157
|
+
type="donut"
|
|
158
|
+
data={budget}
|
|
159
|
+
categoryKey="categorie"
|
|
160
|
+
series={[{ key: "montant", label: "Montant" }]}
|
|
161
|
+
/>`}
|
|
162
|
+
>
|
|
163
|
+
<Chart
|
|
164
|
+
type="donut"
|
|
165
|
+
data={BUDGET}
|
|
166
|
+
categoryKey="categorie"
|
|
167
|
+
series={[{ key: "montant", label: "Montant" }]}
|
|
168
|
+
aria-label="Répartition du budget"
|
|
169
|
+
/>
|
|
170
|
+
</DemoCard>
|
|
171
|
+
|
|
172
|
+
<DemoCard
|
|
173
|
+
title="Sparkline — indicateur"
|
|
174
|
+
code={`<Chart
|
|
175
|
+
type="sparkline"
|
|
176
|
+
data={spark}
|
|
177
|
+
categoryKey="t"
|
|
178
|
+
series={[{ key: "v", label: "Tendance" }]}
|
|
179
|
+
/>`}
|
|
180
|
+
>
|
|
181
|
+
<div className="flex items-end justify-between gap-component">
|
|
182
|
+
<div>
|
|
183
|
+
<p className="text-label text-muted-foreground">Solde</p>
|
|
184
|
+
<p className="text-section-title text-foreground">24 680 €</p>
|
|
185
|
+
</div>
|
|
186
|
+
<div className="w-40">
|
|
187
|
+
<Chart
|
|
188
|
+
type="sparkline"
|
|
189
|
+
data={SPARKLINE}
|
|
190
|
+
categoryKey="t"
|
|
191
|
+
series={[{ key: "v", label: "Tendance" }]}
|
|
192
|
+
showTooltip={false}
|
|
193
|
+
aria-label="Tendance du solde"
|
|
194
|
+
/>
|
|
195
|
+
</div>
|
|
196
|
+
</div>
|
|
197
|
+
</DemoCard>
|
|
198
|
+
|
|
199
|
+
<DemoCard
|
|
200
|
+
title="État vide"
|
|
201
|
+
code={`<Chart
|
|
202
|
+
type="line"
|
|
203
|
+
data={[]}
|
|
204
|
+
categoryKey="mois"
|
|
205
|
+
series={[{ key: "revenus", label: "Revenus" }]}
|
|
206
|
+
/>`}
|
|
207
|
+
>
|
|
208
|
+
<Chart
|
|
209
|
+
type="line"
|
|
210
|
+
data={[]}
|
|
211
|
+
categoryKey="mois"
|
|
212
|
+
series={[{ key: "revenus", label: "Revenus" }]}
|
|
213
|
+
height={180}
|
|
214
|
+
/>
|
|
215
|
+
</DemoCard>
|
|
216
|
+
</div>
|
|
217
|
+
</ShowcaseShell>
|
|
218
|
+
);
|
|
219
|
+
}
|