feat(site): root opens the main gym; other gyms as navbar buttons

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
andreandClaude Sonnet 5.5 committed 2026-10-13 17:06:59 +01:00
1 parent aa55d44406
commit 716eec9f6d
4 files changed
+45 -4

No files matched your search

+23
View File
@@ -408,6 +408,29 @@ section[id] {
color: #fff !important;
}
/* ── Other-gym button (right end of the navbar) ────────────────────────────── */
.gym-switch-btn {
display: inline-block;
background: var(--fitme-accent);
color: var(--fitme-dark);
font-weight: 700;
text-transform: uppercase;
letter-spacing: .5px;
text-decoration: none;
white-space: nowrap;
border: 2px solid var(--fitme-accent);
border-radius: var(--fitme-radius);
padding: 6px 16px;
transition: background-color var(--fitme-transition), color var(--fitme-transition);
}
.gym-switch-btn:hover,
.gym-switch-btn:focus-visible {
background: var(--fitme-dark);
border-color: var(--fitme-dark);
color: var(--fitme-accent);
}
/* ── Sticky Navbar ─────────────────────────────────────────────────────────── */
.navbar-toggler {
min-width: 44px;
+16
View File
@@ -47,6 +47,22 @@ $logo_dims = svg_img_dims_attr(dirname(__DIR__, 2) . '/' . $logo_rel);
</li>
<?php endforeach; ?>
</ul>
<?php
// Other published gyms: the main gym opens first, the rest are
// highlighted buttons at the right end of the bar.
$other_gyms = [];
if (!empty($GLOBALS['pdo'])) {
foreach (db_gyms_published($GLOBALS['pdo']) as $g) {
if ((int) $g['id'] !== (int) current_gym()['id']) $other_gyms[] = $g;
}
}
if ($other_gyms): ?>
<div class="gym-switch d-flex flex-wrap gap-2 ms-lg-auto py-2 py-lg-0 pe-lg-3">
<?php foreach ($other_gyms as $g): ?>
<a class="gym-switch-btn" href="<?= htmlspecialchars(gym_url($g)) ?>"><?= htmlspecialchars($g['name']) ?></a>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
</nav>
</header>
+5 -3
View File
@@ -5,13 +5,15 @@ $current_uri_2 = '';
// No gym in the URL (/, /home, old links): send people to a gym page. With a
// single published gym that is a 301 to it (query string kept, e.g.
// ?agendar=ok); with more, the gym chooser.
// ?agendar=ok); with more, the main (default) gym — the others are reached
// from the navbar's «Ginásios» menu.
if (($_GET['gym'] ?? '') === '') {
require_once __DIR__ . '/../config/db.php';
require_once __DIR__ . '/../config/functions.php';
$published = db_gyms_published($pdo);
if (count($published) > 1) { require __DIR__ . '/gym_chooser.php'; exit; }
$to = $published[0] ?? db_gyms_default($pdo) ?? gym_fallback();
$main = null;
foreach ($published as $g) { if ((int) ($g['is_default'] ?? 0) === 1) { $main = $g; break; } }
$to = $main ?? $published[0] ?? db_gyms_default($pdo) ?? gym_fallback();
$qs = $_SERVER['QUERY_STRING'] ?? '';
header('Location: ' . gym_url($to) . ($qs !== '' ? '?' . $qs : ''), true, 301);
exit;