alpe-temp 1.0.0 → 1.0.2

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.
Files changed (34) hide show
  1. package/bin/epms.js +149 -60
  2. package/frontend-project/src/App.css +1 -0
  3. package/frontend-project/src/Auth/Login.jsx +85 -0
  4. package/frontend-project/src/Auth/Register.jsx +183 -0
  5. package/frontend-project/src/Intro.jsx +33 -0
  6. package/frontend-project/src/LayOut.jsx +38 -0
  7. package/frontend-project/src/api/ApiClient.js +92 -0
  8. package/frontend-project/src/assets/hero.png +0 -0
  9. package/frontend-project/src/assets/react.svg +1 -0
  10. package/frontend-project/src/assets/vite.svg +1 -0
  11. package/frontend-project/src/components/Aside.jsx +9 -0
  12. package/frontend-project/src/components/Button.jsx +100 -0
  13. package/frontend-project/src/components/Card.jsx +104 -0
  14. package/frontend-project/src/components/FormField.jsx +129 -0
  15. package/frontend-project/src/components/Modal.jsx +106 -0
  16. package/frontend-project/src/components/Table.jsx +127 -0
  17. package/frontend-project/src/components/Toast.jsx +64 -0
  18. package/frontend-project/src/components/index.js +14 -0
  19. package/frontend-project/src/config.js +66 -0
  20. package/frontend-project/src/design.js +115 -0
  21. package/frontend-project/src/index.css +60 -0
  22. package/frontend-project/src/layouts/BottomNav.jsx +156 -0
  23. package/frontend-project/src/layouts/TopNav.jsx +150 -0
  24. package/frontend-project/src/layouts/useShell.js +44 -0
  25. package/frontend-project/src/main.jsx +41 -0
  26. package/frontend-project/src/pages/Department.jsx +188 -0
  27. package/frontend-project/src/pages/Employee.jsx +274 -0
  28. package/frontend-project/src/pages/Home.jsx +79 -0
  29. package/frontend-project/src/pages/Profile.jsx +9 -0
  30. package/frontend-project/src/pages/Register.jsx +57 -0
  31. package/frontend-project/src/pages/Reports.jsx +91 -0
  32. package/frontend-project/src/pages/Salary.jsx +264 -0
  33. package/frontend-project/src/themes.js +175 -0
  34. package/package.json +1 -1
@@ -0,0 +1,92 @@
1
+ import axios from 'axios';
2
+
3
+ const BASE_URL = import.meta.env.VITE_API_URL ?? 'http://localhost:3000';
4
+
5
+ const api = axios.create({
6
+ baseURL: BASE_URL,
7
+ headers: { 'Content-Type': 'application/json' },
8
+ });
9
+
10
+ api.interceptors.request.use((config) => {
11
+ const token = localStorage.getItem('token');
12
+ if (token) config.headers.Authorization = `Bearer ${token}`;
13
+ return config;
14
+ });
15
+
16
+ api.interceptors.response.use(
17
+ (res) => res,
18
+ (err) => {
19
+ const msg = err.response?.data?.message || err.message || 'Request failed';
20
+ return Promise.reject(new Error(msg));
21
+ }
22
+ );
23
+
24
+ export const authApi = {
25
+ login: (body) => api.post('/api/auth/login', body).then(r => r.data),
26
+ signup: (body) => api.post('/api/auth/signup', body).then(r => r.data),
27
+ refresh:(body) => api.post('/api/auth/refresh', body).then(r => r.data),
28
+ me: () => api.get('/api/auth/me').then(r => r.data),
29
+ logout: () => api.post('/api/auth/logout').then(r => r.data),
30
+ };
31
+
32
+ export const employeeApi = {
33
+ list: () => api.get('/api/employees').then(r => r.data),
34
+ count: () => api.get('/api/employees/count').then(r => r.data),
35
+ create: (body) => api.post('/api/employees', body).then(r => r.data),
36
+ update: (id, b) => api.put(`/api/employees/${id}`, b).then(r => r.data),
37
+ remove: (id) => api.delete(`/api/employees/${id}`).then(r => r.data),
38
+ };
39
+
40
+ export const departmentApi = {
41
+ list: () => api.get('/api/departments').then(r => r.data),
42
+ create: (body) => api.post('/api/departments', body).then(r => r.data),
43
+ update: (id, b) => api.put(`/api/departments/${id}`, b).then(r => r.data),
44
+ remove: (id) => api.delete(`/api/departments/${id}`).then(r => r.data),
45
+ };
46
+
47
+ export const salaryApi = {
48
+ list: () => api.get('/api/salaries').then(r => r.data),
49
+ create: (body) => api.post('/api/salaries', body).then(r => r.data),
50
+ update: (id, b) => api.put(`/api/salaries/${id}`, b).then(r => r.data),
51
+ remove: (id) => api.delete(`/api/salaries/${id}`).then(r => r.data),
52
+ average: () => api.get('/api/salaries/avg').then(r => r.data),
53
+ };
54
+
55
+ export const reportsApi = {
56
+ monthlyPayroll: (month) => api.get('/api/reports/payroll', { params: { month } }).then(r => r.data),
57
+ };
58
+
59
+ export const excelApi = {
60
+ async download(path, filename = 'export') {
61
+ const token = localStorage.getItem('token');
62
+ const res = await fetch(`${BASE_URL}${path}`, {
63
+ headers: { ...(token ? { Authorization: `Bearer ${token}` } : {}) },
64
+ });
65
+ const blob = await res.blob();
66
+ const url = URL.createObjectURL(blob);
67
+ const a = Object.assign(document.createElement('a'), { href: url, download: `${filename}.xlsx` });
68
+ document.body.appendChild(a);
69
+ a.click();
70
+ a.remove();
71
+ URL.revokeObjectURL(url);
72
+ },
73
+ exportUsers: () => excelApi.download('/api/excel/export/users', 'employees-report'),
74
+ exportCustom: async (sheetName, data, filename) => {
75
+ const token = localStorage.getItem('token');
76
+ const res = await fetch(`${BASE_URL}/api/excel/export/custom`, {
77
+ method: 'POST',
78
+ headers: { 'Content-Type': 'application/json', ...(token ? { Authorization: `Bearer ${token}` } : {}) },
79
+ body: JSON.stringify({ sheetName, data }),
80
+ });
81
+ if (!res.ok) throw new Error(await res.text());
82
+ const blob = await res.blob();
83
+ const url = URL.createObjectURL(blob);
84
+ const a = Object.assign(document.createElement('a'), { href: url, download: `${filename ?? sheetName}.xlsx` });
85
+ document.body.appendChild(a);
86
+ a.click();
87
+ a.remove();
88
+ URL.revokeObjectURL(url);
89
+ },
90
+ };
91
+
92
+ export default api;
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="77" height="47" fill="none" aria-labelledby="vite-logo-title" viewBox="0 0 77 47"><title id="vite-logo-title">Vite</title><style>.parenthesis{fill:#000}@media (prefers-color-scheme:dark){.parenthesis{fill:#fff}}</style><path fill="#9135ff" d="M40.151 45.71c-.663.844-2.02.374-2.02-.699V34.708a2.26 2.26 0 0 0-2.262-2.262H24.493c-.92 0-1.457-1.04-.92-1.788l7.479-10.471c1.07-1.498 0-3.578-1.842-3.578H15.443c-.92 0-1.456-1.04-.92-1.788l9.696-13.576c.213-.297.556-.474.92-.474h28.894c.92 0 1.456 1.04.92 1.788l-7.48 10.472c-1.07 1.497 0 3.578 1.842 3.578h11.376c.944 0 1.474 1.087.89 1.83L40.153 45.712z"/><mask id="a" width="48" height="47" x="14" y="0" maskUnits="userSpaceOnUse" style="mask-type:alpha"><path fill="#000" d="M40.047 45.71c-.663.843-2.02.374-2.02-.699V34.708a2.26 2.26 0 0 0-2.262-2.262H24.389c-.92 0-1.457-1.04-.92-1.788l7.479-10.472c1.07-1.497 0-3.578-1.842-3.578H15.34c-.92 0-1.456-1.04-.92-1.788l9.696-13.575c.213-.297.556-.474.92-.474H53.93c.92 0 1.456 1.04.92 1.788L47.37 13.03c-1.07 1.498 0 3.578 1.842 3.578h11.376c.944 0 1.474 1.088.89 1.831L40.049 45.712z"/></mask><g mask="url(#a)"><g filter="url(#b)"><ellipse cx="5.508" cy="14.704" fill="#eee6ff" rx="5.508" ry="14.704" transform="rotate(269.814 20.96 11.29)scale(-1 1)"/></g><g filter="url(#c)"><ellipse cx="10.399" cy="29.851" fill="#eee6ff" rx="10.399" ry="29.851" transform="rotate(89.814 -16.902 -8.275)scale(1 -1)"/></g><g filter="url(#d)"><ellipse cx="5.508" cy="30.487" fill="#8900ff" rx="5.508" ry="30.487" transform="rotate(89.814 -19.197 -7.127)scale(1 -1)"/></g><g filter="url(#e)"><ellipse cx="5.508" cy="30.599" fill="#8900ff" rx="5.508" ry="30.599" transform="rotate(89.814 -25.928 4.177)scale(1 -1)"/></g><g filter="url(#f)"><ellipse cx="5.508" cy="30.599" fill="#8900ff" rx="5.508" ry="30.599" transform="rotate(89.814 -25.738 5.52)scale(1 -1)"/></g><g filter="url(#g)"><ellipse cx="14.072" cy="22.078" fill="#eee6ff" rx="14.072" ry="22.078" transform="rotate(93.35 31.245 55.578)scale(-1 1)"/></g><g filter="url(#h)"><ellipse cx="3.47" cy="21.501" fill="#8900ff" rx="3.47" ry="21.501" transform="rotate(89.009 35.419 55.202)scale(-1 1)"/></g><g filter="url(#i)"><ellipse cx="3.47" cy="21.501" fill="#8900ff" rx="3.47" ry="21.501" transform="rotate(89.009 35.419 55.202)scale(-1 1)"/></g><g filter="url(#j)"><ellipse cx="14.592" cy="9.743" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(39.51 14.592 9.743)"/></g><g filter="url(#k)"><ellipse cx="61.728" cy="-5.321" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(37.892 61.728 -5.32)"/></g><g filter="url(#l)"><ellipse cx="55.618" cy="7.104" fill="#00c2ff" rx="5.971" ry="9.665" transform="rotate(37.892 55.618 7.104)"/></g><g filter="url(#m)"><ellipse cx="12.326" cy="39.103" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(37.892 12.326 39.103)"/></g><g filter="url(#n)"><ellipse cx="12.326" cy="39.103" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(37.892 12.326 39.103)"/></g><g filter="url(#o)"><ellipse cx="49.857" cy="30.678" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(37.892 49.857 30.678)"/></g><g filter="url(#p)"><ellipse cx="52.623" cy="33.171" fill="#00c2ff" rx="5.971" ry="15.297" transform="rotate(37.892 52.623 33.17)"/></g></g><path d="M6.919 0c-9.198 13.166-9.252 33.575 0 46.789h6.215c-9.25-13.214-9.196-33.623 0-46.789zm62.424 0h-6.215c9.198 13.166 9.252 33.575 0 46.789h6.215c9.25-13.214 9.196-33.623 0-46.789" class="parenthesis"/><defs><filter id="b" width="60.045" height="41.654" x="-5.564" y="16.92" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="7.659"/></filter><filter id="c" width="90.34" height="51.437" x="-40.407" y="-6.762" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="7.659"/></filter><filter id="d" width="79.355" height="29.4" x="-35.435" y="2.801" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="e" width="79.579" height="29.4" x="-30.84" y="20.8" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="f" width="79.579" height="29.4" x="-29.307" y="21.949" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="g" width="74.749" height="58.852" x="29.961" y="-17.13" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="7.659"/></filter><filter id="h" width="61.377" height="25.362" x="37.754" y="3.055" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="i" width="61.377" height="25.362" x="37.754" y="3.055" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="j" width="56.045" height="63.649" x="-13.43" y="-22.082" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="k" width="54.814" height="64.646" x="34.321" y="-37.644" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="l" width="33.541" height="35.313" x="38.847" y="-10.552" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="m" width="54.814" height="64.646" x="-15.081" y="6.78" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="n" width="54.814" height="64.646" x="-15.081" y="6.78" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="o" width="54.814" height="64.646" x="22.45" y="-1.645" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="p" width="39.409" height="43.623" x="32.919" y="11.36" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter></defs></svg>
@@ -0,0 +1,9 @@
1
+ import React from 'react'
2
+
3
+ function Aside() {
4
+ return (
5
+ <div>Aside</div>
6
+ )
7
+ }
8
+
9
+ export default Aside
@@ -0,0 +1,100 @@
1
+ // ═══════════════════════════════════════════════════════════════════════════
2
+ // 🔘 BUTTON — Reusable button with config-driven defaults
3
+ // ═══════════════════════════════════════════════════════════════════════════
4
+ //
5
+ // HOW TO USE:
6
+ // <Button onClick={...}>Click me</Button>
7
+ // <Button variant="danger" size="lg">Delete</Button>
8
+ // <Button loading icon={<Save />}>Save</Button>
9
+ //
10
+ // PROPS:
11
+ // variant: 'primary' | 'dark' | 'danger' | 'outline' | 'ghost' | 'success'
12
+ // size: 'xs' | 'sm' | 'md' | 'lg'
13
+ // loading: show spinner instead of icon
14
+ // icon: icon component to show on the left
15
+ // iconRight: icon component to show on the right
16
+ // fullWidth: make button fill container width
17
+ // className: additional CSS classes
18
+ //
19
+ // CONFIG INTEGRATION:
20
+ // - Rounded corners come from config.js → --radius CSS variable
21
+ // - Primary color from config.js theme
22
+ //
23
+ // ═══════════════════════════════════════════════════════════════════════════
24
+
25
+ import React from 'react';
26
+ import { Loader2 } from 'lucide-react';
27
+ import { config } from '../config';
28
+ import { getRoundedClass } from '../design';
29
+
30
+ const BASE =
31
+ 'inline-flex items-center justify-center gap-2 font-medium ' +
32
+ 'transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-1 ' +
33
+ 'disabled:opacity-50 disabled:cursor-not-allowed select-none';
34
+
35
+ const VARIANTS = {
36
+ primary:
37
+ 'text-white hover:opacity-90 active:scale-[0.98] focus:ring-[var(--color-primary)]',
38
+ dark:
39
+ 'bg-black text-white hover:bg-gray-900 focus:ring-gray-600 active:scale-[0.98]',
40
+ danger:
41
+ 'bg-red-500 text-white hover:bg-red-600 focus:ring-red-400 active:scale-[0.98]',
42
+ outline:
43
+ 'border text-gray-600 bg-white hover:bg-gray-50 focus:ring-gray-300 active:scale-[0.98]',
44
+ ghost:
45
+ 'text-gray-600 hover:bg-gray-100 focus:ring-gray-200 active:scale-[0.98]',
46
+ success:
47
+ 'bg-emerald-500 text-white hover:bg-emerald-600 focus:ring-emerald-400 active:scale-[0.98]',
48
+ };
49
+
50
+ const SIZES = {
51
+ xs: 'text-[11px] px-2.5 py-1',
52
+ sm: 'text-[12px] px-3 py-1.5',
53
+ md: 'text-[13px] px-4 py-2',
54
+ lg: 'text-[14px] px-5 py-2.5',
55
+ };
56
+
57
+ export default function Button({
58
+ children,
59
+ variant = 'primary',
60
+ size = 'md',
61
+ loading = false,
62
+ icon,
63
+ iconRight,
64
+ fullWidth = false,
65
+ className = '',
66
+ disabled,
67
+ ...rest
68
+ }) {
69
+ // ─── Get rounded class from config ────────────────────────────────────────
70
+ const roundClass = getRoundedClass(config.rounded);
71
+
72
+ // ─── Primary variant gets its background from CSS variable ─────────────────
73
+ const variantStyle =
74
+ variant === 'primary'
75
+ ? { backgroundColor: 'var(--color-primary)' }
76
+ : {};
77
+
78
+ // ─── Outline variant gets its border color from CSS variable ───────────────
79
+ const borderStyle =
80
+ variant === 'outline'
81
+ ? { borderColor: 'var(--color-border)' }
82
+ : {};
83
+
84
+ return (
85
+ <button
86
+ className={`${BASE} ${VARIANTS[variant] ?? VARIANTS.primary} ${SIZES[size] ?? SIZES.md} ${fullWidth ? 'w-full' : ''} ${roundClass} ${className}`}
87
+ style={{ ...variantStyle, ...borderStyle }}
88
+ disabled={disabled || loading}
89
+ {...rest}
90
+ >
91
+ {loading ? (
92
+ <Loader2 className="w-4 h-4 animate-spin" />
93
+ ) : icon ? (
94
+ <span className="w-4 h-4 flex-shrink-0">{icon}</span>
95
+ ) : null}
96
+ {children}
97
+ {!loading && iconRight && <span className="w-4 h-4 flex-shrink-0">{iconRight}</span>}
98
+ </button>
99
+ );
100
+ }
@@ -0,0 +1,104 @@
1
+ // ═══════════════════════════════════════════════════════════════════════════
2
+ // 🃏 CARD — Reusable card & stat card with config-driven styling
3
+ // ═══════════════════════════════════════════════════════════════════════════
4
+ //
5
+ // HOW TO USE:
6
+ // <Card title="Users" action={<Button>Add</Button>}>
7
+ // <p>Content goes here</p>
8
+ // </Card>
9
+ //
10
+ // <StatCard label="Total Employees" value="150" trend="+12%" />
11
+ //
12
+ // PROPS (Card):
13
+ // title: card heading text
14
+ // subtitle: smaller text below title
15
+ // action: element to show on the right (e.g. a Button)
16
+ // children: card body content
17
+ // className: additional CSS classes
18
+ //
19
+ // PROPS (StatCard):
20
+ // label: stat label
21
+ // value: stat value (string or number)
22
+ // trend: optional trend text (e.g. "+12%")
23
+ // trendUp: whether trend is positive (true=green, false=red)
24
+ // loading: show skeleton placeholder
25
+ // className: additional CSS classes
26
+ //
27
+ // CONFIG INTEGRATION:
28
+ // - Background from var(--color-card)
29
+ // - Border from var(--color-border)
30
+ //
31
+ // ═══════════════════════════════════════════════════════════════════════════
32
+
33
+ import React from 'react';
34
+ import { config } from '../config';
35
+ import { getRoundedClass } from '../design';
36
+
37
+ export function Card({ title, subtitle, action, children, className = '' }) {
38
+ const roundClass = getRoundedClass(config.rounded);
39
+
40
+ return (
41
+ <div
42
+ className={`p-5 ${roundClass} ${className}`}
43
+ style={{
44
+ backgroundColor: 'var(--color-card)',
45
+ border: '1px solid var(--color-border)',
46
+ }}
47
+ >
48
+ {(title || action) && (
49
+ <div className="flex items-start justify-between mb-4">
50
+ <div>
51
+ {title && (
52
+ <h3 className="text-[13px] font-semibold" style={{ color: 'var(--color-text)' }}>
53
+ {title}
54
+ </h3>
55
+ )}
56
+ {subtitle && (
57
+ <p className="text-[11px] mt-0.5" style={{ color: 'var(--color-text-muted)' }}>
58
+ {subtitle}
59
+ </p>
60
+ )}
61
+ </div>
62
+ {action && <div className="flex-shrink-0">{action}</div>}
63
+ </div>
64
+ )}
65
+ {children}
66
+ </div>
67
+ );
68
+ }
69
+
70
+ export function StatCard({ label, value, trend, trendUp = true, loading = false, className = '' }) {
71
+ const roundClass = getRoundedClass(config.rounded);
72
+
73
+ return (
74
+ <div
75
+ className={`p-5 flex flex-col gap-3 ${roundClass} ${className}`}
76
+ style={{
77
+ backgroundColor: 'var(--color-card)',
78
+ border: '1px solid var(--color-border)',
79
+ }}
80
+ >
81
+ <div className="flex items-center justify-between">
82
+ <span className="text-[12px] font-semibold uppercase tracking-wide" style={{ color: 'var(--color-text-muted)' }}>
83
+ {label}
84
+ </span>
85
+ </div>
86
+ {loading ? (
87
+ <div className="h-8 w-24 animate-pulse" style={{ backgroundColor: 'var(--color-border)' }} />
88
+ ) : (
89
+ <span className="text-[32px] font-bold leading-none" style={{ color: 'var(--color-text)' }}>
90
+ {value ?? '—'}
91
+ </span>
92
+ )}
93
+ {trend && (
94
+ <span
95
+ className={`text-[11px] font-semibold px-2 py-0.5 w-fit ${
96
+ trendUp ? 'bg-emerald-50 text-emerald-600' : 'bg-red-50 text-red-500'
97
+ }`}
98
+ >
99
+ {trend}
100
+ </span>
101
+ )}
102
+ </div>
103
+ );
104
+ }
@@ -0,0 +1,129 @@
1
+ // ═══════════════════════════════════════════════════════════════════════════
2
+ // 📝 FORM FIELD — Reusable form inputs with labels & validation
3
+ // ═══════════════════════════════════════════════════════════════════════════
4
+ //
5
+ // HOW TO USE:
6
+ // <FormField label="Email" required error={errors.email}>
7
+ // <FormField.Input type="email" value={email} onChange={setEmail} />
8
+ // </FormField>
9
+ //
10
+ // <FormField label="Role">
11
+ // <FormField.Select options={['admin', 'user']} value={role} onChange={setRole} />
12
+ // </FormField>
13
+ //
14
+ // <FormField label="Bio">
15
+ // <FormField.Textarea value={bio} onChange={setBio} />
16
+ // </FormField>
17
+ //
18
+ // PROPS:
19
+ // label: field label text
20
+ // required: show red asterisk
21
+ // error: error message string
22
+ // children: input element(s)
23
+ // className: additional CSS classes
24
+ //
25
+ // SUB-COMPONENTS:
26
+ // FormField.Input → <input>
27
+ // FormField.Select → <select>
28
+ // FormField.Textarea → <textarea>
29
+ //
30
+ // CONFIG INTEGRATION:
31
+ // - Rounded corners from config.js → --radius CSS variable
32
+ // - Colors from CSS variables
33
+ //
34
+ // ═══════════════════════════════════════════════════════════════════════════
35
+
36
+ import React from 'react';
37
+ import { config } from '../config';
38
+ import { getRoundedClass } from '../design';
39
+
40
+ // ─── BASE INPUT STYLES ──────────────────────────────────────────────────────
41
+ const INPUT_BASE =
42
+ 'w-full px-3 py-2 text-[13px] font-medium ' +
43
+ 'border transition-colors duration-150 ' +
44
+ 'placeholder:text-gray-400 focus:outline-none focus:ring-1 ' +
45
+ 'disabled:bg-gray-50 disabled:text-gray-400';
46
+
47
+ // ─── MAIN FORM FIELD COMPONENT ──────────────────────────────────────────────
48
+ export default function FormField({ label, required = false, error, children, className = '' }) {
49
+ return (
50
+ <div className={`flex flex-col gap-1 ${className}`}>
51
+ {label && (
52
+ <label className="text-[12px] font-semibold select-none" style={{ color: 'var(--color-text-muted)' }}>
53
+ {label}
54
+ {required && <span className="text-red-400 ml-0.5">*</span>}
55
+ </label>
56
+ )}
57
+ {children}
58
+ {error && <p className="text-[11px] text-red-500 font-medium">{error}</p>}
59
+ </div>
60
+ );
61
+ }
62
+
63
+ // ─── TEXT INPUT ──────────────────────────────────────────────────────────────
64
+ FormField.Input = function FieldInput({ onChange, className = '', ...props }) {
65
+ const roundClass = getRoundedClass(config.rounded);
66
+ return (
67
+ <input
68
+ className={`${INPUT_BASE} ${roundClass} ${className}`}
69
+ style={{
70
+ backgroundColor: 'var(--color-card)',
71
+ borderColor: 'var(--color-border)',
72
+ color: 'var(--color-text)',
73
+ }}
74
+ onChange={(e) => onChange?.(e.target.value, e)}
75
+ {...props}
76
+ />
77
+ );
78
+ };
79
+
80
+ // ─── SELECT DROPDOWN ─────────────────────────────────────────────────────────
81
+ FormField.Select = function FieldSelect({ value, onChange, options = [], placeholder, className = '', ...props }) {
82
+ const roundClass = getRoundedClass(config.rounded);
83
+ const normalised = options.map((o) =>
84
+ typeof o === 'string' ? { value: o, label: o } : o
85
+ );
86
+
87
+ return (
88
+ <select
89
+ value={value}
90
+ onChange={(e) => onChange?.(e.target.value, e)}
91
+ className={`${INPUT_BASE} ${roundClass} ${className}`}
92
+ style={{
93
+ backgroundColor: 'var(--color-card)',
94
+ borderColor: 'var(--color-border)',
95
+ color: 'var(--color-text)',
96
+ }}
97
+ {...props}
98
+ >
99
+ {placeholder && (
100
+ <option value="" disabled>
101
+ {placeholder}
102
+ </option>
103
+ )}
104
+ {normalised.map((o) => (
105
+ <option key={o.value} value={o.value}>
106
+ {o.label}
107
+ </option>
108
+ ))}
109
+ </select>
110
+ );
111
+ };
112
+
113
+ // ─── TEXTAREA ────────────────────────────────────────────────────────────────
114
+ FormField.Textarea = function FieldTextarea({ onChange, className = '', ...props }) {
115
+ const roundClass = getRoundedClass(config.rounded);
116
+ return (
117
+ <textarea
118
+ rows={3}
119
+ className={`${INPUT_BASE} resize-none ${roundClass} ${className}`}
120
+ style={{
121
+ backgroundColor: 'var(--color-card)',
122
+ borderColor: 'var(--color-border)',
123
+ color: 'var(--color-text)',
124
+ }}
125
+ onChange={(e) => onChange?.(e.target.value, e)}
126
+ {...props}
127
+ />
128
+ );
129
+ };
@@ -0,0 +1,106 @@
1
+ // ═══════════════════════════════════════════════════════════════════════════
2
+ // 🪟 MODAL — Backdrop modal with config-driven styling
3
+ // ═══════════════════════════════════════════════════════════════════════════
4
+ //
5
+ // WHAT THIS IS:
6
+ // A modal dialog that appears over everything with a dark backdrop.
7
+ // Press Escape or click outside to close.
8
+ //
9
+ // HOW TO USE:
10
+ // <Modal open={isOpen} onClose={() => setOpen(false)} title="Edit Item">
11
+ // <p>Modal content here</p>
12
+ // <Modal.Footer>
13
+ // <Button onClick={() => setOpen(false)}>Cancel</Button>
14
+ // </Modal.Footer>
15
+ // </Modal>
16
+ //
17
+ // PROPS:
18
+ // open: boolean (show/hide)
19
+ // onClose: function to close
20
+ // title: modal header text
21
+ // size: 'sm' | 'md' | 'lg' | 'xl' | '2xl'
22
+ // children: modal body
23
+ // className: additional CSS classes
24
+ //
25
+ // CONFIG INTEGRATION:
26
+ // - Rounded corners from config.js
27
+ // - Colors from CSS variables
28
+ //
29
+ // ═══════════════════════════════════════════════════════════════════════════
30
+
31
+ import React, { useEffect } from 'react';
32
+ import { createPortal } from 'react-dom';
33
+ import { X } from 'lucide-react';
34
+ import { config } from '../config';
35
+ import { getRoundedClass } from '../design';
36
+
37
+ const SIZES = {
38
+ sm: 'max-w-sm',
39
+ md: 'max-w-md',
40
+ lg: 'max-w-lg',
41
+ xl: 'max-w-xl',
42
+ '2xl': 'max-w-2xl',
43
+ };
44
+
45
+ export default function Modal({ open, onClose, title, size = 'md', children, className = '' }) {
46
+ const roundClass = getRoundedClass(config.rounded);
47
+
48
+ // Close on Escape key
49
+ useEffect(() => {
50
+ if (!open) return;
51
+ const handler = (e) => { if (e.key === 'Escape') onClose(); };
52
+ window.addEventListener('keydown', handler);
53
+ return () => window.removeEventListener('keydown', handler);
54
+ }, [open, onClose]);
55
+
56
+ if (!open) return null;
57
+
58
+ return createPortal(
59
+ <div className="fixed inset-0 z-[9999] flex items-center justify-center p-4" role="dialog" aria-modal="true">
60
+ {/* Backdrop */}
61
+ <div
62
+ className="absolute inset-0 bg-black/40 backdrop-blur-[2px]"
63
+ onClick={onClose}
64
+ />
65
+ {/* Modal content */}
66
+ <div
67
+ className={`relative shadow-xl w-full ${SIZES[size] ?? SIZES.md} ${roundClass} ${className}`}
68
+ style={{
69
+ backgroundColor: 'var(--color-card)',
70
+ border: '1px solid var(--color-border)',
71
+ }}
72
+ >
73
+ {title && (
74
+ <div className="flex items-center justify-between px-5 py-4 border-b" style={{ borderColor: 'var(--color-border)' }}>
75
+ <h2 className="text-[14px] font-semibold" style={{ color: 'var(--color-text)' }}>
76
+ {title}
77
+ </h2>
78
+ <button
79
+ onClick={onClose}
80
+ className="w-7 h-7 flex items-center justify-center transition-colors hover:opacity-70"
81
+ style={{ color: 'var(--color-text-muted)' }}
82
+ >
83
+ <X className="w-4 h-4" />
84
+ </button>
85
+ </div>
86
+ )}
87
+ <div className="px-5 py-4">{children}</div>
88
+ </div>
89
+ </div>,
90
+ document.body
91
+ );
92
+ }
93
+
94
+ // ─── MODAL FOOTER ────────────────────────────────────────────────────────────
95
+ // Use inside <Modal> to add a footer with action buttons.
96
+ //
97
+ Modal.Footer = function ModalFooter({ children }) {
98
+ return (
99
+ <div
100
+ className="flex justify-end gap-2 pt-3 mt-2 border-t"
101
+ style={{ borderColor: 'var(--color-border)' }}
102
+ >
103
+ {children}
104
+ </div>
105
+ );
106
+ };