Files

38 lines
1.9 KiB
PHP

<?php
function layout_head(string $title): void {
echo '<!DOCTYPE html><html lang="fr"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>' . htmlspecialchars($title) . ' — PercoVitrine</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
<link rel="stylesheet" href="/assets/style.css">
</head><body><div class="app-wrap">';
}
function layout_sidebar(string $active = ''): void {
$links = [
['href'=>'/','icon'=>'fa-store','label'=>'Produits','key'=>'products'],
['href'=>'/categories.php','icon'=>'fa-tags','label'=>'Catégories','key'=>'categories'],
['href'=>'/settings.php','icon'=>'fa-gear','label'=>'Réglages / Etsy','key'=>'settings'],
];
echo '<aside class="sidebar"><a href="/" class="sidebar-brand"><i class="fas fa-store"></i> <span>PercoVitrine</span></a><nav class="sidebar-nav">';
echo '<div class="sidebar-section">Menu</div>';
foreach ($links as $l) {
$cls = $active === $l['key'] ? ' active' : '';
echo '<a href="' . $l['href'] . '" class="sidebar-link' . $cls . '"><i class="fas ' . $l['icon'] . '"></i><span>' . $l['label'] . '</span></a>';
}
echo '</nav></aside>';
}
function layout_main_open(): void {
echo '<main class="main">';
}
function layout_foot(): void {
echo '</main></div><div id="toasts" class="toast-wrap"></div>
<script>
function toast(msg,type="ok"){const c=document.getElementById("toasts");const t=document.createElement("div");t.className="toast"+(type==="error"?" error":"");t.textContent=msg;c.appendChild(t);setTimeout(()=>t.remove(),3500);}
function confirm2(msg){return new Promise(r=>{if(confirm(msg))r(true);else r(false);})}
</script></body></html>';
}