react-groundwork 0.0.0-stage → 0.1.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/.env.example +6 -0
- package/.gitattributes +2 -0
- package/.prettierignore +7 -0
- package/.prettierrc.json +12 -0
- package/README.md +24 -2
- package/cli/index.js +119 -0
- package/components.json +25 -0
- package/eslint.config.js +17 -0
- package/index.html +13 -0
- package/jsconfig.json +8 -0
- package/package.json +111 -4
- package/public/.htaccess +11 -0
- package/public/logo.png +0 -0
- package/src/App.jsx +14 -0
- package/src/api/api.routes.js +12 -0
- package/src/api/api.services.js +8 -0
- package/src/api/apiCall.js +128 -0
- package/src/api/apiHelpers.js +20 -0
- package/src/assets/css/index.css +173 -0
- package/src/assets/images/placeholders/placeholder-170x166.png +0 -0
- package/src/assets/images/placeholders/placeholder-360x260.png +0 -0
- package/src/assets/images/placeholders/placeholder-372x225.png +0 -0
- package/src/assets/images/placeholders/placeholder-40x40.png +0 -0
- package/src/assets/images/placeholders/placeholder-451x392.png +0 -0
- package/src/components/common/AppChart.jsx +56 -0
- package/src/components/common/Breadcrumbs.jsx +90 -0
- package/src/components/common/DataTable.jsx +203 -0
- package/src/components/common/DatePicker.jsx +275 -0
- package/src/components/common/DialogComponent.jsx +308 -0
- package/src/components/common/ErrorStateComponent.jsx +46 -0
- package/src/components/common/FullscreenToggle.jsx +54 -0
- package/src/components/common/HeadingComponent.jsx +29 -0
- package/src/components/common/LoadingComponent.jsx +33 -0
- package/src/components/common/NetworkStatus.jsx +103 -0
- package/src/components/common/NoDataComponent.jsx +45 -0
- package/src/components/common/Pagination.jsx +128 -0
- package/src/components/common/ParagraphComponent.jsx +14 -0
- package/src/components/common/PhoneInputComponent.jsx +242 -0
- package/src/components/common/ReactSelect.jsx +145 -0
- package/src/components/common/SearchSelect.jsx +176 -0
- package/src/components/common/SeeMore.jsx +26 -0
- package/src/components/common/SortableHeader.jsx +23 -0
- package/src/components/common/theme-toggle.jsx +39 -0
- package/src/components/layout/AuthLayout.jsx +90 -0
- package/src/components/layout/PageLayout.jsx +32 -0
- package/src/components/layout/SidebarLayout.jsx +233 -0
- package/src/components/ui/avatar.jsx +84 -0
- package/src/components/ui/badge.jsx +43 -0
- package/src/components/ui/button.jsx +44 -0
- package/src/components/ui/card.jsx +69 -0
- package/src/components/ui/checkbox.jsx +25 -0
- package/src/components/ui/dialog.jsx +149 -0
- package/src/components/ui/empty.jsx +82 -0
- package/src/components/ui/input.jsx +19 -0
- package/src/components/ui/label.jsx +19 -0
- package/src/components/ui/select.jsx +156 -0
- package/src/components/ui/skeleton.jsx +7 -0
- package/src/components/ui/sonner.jsx +37 -0
- package/src/components/ui/switch.jsx +23 -0
- package/src/components/ui/table.jsx +74 -0
- package/src/components/ui/textarea.jsx +16 -0
- package/src/constants/constant.js +16 -0
- package/src/context/theme-provider.jsx +48 -0
- package/src/features/components/ComponentFormDialog.jsx +162 -0
- package/src/features/components/ComponentsTable.jsx +219 -0
- package/src/features/components/componentStyles.js +16 -0
- package/src/features/components/mockData.js +407 -0
- package/src/features/playground/BasicsSection.jsx +122 -0
- package/src/features/playground/DataSection.jsx +210 -0
- package/src/features/playground/DemoCard.jsx +21 -0
- package/src/features/playground/FeedbackSection.jsx +309 -0
- package/src/features/playground/FormsSection.jsx +188 -0
- package/src/features/playground/UtilitiesSection.jsx +200 -0
- package/src/hooks/useApiHandler.jsx +82 -0
- package/src/hooks/useDebounce.js +12 -0
- package/src/lib/utils.js +1 -0
- package/src/main.jsx +16 -0
- package/src/pages/auth/ForgotPasswordPage.jsx +101 -0
- package/src/pages/auth/LoginPage.jsx +120 -0
- package/src/pages/auth/SignupPage.jsx +135 -0
- package/src/pages/views/ComponentsPage.jsx +316 -0
- package/src/pages/views/DashboardPage.jsx +260 -0
- package/src/pages/views/LandingPage.jsx +772 -0
- package/src/pages/views/NotFoundPage.jsx +30 -0
- package/src/pages/views/PlaygroundPage.jsx +50 -0
- package/src/routes/AppRoutes.jsx +29 -0
- package/src/routes/ProtectedRoute.jsx +18 -0
- package/src/utils/exportCsv.js +17 -0
- package/src/utils/formatCurrency.js +19 -0
- package/src/utils/formatDateTime.js +34 -0
- package/src/utils/handleSessionExpire.js +22 -0
- package/src/utils/logger.js +34 -0
- package/vite.config.js +23 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Select from "react-select";
|
|
3
|
+
import { useTheme } from "next-themes";
|
|
4
|
+
|
|
5
|
+
const colourStyles = {
|
|
6
|
+
control: (styles, { isDisabled, isFocused, selectProps }) => ({
|
|
7
|
+
...styles,
|
|
8
|
+
backgroundColor: isDisabled ? "var(--muted)" : "var(--card)",
|
|
9
|
+
borderColor: selectProps.isInvalid ? "var(--destructive)" : isFocused ? "var(--primary)" : "var(--border)",
|
|
10
|
+
boxShadow: selectProps.isInvalid ? "0 0 0 1px var(--destructive)" : isFocused ? "0 0 0 1px var(--primary)" : "none",
|
|
11
|
+
borderRadius: "var(--radius-md)",
|
|
12
|
+
padding: "1px 4px",
|
|
13
|
+
minHeight: "36px",
|
|
14
|
+
fontSize: "0.875rem",
|
|
15
|
+
":hover": {
|
|
16
|
+
borderColor: selectProps.isInvalid ? "var(--destructive)" : "var(--primary)",
|
|
17
|
+
},
|
|
18
|
+
}),
|
|
19
|
+
menu: (styles) => ({
|
|
20
|
+
...styles,
|
|
21
|
+
backgroundColor: "var(--card)",
|
|
22
|
+
border: "1px solid var(--border)",
|
|
23
|
+
borderRadius: "var(--radius-md)",
|
|
24
|
+
overflow: "hidden",
|
|
25
|
+
zIndex: 9999,
|
|
26
|
+
}),
|
|
27
|
+
menuList: (styles) => ({
|
|
28
|
+
...styles,
|
|
29
|
+
padding: 0,
|
|
30
|
+
maxHeight: 200,
|
|
31
|
+
}),
|
|
32
|
+
option: (styles, { isFocused, isSelected }) => ({
|
|
33
|
+
...styles,
|
|
34
|
+
backgroundColor: isSelected ? "var(--primary)" : isFocused ? "var(--accent)" : "transparent",
|
|
35
|
+
color: isSelected ? "var(--primary-foreground)" : "var(--foreground)",
|
|
36
|
+
padding: "8px 12px",
|
|
37
|
+
fontSize: "0.875rem",
|
|
38
|
+
cursor: "pointer",
|
|
39
|
+
":active": {
|
|
40
|
+
backgroundColor: "var(--primary)",
|
|
41
|
+
color: "var(--primary-foreground)",
|
|
42
|
+
},
|
|
43
|
+
}),
|
|
44
|
+
singleValue: (styles) => ({
|
|
45
|
+
...styles,
|
|
46
|
+
color: "var(--foreground)",
|
|
47
|
+
fontSize: "0.875rem",
|
|
48
|
+
}),
|
|
49
|
+
placeholder: (styles) => ({
|
|
50
|
+
...styles,
|
|
51
|
+
color: "var(--muted-foreground)",
|
|
52
|
+
fontSize: "0.875rem",
|
|
53
|
+
}),
|
|
54
|
+
dropdownIndicator: (styles) => ({
|
|
55
|
+
...styles,
|
|
56
|
+
color: "var(--muted-foreground)",
|
|
57
|
+
padding: "4px",
|
|
58
|
+
":hover": {
|
|
59
|
+
color: "var(--foreground)",
|
|
60
|
+
},
|
|
61
|
+
}),
|
|
62
|
+
indicatorSeparator: () => ({
|
|
63
|
+
display: "none",
|
|
64
|
+
}),
|
|
65
|
+
input: (styles) => ({
|
|
66
|
+
...styles,
|
|
67
|
+
color: "var(--foreground)",
|
|
68
|
+
fontSize: "0.875rem",
|
|
69
|
+
}),
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const ReactSelect = ({
|
|
73
|
+
options = [],
|
|
74
|
+
value,
|
|
75
|
+
onChange,
|
|
76
|
+
placeholder = "Select an option...",
|
|
77
|
+
isDisabled = false,
|
|
78
|
+
isLoading = false,
|
|
79
|
+
isInvalid = false,
|
|
80
|
+
isClearable = false,
|
|
81
|
+
inputId,
|
|
82
|
+
label,
|
|
83
|
+
className = "",
|
|
84
|
+
width = "100%",
|
|
85
|
+
minWidth = "",
|
|
86
|
+
maxWidth = "",
|
|
87
|
+
containerClassName = "",
|
|
88
|
+
}) => {
|
|
89
|
+
const { theme } = useTheme();
|
|
90
|
+
|
|
91
|
+
const customStyles = {
|
|
92
|
+
...colourStyles,
|
|
93
|
+
control: (base, state) => ({
|
|
94
|
+
...colourStyles.control(base, state),
|
|
95
|
+
width: width,
|
|
96
|
+
minWidth: minWidth || undefined,
|
|
97
|
+
maxWidth: maxWidth || undefined,
|
|
98
|
+
}),
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<div className={`w-full ${containerClassName}`}>
|
|
103
|
+
{label && <label className="block text-sm font-medium text-foreground mb-2">{label}</label>}
|
|
104
|
+
<div className={className}>
|
|
105
|
+
<Select
|
|
106
|
+
inputId={inputId}
|
|
107
|
+
options={options}
|
|
108
|
+
value={value}
|
|
109
|
+
onChange={onChange}
|
|
110
|
+
placeholder={placeholder}
|
|
111
|
+
isDisabled={isDisabled}
|
|
112
|
+
isLoading={isLoading}
|
|
113
|
+
isInvalid={isInvalid}
|
|
114
|
+
isClearable={isClearable}
|
|
115
|
+
styles={customStyles}
|
|
116
|
+
theme={(defaultTheme) => ({
|
|
117
|
+
...defaultTheme,
|
|
118
|
+
colors: {
|
|
119
|
+
...defaultTheme.colors,
|
|
120
|
+
primary: "var(--primary)",
|
|
121
|
+
primary75: "var(--primary)",
|
|
122
|
+
primary50: "var(--accent)",
|
|
123
|
+
primary25: "var(--muted)",
|
|
124
|
+
neutral0: "var(--card)",
|
|
125
|
+
neutral5: "var(--muted)",
|
|
126
|
+
neutral10: "var(--border)",
|
|
127
|
+
neutral20: "var(--border)",
|
|
128
|
+
neutral30: "var(--muted-foreground)",
|
|
129
|
+
neutral40: "var(--foreground)",
|
|
130
|
+
neutral50: "var(--foreground)",
|
|
131
|
+
neutral60: "var(--foreground)",
|
|
132
|
+
neutral70: "var(--foreground)",
|
|
133
|
+
neutral80: "var(--foreground)",
|
|
134
|
+
neutral90: "var(--foreground)",
|
|
135
|
+
},
|
|
136
|
+
})}
|
|
137
|
+
className="react-select-container"
|
|
138
|
+
classNamePrefix="react-select"
|
|
139
|
+
/>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
);
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export default ReactSelect;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
import { Combobox } from "@base-ui/react/combobox";
|
|
3
|
+
import { Check, ChevronsUpDown, Search } from "lucide-react";
|
|
4
|
+
import { cn } from "@/lib/utils";
|
|
5
|
+
|
|
6
|
+
const SearchSelect = ({
|
|
7
|
+
id,
|
|
8
|
+
options = [],
|
|
9
|
+
value,
|
|
10
|
+
onValueChange,
|
|
11
|
+
placeholder = "Select...",
|
|
12
|
+
searchPlaceholder = "Search...",
|
|
13
|
+
emptyText = "No results found",
|
|
14
|
+
searchable = true,
|
|
15
|
+
disabled = false,
|
|
16
|
+
invalid = false,
|
|
17
|
+
multiple = false,
|
|
18
|
+
className,
|
|
19
|
+
}) => {
|
|
20
|
+
const chipsRef = useRef(null);
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const el = chipsRef.current;
|
|
24
|
+
if (!el) return undefined;
|
|
25
|
+
const handleWheel = (e) => {
|
|
26
|
+
if (!e.deltaY || el.scrollWidth <= el.clientWidth) return;
|
|
27
|
+
e.preventDefault();
|
|
28
|
+
el.scrollLeft += e.deltaY;
|
|
29
|
+
};
|
|
30
|
+
el.addEventListener("wheel", handleWheel, { passive: false });
|
|
31
|
+
return () => el.removeEventListener("wheel", handleWheel);
|
|
32
|
+
}, [multiple]);
|
|
33
|
+
|
|
34
|
+
const selectedValues = multiple ? (value ?? []).map(String) : [];
|
|
35
|
+
const selected = multiple
|
|
36
|
+
? options.filter((opt) => selectedValues.includes(String(opt.value)))
|
|
37
|
+
: (options.find((opt) => String(opt.value) === String(value)) ?? null);
|
|
38
|
+
|
|
39
|
+
const handleValueChange = (next) => {
|
|
40
|
+
if (multiple) {
|
|
41
|
+
onValueChange?.((next ?? []).map((item) => item.value));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
onValueChange?.(next ? next.value : "");
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<Combobox.Root
|
|
49
|
+
items={options}
|
|
50
|
+
multiple={multiple}
|
|
51
|
+
filter={searchable ? undefined : null}
|
|
52
|
+
value={selected}
|
|
53
|
+
onValueChange={handleValueChange}
|
|
54
|
+
itemToStringLabel={(item) => item.label}
|
|
55
|
+
isItemEqualToValue={(item, current) => String(item.value) === String(current?.value)}
|
|
56
|
+
disabled={disabled}
|
|
57
|
+
>
|
|
58
|
+
<Combobox.Trigger
|
|
59
|
+
id={id}
|
|
60
|
+
aria-invalid={invalid || undefined}
|
|
61
|
+
className={cn(
|
|
62
|
+
"flex h-9 w-full items-center justify-between gap-2 rounded-lg border border-input bg-transparent px-3 text-left text-sm transition-colors outline-none",
|
|
63
|
+
"hover:border-foreground/20 focus-visible:border-primary focus-visible:ring-3 focus-visible:ring-primary/12",
|
|
64
|
+
"data-popup-open:border-primary data-popup-open:ring-3 data-popup-open:ring-primary/12",
|
|
65
|
+
"disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:bg-input/30",
|
|
66
|
+
className,
|
|
67
|
+
)}
|
|
68
|
+
>
|
|
69
|
+
{multiple ? (
|
|
70
|
+
<span
|
|
71
|
+
ref={chipsRef}
|
|
72
|
+
className="flex min-w-0 flex-1 items-center overflow-x-auto overflow-y-hidden [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"
|
|
73
|
+
>
|
|
74
|
+
<Combobox.Value>
|
|
75
|
+
{(items) =>
|
|
76
|
+
items?.length ? (
|
|
77
|
+
<span className="flex items-center gap-1 whitespace-nowrap">
|
|
78
|
+
{items.map((item) => (
|
|
79
|
+
<span
|
|
80
|
+
key={item.value}
|
|
81
|
+
className="inline-flex shrink-0 items-center rounded-md bg-primary/10 px-2 py-0.5 text-xs font-medium text-primary ring-1 ring-primary/20 ring-inset"
|
|
82
|
+
>
|
|
83
|
+
{item.label}
|
|
84
|
+
</span>
|
|
85
|
+
))}
|
|
86
|
+
</span>
|
|
87
|
+
) : (
|
|
88
|
+
<span className="truncate text-muted-foreground">{placeholder}</span>
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
</Combobox.Value>
|
|
92
|
+
</span>
|
|
93
|
+
) : (
|
|
94
|
+
<Combobox.Value placeholder={<span className="text-muted-foreground">{placeholder}</span>}>
|
|
95
|
+
{(item) => <span className="truncate">{item?.label}</span>}
|
|
96
|
+
</Combobox.Value>
|
|
97
|
+
)}
|
|
98
|
+
<Combobox.Icon className="flex shrink-0 text-muted-foreground">
|
|
99
|
+
<ChevronsUpDown className="size-4" />
|
|
100
|
+
</Combobox.Icon>
|
|
101
|
+
</Combobox.Trigger>
|
|
102
|
+
|
|
103
|
+
<Combobox.Portal>
|
|
104
|
+
<Combobox.Positioner sideOffset={6} className="isolate z-50 outline-none">
|
|
105
|
+
<Combobox.Popup
|
|
106
|
+
className={cn(
|
|
107
|
+
"w-(--anchor-width) min-w-44 origin-(--transform-origin) overflow-hidden rounded-xl bg-popover text-popover-foreground shadow-lg shadow-black/8 ring-1 ring-foreground/10 outline-none",
|
|
108
|
+
"duration-150 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
109
|
+
)}
|
|
110
|
+
>
|
|
111
|
+
{searchable && (
|
|
112
|
+
<div className="relative border-b border-border">
|
|
113
|
+
<Search className="pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground" />
|
|
114
|
+
<Combobox.Input
|
|
115
|
+
placeholder={searchPlaceholder}
|
|
116
|
+
className="h-10 w-full bg-transparent pr-3 pl-9 text-sm outline-none placeholder:text-muted-foreground"
|
|
117
|
+
/>
|
|
118
|
+
</div>
|
|
119
|
+
)}
|
|
120
|
+
|
|
121
|
+
<Combobox.Empty className="px-3 py-6 text-center text-sm text-muted-foreground empty:hidden">
|
|
122
|
+
{emptyText}
|
|
123
|
+
</Combobox.Empty>
|
|
124
|
+
|
|
125
|
+
<Combobox.List className="max-h-60 overflow-y-auto p-1.5 outline-none empty:hidden">
|
|
126
|
+
{(item) => {
|
|
127
|
+
const isChecked = multiple
|
|
128
|
+
? selectedValues.includes(String(item.value))
|
|
129
|
+
: String(item.value) === String(value);
|
|
130
|
+
return (
|
|
131
|
+
<Combobox.Item
|
|
132
|
+
key={item.value}
|
|
133
|
+
value={item}
|
|
134
|
+
className={cn(
|
|
135
|
+
"relative flex cursor-pointer items-center gap-2.5 rounded-lg px-3 py-2 text-sm outline-none select-none",
|
|
136
|
+
"data-highlighted:bg-muted",
|
|
137
|
+
isChecked && "font-medium text-primary",
|
|
138
|
+
"data-disabled:pointer-events-none data-disabled:opacity-50",
|
|
139
|
+
)}
|
|
140
|
+
>
|
|
141
|
+
{multiple ? (
|
|
142
|
+
<span
|
|
143
|
+
aria-hidden="true"
|
|
144
|
+
className={cn(
|
|
145
|
+
"flex size-4 shrink-0 items-center justify-center rounded-[4px] border transition-colors",
|
|
146
|
+
isChecked
|
|
147
|
+
? "border-primary bg-primary text-primary-foreground"
|
|
148
|
+
: "border-input bg-transparent",
|
|
149
|
+
)}
|
|
150
|
+
>
|
|
151
|
+
{isChecked && <Check className="size-3" strokeWidth={3} />}
|
|
152
|
+
</span>
|
|
153
|
+
) : (
|
|
154
|
+
<span
|
|
155
|
+
aria-hidden="true"
|
|
156
|
+
className={cn(
|
|
157
|
+
"flex size-4 shrink-0 items-center justify-center rounded-full border transition-colors",
|
|
158
|
+
isChecked ? "border-primary" : "border-input bg-transparent",
|
|
159
|
+
)}
|
|
160
|
+
>
|
|
161
|
+
{isChecked && <span className="size-2 rounded-full bg-primary" />}
|
|
162
|
+
</span>
|
|
163
|
+
)}
|
|
164
|
+
<span className="truncate">{item.label}</span>
|
|
165
|
+
</Combobox.Item>
|
|
166
|
+
);
|
|
167
|
+
}}
|
|
168
|
+
</Combobox.List>
|
|
169
|
+
</Combobox.Popup>
|
|
170
|
+
</Combobox.Positioner>
|
|
171
|
+
</Combobox.Portal>
|
|
172
|
+
</Combobox.Root>
|
|
173
|
+
);
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
export default SearchSelect;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { cn } from "@/lib/utils";
|
|
3
|
+
|
|
4
|
+
const SeeMore = ({ text, limit = 120, className }) => {
|
|
5
|
+
const [expanded, setExpanded] = useState(false);
|
|
6
|
+
|
|
7
|
+
if (!text) return null;
|
|
8
|
+
if (text.length <= limit) {
|
|
9
|
+
return <p className={cn("text-sm text-foreground", className)}>{text}</p>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<p className={cn("text-sm text-foreground", className)}>
|
|
14
|
+
{expanded ? text : `${text.slice(0, limit).trimEnd()}...`}{" "}
|
|
15
|
+
<button
|
|
16
|
+
type="button"
|
|
17
|
+
onClick={() => setExpanded((prev) => !prev)}
|
|
18
|
+
className="font-medium text-primary hover:underline"
|
|
19
|
+
>
|
|
20
|
+
{expanded ? "See less" : "See more"}
|
|
21
|
+
</button>
|
|
22
|
+
</p>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default SeeMore;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ArrowDown, ArrowUp, ArrowUpDown } from "lucide-react";
|
|
2
|
+
import { cn } from "@/lib/utils";
|
|
3
|
+
|
|
4
|
+
const SortableHeader = ({ label, sortKey, sortBy, sortOrder, onSort, className }) => {
|
|
5
|
+
const active = sortBy === sortKey;
|
|
6
|
+
const Icon = active ? (sortOrder === "asc" ? ArrowUp : ArrowDown) : ArrowUpDown;
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<button
|
|
10
|
+
type="button"
|
|
11
|
+
onClick={() => onSort?.(sortKey)}
|
|
12
|
+
className={cn(
|
|
13
|
+
"inline-flex items-center gap-1 text-left font-medium text-foreground transition-colors hover:text-primary-hover",
|
|
14
|
+
className,
|
|
15
|
+
)}
|
|
16
|
+
>
|
|
17
|
+
{label}
|
|
18
|
+
<Icon className={cn("h-3.5 w-3.5", active ? "text-primary" : "text-muted-foreground")} />
|
|
19
|
+
</button>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default SortableHeader;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { AnimatePresence, motion } from "framer-motion";
|
|
2
|
+
import { Moon, Sun } from "lucide-react";
|
|
3
|
+
import { Button } from "@/components/ui/button";
|
|
4
|
+
import { useTheme } from "@/context/theme-provider";
|
|
5
|
+
|
|
6
|
+
const resolveTheme = (theme) => {
|
|
7
|
+
if (theme !== "system") return theme;
|
|
8
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function ThemeToggle({ variant = "outline", size = "sm", className }) {
|
|
12
|
+
const { theme, setTheme } = useTheme();
|
|
13
|
+
const isDark = resolveTheme(theme) === "dark";
|
|
14
|
+
const Icon = isDark ? Moon : Sun;
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Button
|
|
18
|
+
variant={variant}
|
|
19
|
+
size={size}
|
|
20
|
+
className={className}
|
|
21
|
+
onClick={() => setTheme(isDark ? "light" : "dark")}
|
|
22
|
+
title={isDark ? "Switch to light mode" : "Switch to dark mode"}
|
|
23
|
+
>
|
|
24
|
+
<AnimatePresence mode="wait" initial={false}>
|
|
25
|
+
<motion.span
|
|
26
|
+
key={isDark ? "dark" : "light"}
|
|
27
|
+
className="flex"
|
|
28
|
+
initial={{ opacity: 0, rotate: -90, scale: 0.5 }}
|
|
29
|
+
animate={{ opacity: 1, rotate: 0, scale: 1 }}
|
|
30
|
+
exit={{ opacity: 0, rotate: 90, scale: 0.5 }}
|
|
31
|
+
transition={{ duration: 0.2, ease: "easeOut" }}
|
|
32
|
+
>
|
|
33
|
+
<Icon className="h-[1.1rem] w-[1.1rem]" />
|
|
34
|
+
</motion.span>
|
|
35
|
+
</AnimatePresence>
|
|
36
|
+
<span className="sr-only">Toggle theme</span>
|
|
37
|
+
</Button>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Link } from "react-router-dom";
|
|
2
|
+
import { Check, Info, Terminal } from "lucide-react";
|
|
3
|
+
import { ThemeToggle } from "@/components/common/theme-toggle";
|
|
4
|
+
import { APP_NAME } from "@/constants/constant";
|
|
5
|
+
import authImage from "@/assets/images/placeholders/placeholder-360x260.png";
|
|
6
|
+
|
|
7
|
+
const HIGHLIGHTS = [
|
|
8
|
+
"Public and protected routes with session handling",
|
|
9
|
+
"API layer with toasts, timeouts and request cancellation",
|
|
10
|
+
"Component kit with light and dark themes",
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
const AuthLayout = ({ title, subtitle, notice, children, footer }) => {
|
|
14
|
+
return (
|
|
15
|
+
<div className="grid min-h-screen w-full lg:grid-cols-2">
|
|
16
|
+
<div className="relative hidden flex-col justify-between overflow-hidden p-10 text-white lg:flex">
|
|
17
|
+
<img
|
|
18
|
+
src={authImage}
|
|
19
|
+
alt=""
|
|
20
|
+
aria-hidden="true"
|
|
21
|
+
className="pointer-events-none absolute inset-0 h-full w-full object-cover"
|
|
22
|
+
/>
|
|
23
|
+
<div className="pointer-events-none absolute inset-0 bg-linear-to-t from-black/85 via-black/45 to-black/35" />
|
|
24
|
+
|
|
25
|
+
<Link to="/" className="relative flex items-center gap-2.5">
|
|
26
|
+
<div className="flex h-8 w-8 items-center justify-center rounded-lg bg-white text-sm font-bold text-primary shadow-md">
|
|
27
|
+
{APP_NAME.charAt(0)}
|
|
28
|
+
</div>
|
|
29
|
+
<span className="text-base font-semibold">{APP_NAME}</span>
|
|
30
|
+
</Link>
|
|
31
|
+
|
|
32
|
+
<div className="relative space-y-6 [text-shadow:0_1px_12px_rgb(0_0_0/0.45)]">
|
|
33
|
+
<span className="flex h-12 w-12 items-center justify-center rounded-xl bg-white/15 ring-1 ring-white/20 backdrop-blur">
|
|
34
|
+
<Terminal className="h-6 w-6" />
|
|
35
|
+
</span>
|
|
36
|
+
<p className="max-w-md font-heading text-3xl leading-tight font-bold tracking-tight text-balance">
|
|
37
|
+
A React foundation with routing, auth screens, an API layer and a UI kit, configured once and reused in
|
|
38
|
+
every project.
|
|
39
|
+
</p>
|
|
40
|
+
<ul className="space-y-3 text-sm text-white/85">
|
|
41
|
+
{HIGHLIGHTS.map((item) => (
|
|
42
|
+
<li key={item} className="flex items-center gap-2.5">
|
|
43
|
+
<span className="flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-white/20">
|
|
44
|
+
<Check className="h-3 w-3" />
|
|
45
|
+
</span>
|
|
46
|
+
{item}
|
|
47
|
+
</li>
|
|
48
|
+
))}
|
|
49
|
+
</ul>
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
<p className="relative text-xs text-white/60">React starter template</p>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
<div className="flex flex-col bg-background">
|
|
56
|
+
<div className="flex items-center justify-between p-4 lg:justify-end">
|
|
57
|
+
<Link to="/" className="flex items-center gap-2 lg:hidden">
|
|
58
|
+
<div className="flex h-7 w-7 items-center justify-center rounded-lg bg-primary text-xs font-bold text-primary-foreground">
|
|
59
|
+
{APP_NAME.charAt(0)}
|
|
60
|
+
</div>
|
|
61
|
+
<span className="text-sm font-semibold">{APP_NAME}</span>
|
|
62
|
+
</Link>
|
|
63
|
+
<ThemeToggle />
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
<div className="flex flex-1 items-center justify-center px-6 pb-10">
|
|
67
|
+
<div className="w-full max-w-sm space-y-6">
|
|
68
|
+
<div className="space-y-1.5 text-center">
|
|
69
|
+
<h1 className="font-heading text-2xl font-semibold tracking-tight">{title}</h1>
|
|
70
|
+
{subtitle && <p className="text-sm text-muted-foreground">{subtitle}</p>}
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
{notice && (
|
|
74
|
+
<div className="flex gap-2.5 rounded-lg border border-primary/20 bg-primary/5 px-3 py-2.5 text-xs leading-relaxed text-muted-foreground">
|
|
75
|
+
<Info className="mt-px h-3.5 w-3.5 shrink-0 text-primary" />
|
|
76
|
+
<p>{notice}</p>
|
|
77
|
+
</div>
|
|
78
|
+
)}
|
|
79
|
+
|
|
80
|
+
{children}
|
|
81
|
+
|
|
82
|
+
{footer && <div className="text-center text-sm text-muted-foreground">{footer}</div>}
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export default AuthLayout;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { cn } from "@/lib/utils";
|
|
3
|
+
import SidebarLayout from "@/components/layout/SidebarLayout";
|
|
4
|
+
|
|
5
|
+
const VARIANT_CLASSES = {
|
|
6
|
+
primary: "h-full p-2 overflow-y-auto",
|
|
7
|
+
secondary: "h-full p-4 md:p-6 lg:p-8 overflow-y-auto",
|
|
8
|
+
table: "flex min-h-0 flex-1 flex-col overflow-hidden px-2 py-1",
|
|
9
|
+
center: "flex items-center justify-center min-h-[calc(100vh-3rem)] w-full",
|
|
10
|
+
fluid: "h-full w-full",
|
|
11
|
+
fixed: "h-full w-full overflow-hidden",
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const CONTAINER_CLASSES = {
|
|
15
|
+
none: "",
|
|
16
|
+
sm: "max-w-screen-sm mx-auto w-full",
|
|
17
|
+
md: "max-w-screen-md mx-auto w-full",
|
|
18
|
+
lg: "max-w-screen-lg mx-auto w-full",
|
|
19
|
+
xl: "max-w-screen-xl mx-auto w-full",
|
|
20
|
+
full: "w-full",
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const PageLayout = ({ children, variant = "primary", container = "none", className, showSidebar = false }) => {
|
|
24
|
+
const resolvedVariant = VARIANT_CLASSES[variant] ?? VARIANT_CLASSES.primary;
|
|
25
|
+
const resolvedContainer = CONTAINER_CLASSES[container] ?? "";
|
|
26
|
+
|
|
27
|
+
const content = <div className={cn(resolvedVariant, "bg-background", resolvedContainer, className)}>{children}</div>;
|
|
28
|
+
|
|
29
|
+
return showSidebar ? <SidebarLayout>{content}</SidebarLayout> : content;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default PageLayout;
|