Spaces:
Running
Running
Commit ·
f0bf30e
1
Parent(s): 5797fa4
feat: add beautiful neo-brutalist stylized loading screen for canvas
Browse files- src/features/canvas/hooks/useCanvasLogic.js +6 -1
- src/index.css +30 -0
- src/pages/CanvasPage.jsx +31 -1
src/features/canvas/hooks/useCanvasLogic.js
CHANGED
|
@@ -275,6 +275,7 @@ export const useCanvasLogic = (projectId, user) => {
|
|
| 275 |
const [saveStatus, setSaveStatus] = useState('saved'); // 'saved', 'saving', 'unsaved'
|
| 276 |
const [projectData, setProjectData] = useState(null);
|
| 277 |
const [collaborators, setCollaborators] = useState([]);
|
|
|
|
| 278 |
|
| 279 |
const activeUsersRef = useRef([]);
|
| 280 |
|
|
@@ -723,6 +724,7 @@ export const useCanvasLogic = (projectId, user) => {
|
|
| 723 |
if (projectId) {
|
| 724 |
const fetchProject = async () => {
|
| 725 |
try {
|
|
|
|
| 726 |
isInitialLoadRef.current = true;
|
| 727 |
setSaveStatus('saved');
|
| 728 |
const res = await axios.get(`${API_URL}/graphs/${projectId}/full`);
|
|
@@ -908,9 +910,11 @@ export const useCanvasLogic = (projectId, user) => {
|
|
| 908 |
|
| 909 |
setTimeout(() => {
|
| 910 |
isInitialLoadRef.current = false;
|
|
|
|
| 911 |
}, 1000);
|
| 912 |
} catch (err) {
|
| 913 |
console.error('Error loading project', err);
|
|
|
|
| 914 |
if (err.response && (err.response.status === 401 || err.response.status === 403 || err.response.status === 404)) {
|
| 915 |
alert("У вас немає прав для доступу до цієї дошки або вона не існує.");
|
| 916 |
navigate('/dashboard');
|
|
@@ -1968,6 +1972,7 @@ export const useCanvasLogic = (projectId, user) => {
|
|
| 1968 |
setActiveThreadId,
|
| 1969 |
createNewThread,
|
| 1970 |
deleteThread,
|
| 1971 |
-
renameThread
|
|
|
|
| 1972 |
};
|
| 1973 |
};
|
|
|
|
| 275 |
const [saveStatus, setSaveStatus] = useState('saved'); // 'saved', 'saving', 'unsaved'
|
| 276 |
const [projectData, setProjectData] = useState(null);
|
| 277 |
const [collaborators, setCollaborators] = useState([]);
|
| 278 |
+
const [isLoading, setIsLoading] = useState(true);
|
| 279 |
|
| 280 |
const activeUsersRef = useRef([]);
|
| 281 |
|
|
|
|
| 724 |
if (projectId) {
|
| 725 |
const fetchProject = async () => {
|
| 726 |
try {
|
| 727 |
+
setIsLoading(true);
|
| 728 |
isInitialLoadRef.current = true;
|
| 729 |
setSaveStatus('saved');
|
| 730 |
const res = await axios.get(`${API_URL}/graphs/${projectId}/full`);
|
|
|
|
| 910 |
|
| 911 |
setTimeout(() => {
|
| 912 |
isInitialLoadRef.current = false;
|
| 913 |
+
setIsLoading(false);
|
| 914 |
}, 1000);
|
| 915 |
} catch (err) {
|
| 916 |
console.error('Error loading project', err);
|
| 917 |
+
setIsLoading(false);
|
| 918 |
if (err.response && (err.response.status === 401 || err.response.status === 403 || err.response.status === 404)) {
|
| 919 |
alert("У вас немає прав для доступу до цієї дошки або вона не існує.");
|
| 920 |
navigate('/dashboard');
|
|
|
|
| 1972 |
setActiveThreadId,
|
| 1973 |
createNewThread,
|
| 1974 |
deleteThread,
|
| 1975 |
+
renameThread,
|
| 1976 |
+
isLoading
|
| 1977 |
};
|
| 1978 |
};
|
src/index.css
CHANGED
|
@@ -219,3 +219,33 @@ h1, h2, h3 {
|
|
| 219 |
linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px) !important;
|
| 220 |
}
|
| 221 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px) !important;
|
| 220 |
}
|
| 221 |
|
| 222 |
+
/* Custom Loading Screen Animations */
|
| 223 |
+
@keyframes loading-bar {
|
| 224 |
+
0% {
|
| 225 |
+
transform: translateX(-100%);
|
| 226 |
+
}
|
| 227 |
+
50% {
|
| 228 |
+
transform: translateX(0%);
|
| 229 |
+
}
|
| 230 |
+
100% {
|
| 231 |
+
transform: translateX(100%);
|
| 232 |
+
}
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
@keyframes spin-slow {
|
| 236 |
+
from {
|
| 237 |
+
transform: rotate(0deg);
|
| 238 |
+
}
|
| 239 |
+
to {
|
| 240 |
+
transform: rotate(360deg);
|
| 241 |
+
}
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
.animate-loading-bar {
|
| 245 |
+
animation: loading-bar 2s ease-in-out infinite;
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
.animate-spin-slow {
|
| 249 |
+
animation: spin-slow 12s linear infinite;
|
| 250 |
+
}
|
| 251 |
+
|
src/pages/CanvasPage.jsx
CHANGED
|
@@ -2134,7 +2134,8 @@ const CanvasInner = () => {
|
|
| 2134 |
setActiveThreadId,
|
| 2135 |
createNewThread,
|
| 2136 |
deleteThread,
|
| 2137 |
-
renameThread
|
|
|
|
| 2138 |
} = useCanvasLogic(id, user);
|
| 2139 |
|
| 2140 |
const hasFittedRef = useRef(false);
|
|
@@ -2769,6 +2770,35 @@ const CanvasInner = () => {
|
|
| 2769 |
<Sidebar />
|
| 2770 |
|
| 2771 |
<main className="flex-grow flex flex-col relative text-primary">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2772 |
<div className="relative h-24 bg-surface-container-lowest border-b-4 border-primary px-8 flex items-center justify-between z-30 shadow-sm">
|
| 2773 |
<div className="flex items-center gap-6">
|
| 2774 |
<button
|
|
|
|
| 2134 |
setActiveThreadId,
|
| 2135 |
createNewThread,
|
| 2136 |
deleteThread,
|
| 2137 |
+
renameThread,
|
| 2138 |
+
isLoading
|
| 2139 |
} = useCanvasLogic(id, user);
|
| 2140 |
|
| 2141 |
const hasFittedRef = useRef(false);
|
|
|
|
| 2770 |
<Sidebar />
|
| 2771 |
|
| 2772 |
<main className="flex-grow flex flex-col relative text-primary">
|
| 2773 |
+
{isLoading && (
|
| 2774 |
+
<div className="absolute inset-0 bg-background flex flex-col items-center justify-center z-[60] animate-fade-in">
|
| 2775 |
+
<div className="flex flex-col items-center gap-6 p-8 bg-surface-container-lowest border-4 border-primary rounded-3xl shadow-[8px_8px_0px_0px_var(--color-primary)] max-w-sm w-full mx-4 text-center">
|
| 2776 |
+
{/* Stylized Neo-brutalist / Sketch spinner */}
|
| 2777 |
+
<div className="relative w-24 h-24 flex items-center justify-center">
|
| 2778 |
+
{/* Sketchbook grid lines background */}
|
| 2779 |
+
<div className="absolute inset-0 rounded-full border-4 border-dashed border-primary/20 animate-spin-slow"></div>
|
| 2780 |
+
{/* Spinner border */}
|
| 2781 |
+
<div className="absolute w-16 h-16 rounded-full border-4 border-primary border-t-transparent animate-spin"></div>
|
| 2782 |
+
{/* Central pulsing target icon */}
|
| 2783 |
+
<Target className="text-primary w-8 h-8 animate-pulse" />
|
| 2784 |
+
</div>
|
| 2785 |
+
|
| 2786 |
+
<div className="space-y-1.5">
|
| 2787 |
+
<h3 className="text-2xl font-display-lg text-primary">
|
| 2788 |
+
{t('canvas.loading', 'Завантаження')}
|
| 2789 |
+
</h3>
|
| 2790 |
+
<p className="text-[11px] font-bold text-primary/50 uppercase tracking-wider leading-relaxed">
|
| 2791 |
+
{t('canvas.loading_sub', 'Завантаження вашої карти цілей...')}
|
| 2792 |
+
</p>
|
| 2793 |
+
</div>
|
| 2794 |
+
|
| 2795 |
+
{/* Neobrutalist Progress bar simulation */}
|
| 2796 |
+
<div className="w-full h-3.5 bg-secondary/10 border-2 border-primary rounded-full overflow-hidden p-0.5 shadow-[2px_2px_0px_0px_var(--color-primary)] relative">
|
| 2797 |
+
<div className="h-full bg-primary rounded-full animate-loading-bar w-1/2"></div>
|
| 2798 |
+
</div>
|
| 2799 |
+
</div>
|
| 2800 |
+
</div>
|
| 2801 |
+
)}
|
| 2802 |
<div className="relative h-24 bg-surface-container-lowest border-b-4 border-primary px-8 flex items-center justify-between z-30 shadow-sm">
|
| 2803 |
<div className="flex items-center gap-6">
|
| 2804 |
<button
|