|
- <?php
-
- declare(strict_types=1);
-
- $navigationItems = [
- ['label' => 'Home', 'href' => '/'],
- ['label' => 'Campaigns', 'href' => '/campaigns'],
- ['label' => 'Campaign Types', 'href' => '/campaign-types'],
- ['label' => 'Jobs', 'href' => '/jobs'],
- ['label' => 'Job Types', 'href' => '/job-types'],
- ];
-
- $currentPath = parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH);
- $currentPath = is_string($currentPath) && $currentPath !== '' ? $currentPath : '/';
- $jsVersion = filemtime(__DIR__ . '/../../../public/js/app.js') ?: time();
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title><?= e($pageTitle ?? 'Campaign Tracker') ?></title>
- <link rel="preconnect" href="https://fonts.googleapis.com">
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
- <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&family=IBM+Plex+Sans:wght@400;600&family=Public+Sans:wght@400;600;700;800&display=swap">
- <link rel="stylesheet" href="https://unpkg.com/tabulator-tables@6.3.1/dist/css/tabulator.min.css">
- <link rel="stylesheet" href="<?= e(asset('css/site.css')) ?>">
- <script>window.__csrf = '<?= e(csrf_token()) ?>';</script>
- <script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.10/dist/htmx.min.js" integrity="sha384-H5SrcfygHmAuTDZphMHqBJLc3FhssKjG7w/CeCpFReSfwBWDTKpkzPP8c+cLsK+V" crossorigin="anonymous" defer></script>
- <script src="https://unpkg.com/tabulator-tables@6.3.1/dist/js/tabulator.min.js" defer></script>
- <script src="<?= e(asset('js/app.js')) ?>?v=<?= e((string) $jsVersion) ?>" defer></script>
- <script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
- </head>
- <body>
- <div class="page-shell">
- <header class="site-header">
- <div class="container header-inner">
- <a class="brand" href="/">
- <span class="brand-mark">CT</span>
- <span class="brand-copy">
- <strong>Campaign Tracker</strong>
- <small>PHP MVC</small>
- </span>
- </a>
-
- <nav class="site-nav" aria-label="Primary navigation">
- <?php
- $navIcons = [
- '/' => '<svg width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.75" viewBox="0 0 24 24" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"/></svg>',
- '/campaigns' => '<svg width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.75" viewBox="0 0 24 24" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2M9 12h6m-6 4h4"/></svg>',
- '/campaign-types' => '<svg width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.75" viewBox="0 0 24 24" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M7 7h.01M3 3h7.5L21 12l-9 9-10.5-10.5V3z"/></svg>',
- '/jobs' => '<svg width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.75" viewBox="0 0 24 24" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M21 13.255A23.931 23.931 0 0112 15c-3.183 0-6.22-.62-9-1.745M16 6V4a2 2 0 00-2-2h-4a2 2 0 00-2 2v2m4 6h.01M5 20h14a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/></svg>',
- '/job-types' => '<svg width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.75" viewBox="0 0 24 24" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4"/></svg>',
- ];
- $prevHref = null;
- $group1 = ['/'];
- $group2 = ['/campaigns', '/campaign-types'];
- $group3 = ['/jobs', '/job-types'];
- foreach ($navigationItems as $item):
- $isActive = $item['href'] === '/'
- ? $currentPath === '/'
- : str_starts_with($currentPath, $item['href']);
- $needsSep = ($prevHref !== null) && (
- (in_array($prevHref, $group1) && in_array($item['href'], $group2)) ||
- (in_array($prevHref, $group2) && in_array($item['href'], $group3))
- );
- if ($needsSep): ?>
- <span class="nav-sep" aria-hidden="true"></span>
- <?php endif; ?>
- <a class="nav-link<?= $isActive ? ' is-active' : '' ?>" href="<?= e($item['href']) ?>">
- <?= $navIcons[$item['href']] ?? '' ?>
- <?= e($item['label']) ?>
- </a>
- <?php $prevHref = $item['href'];
- endforeach; ?>
-
- <?php if (auth()->check()): ?>
- <span class="nav-sep" aria-hidden="true"></span>
- <span class="nav-user"><?= e(auth()->user()?->displayName ?: auth()->user()?->username ?? '') ?></span>
- <form method="post" action="/logout" class="nav-logout-form">
- <?= csrf_field() ?>
- <button type="submit" class="nav-logout-btn">Log out</button>
- </form>
- <?php endif; ?>
- </nav>
- </div>
- </header>
|