@skalfa/skalfa-app 1.0.3 → 1.0.6

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 (90) hide show
  1. package/.env.example +8 -16
  2. package/app/auth/edit/page.tsx +1 -1
  3. package/app/auth/login/page.tsx +1 -1
  4. package/app/auth/me/page.tsx +1 -1
  5. package/app/auth/register/page.tsx +1 -1
  6. package/app/auth/verify/page.tsx +1 -1
  7. package/app/dashboard/layout.tsx +2 -2
  8. package/app/dashboard/page.tsx +1 -1
  9. package/app/index.ts +1 -0
  10. package/app/layout.tsx +2 -4
  11. package/app/page.tsx +2 -2
  12. package/bun.lock +7 -2
  13. package/components/index.ts +1 -3
  14. package/package.json +10 -7
  15. package/styles/components.css +1392 -0
  16. package/styles/globals.css +40 -175
  17. package/styles/utilities.css +37 -0
  18. package/tsconfig.json +4 -2
  19. package/utils/commands/skalfa.ts +1 -1
  20. package/components/base.components/accordion/Accordion.component.tsx +0 -82
  21. package/components/base.components/breadcrumb/Breadcrumb.component.tsx +0 -80
  22. package/components/base.components/button/Button.component.tsx +0 -91
  23. package/components/base.components/button/IconButton.component.tsx +0 -88
  24. package/components/base.components/button/button.decorate.ts +0 -82
  25. package/components/base.components/card/AlertCard.component.tsx +0 -69
  26. package/components/base.components/card/Card.component.tsx +0 -25
  27. package/components/base.components/card/DashboardCard.component.tsx +0 -44
  28. package/components/base.components/card/GalleryCard.component.tsx +0 -50
  29. package/components/base.components/card/ProductCard.component.tsx +0 -65
  30. package/components/base.components/card/ProfileCard.component.tsx +0 -71
  31. package/components/base.components/carousel/Carousel.component.tsx +0 -113
  32. package/components/base.components/chip/Chip.component.tsx +0 -39
  33. package/components/base.components/document/DocumentViewer.component.tsx +0 -164
  34. package/components/base.components/document/ExportExcel.component.tsx +0 -340
  35. package/components/base.components/document/ImportExcel.component.tsx +0 -315
  36. package/components/base.components/document/PrintTable.component.tsx +0 -204
  37. package/components/base.components/document/RenderPDF.component.tsx +0 -416
  38. package/components/base.components/index.ts +0 -85
  39. package/components/base.components/input/Checkbox.component.tsx +0 -109
  40. package/components/base.components/input/Input.component.tsx +0 -332
  41. package/components/base.components/input/InputCheckbox.component.tsx +0 -174
  42. package/components/base.components/input/InputCurrency.component.tsx +0 -163
  43. package/components/base.components/input/InputDate.component.tsx +0 -352
  44. package/components/base.components/input/InputDatetime.component.tsx +0 -260
  45. package/components/base.components/input/InputDocument.component.tsx +0 -352
  46. package/components/base.components/input/InputImage.component.tsx +0 -533
  47. package/components/base.components/input/InputMap.component.tsx +0 -318
  48. package/components/base.components/input/InputNumber.component.tsx +0 -192
  49. package/components/base.components/input/InputOtp.component.tsx +0 -169
  50. package/components/base.components/input/InputPassword.component.tsx +0 -236
  51. package/components/base.components/input/InputRadio.component.tsx +0 -175
  52. package/components/base.components/input/InputTime.component.tsx +0 -276
  53. package/components/base.components/input/InputValues.component.tsx +0 -68
  54. package/components/base.components/input/Radio.component.tsx +0 -102
  55. package/components/base.components/input/Select.component.tsx +0 -541
  56. package/components/base.components/modal/BottomSheet.component.tsx +0 -246
  57. package/components/base.components/modal/FloatingPage.component.tsx +0 -104
  58. package/components/base.components/modal/Modal.component.tsx +0 -96
  59. package/components/base.components/modal/ModalConfirm.component.tsx +0 -218
  60. package/components/base.components/modal/Toast.component.tsx +0 -126
  61. package/components/base.components/nav/Bottombar.component.tsx +0 -116
  62. package/components/base.components/nav/Footer.component.tsx +0 -144
  63. package/components/base.components/nav/Headbar.component.tsx +0 -104
  64. package/components/base.components/nav/Navbar.component.tsx +0 -100
  65. package/components/base.components/nav/Sidebar.component.tsx +0 -301
  66. package/components/base.components/nav/Tabbar.component.tsx +0 -60
  67. package/components/base.components/nav/Wizard.component.tsx +0 -73
  68. package/components/base.components/supervision/FormSupervision.component.tsx +0 -434
  69. package/components/base.components/supervision/TableSupervision.component.tsx +0 -697
  70. package/components/base.components/table/ControlBar.component.tsx +0 -497
  71. package/components/base.components/table/FilterComponent.tsx +0 -518
  72. package/components/base.components/table/Pagination.component.tsx +0 -159
  73. package/components/base.components/table/Table.component.tsx +0 -469
  74. package/components/base.components/typography/TypographyArticle.component.tsx +0 -26
  75. package/components/base.components/typography/TypographyColumn.component.tsx +0 -20
  76. package/components/base.components/typography/TypographyContent.component.tsx +0 -20
  77. package/components/base.components/typography/TypographyTips.component.tsx +0 -20
  78. package/components/base.components/wrap/Draggable.component.tsx +0 -303
  79. package/components/base.components/wrap/IDBProvider.tsx +0 -12
  80. package/components/base.components/wrap/Image.component.tsx +0 -10
  81. package/components/base.components/wrap/OutsideClick.component.tsx +0 -48
  82. package/components/base.components/wrap/ScrollContainer.component.tsx +0 -104
  83. package/components/base.components/wrap/ShortcutProvider.tsx +0 -57
  84. package/components/base.components/wrap/Swipe.component.tsx +0 -93
  85. package/components/construct.components/example.tsx +0 -1
  86. package/components/construct.components/index.ts +0 -5
  87. package/components/structure.components/example.tsx +0 -1
  88. package/components/structure.components/index.ts +0 -5
  89. package/schema/idb/app.schema.ts +0 -9
  90. package/schema/index.ts +0 -5
@@ -1,6 +1,13 @@
1
1
  @import "tailwindcss";
2
+ @import "./components.css";
3
+ @import "./utilities.css";
4
+
5
+
2
6
 
3
7
  @theme {
8
+ /* ============================ */
9
+ /* ## Colors */
10
+ /* ============================ */
4
11
  --color-background: #FAFDFF;
5
12
  --color-foreground: #575757;
6
13
  --color-light-foreground: #9b9b9b;
@@ -16,7 +23,13 @@
16
23
  --color-light-success: #9af8f9;
17
24
  --color-disable: #c4c3c3;
18
25
  --color-light-disable: #f4f4f4;
26
+ --color-stroke: #e2e8f0;
27
+ --color-light-stroke: #f1f5f9;
28
+
19
29
 
30
+ /* ============================ */
31
+ /* ## Animates */
32
+ /* ============================ */
20
33
  --animate-intro-fade: intro_fade 0.1s ease-in-out forwards;
21
34
  @keyframes intro_fade {
22
35
  from {
@@ -26,6 +39,7 @@
26
39
  opacity: 1;
27
40
  }
28
41
  }
42
+
29
43
  --animate-intro-right: intro_right 0.1s ease-in-out;
30
44
  @keyframes intro_right {
31
45
  from {
@@ -33,6 +47,15 @@
33
47
  opacity: 0;
34
48
  }
35
49
  }
50
+
51
+ --animate-intro-left: intro_left 0.1s ease-in-out;
52
+ @keyframes intro_left {
53
+ from {
54
+ transform: translateX(-100);
55
+ opacity: 0;
56
+ }
57
+ }
58
+
36
59
  --animate-intro-down: intro_down 0.1s ease-in-out;
37
60
  @keyframes intro_down {
38
61
  from {
@@ -40,192 +63,34 @@
40
63
  opacity: 0;
41
64
  }
42
65
  }
43
- }
44
-
45
- body {
46
- @apply bg-background text-foreground max-w-full overflow-x-hidden font-normal;
47
- }
48
-
49
- * {
50
- @apply transition duration-75 border-foreground/30;
51
- }
52
-
53
- @layer base {
54
- }
55
-
56
-
57
- @layer components {
58
- .button {
59
- @apply whitespace-nowrap cursor-pointer disabled:!text-disable disabled:!bg-light-disable;
60
- transform: scale(1);
61
- filter: brightness(0.94);
62
- }
63
66
 
64
- .button:disabled {
65
- cursor: default;
66
- pointer-events: none;
67
- }
68
-
69
- .button:hover {
70
- /* transform: scale(1.02); */
71
- filter: brightness(1);
72
- /* box-shadow: 0 2px 5px 0 rgba(87, 87, 87, 0.15); */
73
- }
74
-
75
- .button:active {
76
- transform: scale(1);
77
- filter: brightness(0.9);
78
- box-shadow: inset 0 0 5px 0 rgba(0, 0, 0, 0.25);
79
- }
80
-
81
- .button-loading {
82
- border-radius: 50%;
83
- display: inline-block;
84
- border-top: 2.5px solid;
85
- border-left: 2.5px solid;
86
- border-right: 2.5px solid transparent;
87
- box-sizing: border-box;
88
- animation: rotation 1s linear infinite;
89
- }
90
-
91
- @keyframes rotation {
92
- 0% {
93
- transform: rotate(0deg);
94
- }
95
- 100% {
96
- transform: rotate(360deg);
67
+ --animate-intro-up: intro_up 0.1s ease-in-out;
68
+ @keyframes intro_up {
69
+ from {
70
+ transform: translateY(100);
71
+ opacity: 0;
97
72
  }
98
73
  }
99
74
 
100
- .input {
101
- @apply px-4 py-2 rounded-[6px] text-foreground bg-background w-full transition duration-150 ease-in-out focus:outline-none border border-slate-300 placeholder:font-normal placeholder:text-light-foreground focus:!border-primary disabled:opacity-60;
102
- }
103
-
104
- .input-file {
105
- @apply file:-mx-3 file:-my-1 file:cursor-pointer file:overflow-hidden file:rounded-md file:border-0 file:border-solid file:border-inherit file:[margin-inline-end:0.75rem] file:bg-slate-200 file:px-3 file:py-1 file:text-slate-500;
106
- }
107
-
108
- .input-label {
109
- @apply select-none text-sm text-foreground;
110
- }
111
75
 
112
- .input-error {
113
- @apply !border-light-danger bg-light-danger/20;
114
- }
115
-
116
- .input-icon {
117
- @apply absolute top-1/2 -translate-y-1/2 text-light-foreground;
118
- }
119
-
120
- .input-error-message {
121
- @apply text-xs text-danger;
122
- }
123
-
124
- .input-tip {
125
- @apply text-xs text-light-foreground;
126
- }
127
-
128
- .input-suggest-container {
129
- @apply py-2 rounded-lg absolute left-0 w-full bg-background shadow z-30 overflow-hidden ease-in-out max-h-[200px] overflow-y-auto;
130
- }
131
-
132
- .input-suggest {
133
- @apply py-1 px-4 cursor-pointer w-full list-none text-foreground hover:text-primary;
134
- }
135
-
136
- .input-values-container {
137
- @apply flex gap-2 flex-nowrap w-max;
138
- }
139
-
140
- .input-values-item {
141
- @apply flex text-sm px-1 pl-2 justify-between bg-white text-foreground border items-center rounded-[4px];
142
- }
143
-
144
- .input-values-delete {
145
- @apply text-xs cursor-pointer text-light-foreground pl-2 pr-1 py-1 hover:text-danger;
146
- }
147
-
148
- .input-scroll::-webkit-scrollbar {
149
- width: 5px;
150
- height: 5px;
151
- position: fixed;
152
- top: 0;
153
- left: 0;
154
- }
155
-
156
- .input-scroll:hover::-webkit-scrollbar {
157
- width: 5px;
158
- height: 5px;
159
- }
160
-
161
- .input-scroll::-webkit-scrollbar-track {
162
- box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.1);
163
- border-radius: 10px;
164
- }
165
-
166
- .input-scroll::-webkit-scrollbar-thumb {
167
- background: rgba(0, 0, 0, 0.1);
168
- border-radius: 10px;
169
- }
170
-
171
- .input-scroll::-webkit-scrollbar-thumb:hover {
172
- background: rgba(0, 0, 0, 0.1);
173
- }
174
-
175
- .modal {
176
- @apply isolate fixed left-1/2 -translate-x-1/2 top-[1rem] md:top-[15vh] opacity-100 bg-white z-40;
177
- }
178
-
179
- .modal-header {
180
- @apply flex justify-between items-center gap-8 px-4 pt-4;
181
- }
182
-
183
- .modal-footer {
184
- @apply px-4 py-2.5 mt-4 bg-background rounded-b-[6px];
185
- }
186
-
187
- .floating-page {
188
- @apply fixed top-[1rem] right-0 bg-background lg:top-0 h-screen z-40 border-t-4 md:border-t-0 md:border-l-4 !border-primary overflow-hidden overflow-y-auto;
189
- }
190
-
191
- .toast {
192
- @apply isolate fixed right-5 bottom-5 opacity-100 bg-white z-40;
193
- }
194
-
195
- .modal-backdrop {
196
- @apply isolate fixed left-0 top-0 z-40 w-screen h-screen bg-light-foreground/20 backdrop-blur-[1px];
197
- }
198
76
  }
199
77
 
200
- @layer utilities {
201
- body::-webkit-scrollbar,
202
- .scroll::-webkit-scrollbar {
203
- @apply w-[10px] h-[10px];
204
- }
205
-
206
- .scroll-sm::-webkit-scrollbar {
207
- @apply w-[7px] h-[7px];
208
- }
209
78
 
210
- .scroll-lg::-webkit-scrollbar {
211
- @apply w-[14px] h-[14px];
212
- }
213
79
 
214
- body::-webkit-scrollbar-thumb,
215
- .scroll::-webkit-scrollbar-thumb,
216
- .scroll-sm::-webkit-scrollbar-thumb,
217
- .scroll-lg::-webkit-scrollbar-thumb {
218
- @apply bg-light-primary/60 cursor-pointer rounded-[3px];
80
+ @layer base {
81
+ /* ============================ */
82
+ /* ## Body default style */
83
+ /* ============================ */
84
+ body {
85
+ @apply bg-background text-foreground max-w-full overflow-x-hidden font-normal;
219
86
  }
220
87
 
221
- body::-webkit-scrollbar-thumb:hover,
222
- .scroll:hover::-webkit-scrollbar-thumb:hover,
223
- .scroll-sm:hover::-webkit-scrollbar-thumb:hover,
224
- .scroll-lg:hover::-webkit-scrollbar-thumb:hover {
225
- @apply bg-primary;
226
- }
227
88
 
228
- .scroll-none::-webkit-scrollbar {
229
- @apply w-0 h-0;
89
+ /* ============================ */
90
+ /* ## All default style */
91
+ /* ============================ */
92
+ * {
93
+ @apply transition duration-75 border-stroke;
230
94
  }
231
95
  }
96
+
@@ -0,0 +1,37 @@
1
+ @layer utilities {
2
+ /* ============================ */
3
+ /* ## Scroll style */
4
+ /* ============================ */
5
+ body::-webkit-scrollbar,
6
+ .scroll::-webkit-scrollbar {
7
+ @apply w-[10px] h-[10px];
8
+ }
9
+
10
+ .scroll-sm::-webkit-scrollbar {
11
+ @apply w-[7px] h-[7px];
12
+ }
13
+
14
+ .scroll-lg::-webkit-scrollbar {
15
+ @apply w-[14px] h-[14px];
16
+ }
17
+
18
+ body::-webkit-scrollbar-thumb,
19
+ .scroll::-webkit-scrollbar-thumb,
20
+ .scroll-sm::-webkit-scrollbar-thumb,
21
+ .scroll-lg::-webkit-scrollbar-thumb {
22
+ @apply bg-light-primary/60 cursor-pointer rounded-[3px];
23
+ }
24
+
25
+ body::-webkit-scrollbar-thumb:hover,
26
+ .scroll::-webkit-scrollbar-thumb:hover,
27
+ .scroll-sm::-webkit-scrollbar-thumb:hover,
28
+ .scroll-lg::-webkit-scrollbar-thumb:hover {
29
+ @apply bg-primary;
30
+ }
31
+
32
+ .scroll-none::-webkit-scrollbar {
33
+ @apply w-0 h-0;
34
+ }
35
+
36
+
37
+ }
package/tsconfig.json CHANGED
@@ -19,8 +19,10 @@
19
19
  "@/*" : ["./*"],
20
20
  "@utils" : ["./utils/index.ts"],
21
21
  "@utils/*" : ["./utils/*"],
22
- "@components" : ["./components/index.ts"],
23
- "@components/*" : ["./components/*", "./components/base.components/*", "./components/construct.components/*", "./components/structure.components/*"],
22
+ "@components" : ["./components/index.ts", "../skalfa-component/dist/index.d.ts"],
23
+ "@components/*" : ["./components/*", "../skalfa-component/dist/*"],
24
+ "@skalfa/skalfa-component": ["../skalfa-component/dist/index.d.ts"],
25
+ "@skalfa/skalfa-component/*": ["../skalfa-component/dist/*"],
24
26
  "@contexts" : ["./contexts/index.ts"],
25
27
  "@contexts/*" : ["./contexts/*"],
26
28
  "@app" : ["./app/index.ts"],
@@ -1,3 +1,3 @@
1
- import { runCli } from "@skalfa/skalfa-app-core";
1
+ import { runCli } from "@skalfa/skalfa-app-core/dist/commands/cli";
2
2
 
3
3
  runCli();
@@ -1,82 +0,0 @@
1
- "use client"
2
-
3
- import { ReactNode, useEffect, useState } from "react";
4
- import { faChevronDown, faChevronLeft } from "@fortawesome/free-solid-svg-icons";
5
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
6
- import { cn, pcn } from "@utils";
7
-
8
-
9
-
10
- type CT = "container" | "head" | "active" | "base";
11
-
12
- export interface AccordionProps {
13
- setActive ?: number | null;
14
- items : { head: ReactNode; content: ReactNode }[];
15
- horizontal ?: boolean;
16
- className ?: string;
17
- };
18
-
19
-
20
-
21
- export function AccordionComponent({
22
- items,
23
- setActive = null,
24
- horizontal = false,
25
-
26
- /** Use custom class with: "container::", "head::", "active::". */
27
- className = "",
28
- }: AccordionProps) {
29
- const [isActive, setIsActive] = useState<number | null>(setActive);
30
-
31
- useEffect(() => {
32
- setIsActive(setActive);
33
- }, [setActive]);
34
-
35
- const styles = {
36
- container: cn(
37
- "bg-white border rounded-lg flex",
38
- horizontal ? "flex-row w-min border-r-0" : "flex-col border-b-0",
39
- pcn<CT>(className, "container"),
40
- ),
41
- head: cn(
42
- "flex justify-between items-center gap-4 font-semibold cursor-pointer",
43
- horizontal ? "flex-col px-2 py-4" : "py-2 px-4",
44
- pcn<CT>(className, "head"),
45
- ),
46
- };
47
-
48
- return (
49
- <div className={styles?.container}>
50
- {items.map(({ head, content }, key) => (
51
- <div
52
- key={key}
53
- className={cn(horizontal ? "border-r flex" : "border-b")}
54
- >
55
- <div
56
- className={styles?.head}
57
- onClick={() => setIsActive(isActive === key ? null : key)}
58
- >
59
- <div>{head}</div>
60
- <div
61
- className={cn(
62
- "w-min transition-transform",
63
- isActive !== key && "rotate-180",
64
- )}
65
- >
66
- <FontAwesomeIcon icon={horizontal ? faChevronLeft : faChevronDown} />
67
- </div>
68
- </div>
69
- <div
70
- className={cn(
71
- "transition-all overflow-hidden",
72
- horizontal ? isActive === key ? "max-w-max pr-4 py-2" : "max-w-0 px-0"
73
- : isActive === key ? "max-h-max pb-4 px-4" : "max-h-0 pb-0 px-4",
74
- pcn<CT>(className, "base"),
75
- isActive === key && pcn<CT>(className, "active"),
76
- )}
77
- >{content}</div>
78
- </div>
79
- ))}
80
- </div>
81
- );
82
- }
@@ -1,80 +0,0 @@
1
- "use client"
2
-
3
- import { Fragment, ReactNode } from "react";
4
- import Link from "next/link";
5
- import { faChevronRight } from "@fortawesome/free-solid-svg-icons";
6
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
7
- import { cn, pcn } from "@utils";
8
-
9
-
10
-
11
- type CT = "container" | "active" | "base";
12
-
13
- export interface BreadcrumbItemProps {
14
- path : string;
15
- label : string;
16
- className ?: string;
17
- };
18
-
19
- export interface BreadcrumbProps {
20
- items : BreadcrumbItemProps[];
21
- square ?: boolean;
22
- separatorContent ?: string | ReactNode;
23
-
24
- /** Use custom class with: "container::", "active::". */
25
- className ?: string;
26
- };
27
-
28
-
29
- export function BreadcrumbComponent({
30
- items,
31
- className = "",
32
- square = false,
33
- separatorContent,
34
- }: BreadcrumbProps) {
35
- return (
36
- <nav
37
- className={cn(
38
- "w-full overflow-x-auto overflow-y-hidden whitespace-nowrap",
39
- pcn<CT>(className, "container"),
40
- )}
41
- >
42
- <ol className="flex">
43
- {items.map((item, index) => {
44
- const isActive = index === items.length - 1;
45
-
46
- return (
47
- <Fragment key={item.path}>
48
- <li>
49
- <Link
50
- href={item.path}
51
- className={cn(
52
- "capitalize",
53
- pcn<CT>(className, "base"),
54
- square && "py-2 px-4 rounded-[6px] bg-light-foreground/10",
55
- isActive && "text-primary",
56
- isActive && square && "text-primary bg-primary/10",
57
- isActive && pcn<CT>(className, "active"),
58
- )}
59
- >
60
- {item.label}
61
- </Link>
62
- </li>
63
-
64
- {!isActive && (
65
- <li className="mx-2">
66
- {separatorContent || (
67
- <FontAwesomeIcon
68
- icon={faChevronRight}
69
- className="text-light-foreground"
70
- />
71
- )}
72
- </li>
73
- )}
74
- </Fragment>
75
- );
76
- })}
77
- </ol>
78
- </nav>
79
- );
80
- }
@@ -1,91 +0,0 @@
1
- "use client"
2
-
3
- import { ReactNode } from "react";
4
- import Link from "next/link";
5
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
6
- import { cn, pcn } from "@utils";
7
- import { buttonVariant, buttonContainer, buttonRadius } from "./button.decorate";
8
-
9
-
10
-
11
- type CT = "icon" | "loading" | "base";
12
-
13
- export interface ButtonProps {
14
- type ?: "submit" | "button";
15
- label ?: string | ReactNode;
16
- variant ?: "solid" | "outline" | "light" | "simple";
17
- paint ?: "primary" | "secondary" | "success" | "danger" | "warning";
18
- rounded ?: boolean | string;
19
- block ?: boolean;
20
- disabled ?: boolean;
21
- size ?: "xs" | "sm" | "md" | "lg";
22
- onClick ?: any;
23
- href ?: string;
24
- icon ?: any;
25
- loading ?: boolean;
26
- hover ?: boolean;
27
-
28
- /** Use custom class with: "icon::", "loading::". */
29
- className?: string;
30
- };
31
-
32
-
33
-
34
-
35
- export function ButtonComponent({
36
- type = "button",
37
- label,
38
- variant = "solid",
39
- paint = "primary",
40
- rounded,
41
- block,
42
- disabled,
43
- size = "md",
44
- onClick,
45
- href,
46
- icon,
47
- loading,
48
- className = "",
49
- }: ButtonProps) {
50
- const buttonClasses = cn(
51
- "button",
52
- buttonVariant[variant][paint],
53
- buttonContainer[size],
54
- rounded ? "rounded-full" : buttonRadius[size],
55
- block && "w-full justify-center",
56
- pcn<CT>(className, "base"),
57
- );
58
-
59
- const loadingClasses = cn(
60
- "button-loading",
61
- size === "sm" ? "w-3 h-3" : size === "lg" ? "w-5 h-5" : "w-4 h-4",
62
- pcn<CT>(className, "loading"),
63
- );
64
-
65
- const iconClasses = cn(
66
- size === "xs"? "text-xs" : size === "sm" ? "text-sm mb-0.5" : size === "lg" ? "text-xl mb-0.5" : "text-base mb-0.5",
67
- pcn<CT>(className, "icon"),
68
- );
69
-
70
- return (
71
- <ButtonComponentWrapper
72
- type={type}
73
- className={buttonClasses}
74
- disabled={disabled || loading}
75
- onClick={onClick}
76
- href={href}
77
- >
78
- {loading ? (
79
- <div className={loadingClasses}></div>
80
- ) : (
81
- icon && <FontAwesomeIcon icon={icon} className={iconClasses} />
82
- )}
83
- {label}
84
- </ButtonComponentWrapper>
85
- );
86
- }
87
-
88
-
89
- const ButtonComponentWrapper = (props: ButtonProps & {children?: ReactNode}) => {
90
- return !props.href ? <button {...props} >{props.children}</button> : <Link href={props.href || ""} {...props}></Link>
91
- }
@@ -1,88 +0,0 @@
1
- "use client"
2
-
3
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
4
- import { cn, pcn } from "@utils";
5
- import { buttonVariant, buttonRadius, iconButtonContainer } from "./button.decorate";
6
-
7
-
8
-
9
- type CT = "icon" | "loading" | "base";
10
-
11
- export interface IconButtonProps {
12
- icon ?: any;
13
- type ?: "submit" | "button";
14
- variant ?: "solid" | "outline" | "light" | "simple";
15
- rounded ?: boolean | string;
16
- disabled ?: boolean;
17
- size ?: "xs" | "sm" | "md" | "lg";
18
- onClick ?: any;
19
- loading ?: boolean;
20
- hover ?: boolean;
21
- tips ?: string | undefined;
22
- paint ?: "primary" | "secondary" | "success" | "danger" | "warning";
23
- customPaint ?: {
24
- bg ?: string;
25
- color ?: string;
26
- border ?: string;
27
- };
28
-
29
- /** Use custom class with: "icon::", "loading::". */
30
- className?: string;
31
- };
32
-
33
-
34
-
35
- export function IconButtonComponent({
36
- type = "button",
37
- variant = "solid",
38
- paint = "primary",
39
- size = "md",
40
- rounded,
41
- disabled,
42
- onClick,
43
- icon,
44
- loading,
45
- tips,
46
- className = "",
47
- }: IconButtonProps) {
48
- const buttonClasses = cn(
49
- "button",
50
- buttonVariant[variant][paint],
51
- iconButtonContainer[size],
52
- rounded ? "rounded-full" : buttonRadius[size],
53
- pcn<CT>(className, "base")
54
- );
55
-
56
- const loadingClasses = cn(
57
- "button-loading",
58
- size === "sm" ? "w-3 h-3" : size === "lg" ? "w-5 h-5" : "w-4 h-4",
59
- pcn<CT>(className, "loading")
60
- );
61
-
62
- const iconClasses = cn(
63
- size === "xs"
64
- ? "text-xs"
65
- : size === "sm"
66
- ? "text-sm mb-0.5"
67
- : size === "lg"
68
- ? "text-xl mb-0.5"
69
- : "text-base mb-0.5",
70
- pcn<CT>(className, "icon")
71
- );
72
-
73
- return (
74
- <button
75
- type={type}
76
- className={buttonClasses}
77
- disabled={disabled || loading}
78
- onClick={onClick}
79
- title={tips}
80
- >
81
- {loading ? (
82
- <div className={loadingClasses}></div>
83
- ) : (
84
- <FontAwesomeIcon icon={icon} className={iconClasses} />
85
- )}
86
- </button>
87
- );
88
- }