This commit is contained in:
105
frontend/src/layouts/Layout.astro
Normal file
105
frontend/src/layouts/Layout.astro
Normal file
@@ -0,0 +1,105 @@
|
||||
---
|
||||
import { ClientRouter } from 'astro:transitions';
|
||||
import '../config.css';
|
||||
import '../styles/global.css';
|
||||
import ThemeToggle from '../components/ui/ThemeToggle.jsx';
|
||||
import ButtonDisplayCounter from '../components/atom/ButtonDisplayCounter.jsx';
|
||||
import Toast from '../components/ui/Toast.jsx';
|
||||
import ToastTrigger from '../components/ToastTrigger.jsx';
|
||||
import NetworkGuard from '../components/ui/NetworkGuard.jsx';
|
||||
import Navbar from '../components/Navbar.jsx';
|
||||
import ToastProvider from '../components/toast/ToastProvider';
|
||||
|
||||
interface Props {
|
||||
title: string;
|
||||
isAuthPage?: boolean;
|
||||
minimalNav?: boolean;
|
||||
}
|
||||
|
||||
const { title, isAuthPage = false, minimalNav = false } = Astro.props as Props;
|
||||
const isProd = import.meta.env.PROD;
|
||||
const isDev = import.meta.env.DEV;
|
||||
---
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="hr" class="h-full scroll-smooth">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/pwa-icon.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="theme-color" content="#4f46e5" />
|
||||
<meta name="mobile-web-app-capable" content="yes" />
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<link rel="manifest" href="/manifest.webmanifest" />
|
||||
<ClientRouter />
|
||||
<title>{title}</title>
|
||||
|
||||
<script is:inline>
|
||||
function primijeniTemu() {
|
||||
const lokalnaTema = localStorage.getItem('theme');
|
||||
const preferiraTamno = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||
if (lokalnaTema === 'dark' || (!lokalnaTema && preferiraTamno)) {
|
||||
document.documentElement.classList.add('dark');
|
||||
} else {
|
||||
document.documentElement.classList.remove('dark');
|
||||
}
|
||||
}
|
||||
primijeniTemu();
|
||||
document.addEventListener('astro:page-load', primijeniTemu);
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body class="relative min-h-screen bg-canvas-base text-text-main font-sans antialiased transition-colors duration-300">
|
||||
<div class="absolute inset-0 bg-[linear-gradient(to_right,var(--color-text-main)_0.03_1px,transparent_1px),linear-gradient(to_bottom,var(--color-text-main)_0.03_1px,transparent_1px)] bg-[size:64px_64px] opacity-[0.4] dark:opacity-[0.02] pointer-events-none z-0"></div>
|
||||
|
||||
{!isAuthPage && <NetworkGuard client:only="preact" />}
|
||||
<Toast client:load />
|
||||
<ToastProvider client:load />
|
||||
{!isAuthPage && isDev && <ToastTrigger client:load />}
|
||||
{!isAuthPage && <Navbar client:load minimal={minimalNav} />}
|
||||
|
||||
<div id="main-content" class="relative z-10 flex flex-col min-h-screen max-w-6xl mx-auto px-6 md:px-8 py-6">
|
||||
<header class="flex flex-row justify-between items-end pb-6 mb-8 border-b border-border-hairline">
|
||||
<div class="flex flex-col">
|
||||
<span class="text-[10px] font-mono tracking-widest text-text-muted opacity-60 uppercase">// CORE_INFRASTRUCTURE</span>
|
||||
<h1 class="text-xl font-bold bg-gradient-to-b from-text-main to-text-main/80 bg-clip-text text-transparent tracking-tight">
|
||||
Astro ERP Platforma
|
||||
</h1>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main class="flex-1 w-full" transition:animate="fade">
|
||||
<slot />
|
||||
</main>
|
||||
|
||||
<footer class="mt-20 pt-6 border-t border-border-hairline flex flex-row justify-between items-center text-[11px] font-mono text-text-muted opacity-50">
|
||||
<span>SYSTEM_STATUS: ACTIVE</span>
|
||||
<span>© {new Date().getFullYear()} CORE_LOGISTICS.</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
<script is:inline define:vars={{ isProd }}>
|
||||
if (typeof window !== 'undefined' && 'serviceWorker' in navigator && window.isSecureContext) {
|
||||
window.addEventListener('load', async function () {
|
||||
if (isProd) {
|
||||
navigator.serviceWorker.register('/service-worker.js').catch(function (error) {
|
||||
console.error('Service worker registration failed:', error);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const registrations = await navigator.serviceWorker.getRegistrations();
|
||||
await Promise.all(registrations.map((registration) => registration.unregister()));
|
||||
if ('caches' in window) {
|
||||
const keys = await caches.keys();
|
||||
await Promise.all(
|
||||
keys
|
||||
.filter((key) => key.startsWith('erp-shell-'))
|
||||
.map((key) => caches.delete(key))
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user