Wiki: subpage tiles spread evenly across rows (4/4 instead of 5/3), Wiki below the divider above Raids in the menu
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
f22ab97947
commit
0ace02f6e0
2 changed files with 29 additions and 4 deletions
|
|
@ -214,15 +214,15 @@ $otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($
|
|||
<?php endif; ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($canViewWiki || $canViewRaids || $canViewPremades || $canViewEvents || $canViewMap || $canViewWarehouse || $canViewGear): ?>
|
||||
<div class="sidebar-nav-gap"></div>
|
||||
<?php endif; ?>
|
||||
<?php if ($canViewWiki): ?>
|
||||
<a href="/wiki.php" class="sidebar-link<?= $isWikiActive ? ' active' : '' ?>" title="Wiki">
|
||||
<?= icon('book') ?><span class="label">Wiki</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($canViewRaids || $canViewPremades || $canViewEvents || $canViewMap || $canViewWarehouse || $canViewGear): ?>
|
||||
<div class="sidebar-nav-gap"></div>
|
||||
<?php endif; ?>
|
||||
<?php if ($canViewRaids): ?>
|
||||
<a href="/raids.php" class="sidebar-link<?= $isRaidsActive ? ' active' : '' ?>" title="Raids">
|
||||
<?= icon('calendar') ?><span class="label">Raids</span>
|
||||
|
|
|
|||
25
wiki.php
25
wiki.php
|
|
@ -310,4 +310,29 @@ $nameOf = static fn (array $u): string => $u['display_name'] !== '' ? $u['displa
|
|||
<?php endif; ?>
|
||||
</main>
|
||||
</div>
|
||||
<script>
|
||||
// "In diesem Kapitel": Kacheln gleichmaessig auf die Zeilen verteilen (8 bei Platz fuer 5 -> 4/4 statt 5/3)
|
||||
(function () {
|
||||
var grids = document.querySelectorAll('.wiki-subpage-grid');
|
||||
if (!grids.length) return;
|
||||
var MIN_WIDTH = 220; // wie minmax(220px, 1fr) im CSS
|
||||
function balance(grid) {
|
||||
var count = grid.children.length;
|
||||
var gap = parseFloat(getComputedStyle(grid).columnGap) || 0;
|
||||
var maxCols = Math.max(1, Math.floor((grid.clientWidth + gap) / (MIN_WIDTH + gap)));
|
||||
// Am liebsten eine Spaltenzahl, die glatt aufgeht (8 -> 4/4 oder 2/2/2/2) - solange sie
|
||||
// mindestens die halbe Breite nutzt. Sonst so gleichmaessig wie moeglich (7 -> 4/3).
|
||||
var cols = 0;
|
||||
for (var c = Math.min(maxCols, count); c >= Math.ceil(Math.min(maxCols, count) / 2); c--) {
|
||||
if (count % c === 0) { cols = c; break; }
|
||||
}
|
||||
if (!cols) cols = Math.ceil(count / Math.ceil(count / maxCols));
|
||||
grid.style.gridTemplateColumns = 'repeat(' + cols + ', minmax(0, 1fr))';
|
||||
}
|
||||
grids.forEach(function (grid) {
|
||||
balance(grid);
|
||||
if (window.ResizeObserver) new ResizeObserver(function () { balance(grid); }).observe(grid);
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
<?php include __DIR__ . '/includes/footer.php'; ?>
|
||||
|
|
|
|||
Loading…
Reference in a new issue