Skip to content

Commit 4f284f6

Browse files
committed
Add ranking view tabs and adminPageTabs styles
1 parent 15fa548 commit 4f284f6

2 files changed

Lines changed: 90 additions & 22 deletions

File tree

public/assets/css/style.css

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ Admin
529529
}
530530

531531
.adminNav a,
532-
.rankingTabs a
532+
.adminPageTabs a
533533
{
534534
display: inline-flex;
535535
align-items: center;
@@ -545,14 +545,14 @@ Admin
545545
}
546546

547547
.adminNav a:hover,
548-
.rankingTabs a:hover
548+
.adminPageTabs a:hover
549549
{
550550
background: #eef2f7;
551551
color: #111827;
552552
}
553553

554554
.adminNav a.active,
555-
.rankingTabs a.active
555+
.adminPageTabs a.active
556556
{
557557
background: #e8f0fe;
558558
color: #1A73E8;
@@ -592,6 +592,17 @@ Admin
592592
font-weight: bold;
593593
}
594594

595+
.adminPageTabs
596+
{
597+
display: inline-flex;
598+
gap: 6px;
599+
margin-bottom: 4px;
600+
padding: 4px;
601+
background: #ffffff;
602+
border: 1px solid #dfe4ea;
603+
border-radius: 10px;
604+
}
605+
595606
.adminPanel
596607
{
597608
margin-top: 18px;
@@ -693,6 +704,7 @@ Admin
693704
}
694705

695706
.adminInputRow input,
707+
.adminSelect,
696708
.rankingWeights input
697709
{
698710
width: 100%;
@@ -707,13 +719,35 @@ Admin
707719
}
708720

709721
.adminInputRow input:focus,
722+
.adminSelect:focus,
710723
.rankingWeights input:focus
711724
{
712725
border-color: #1A73E8;
713726
box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.14);
714727
}
715728

716-
.adminPrimaryButton
729+
.adminSelectForm
730+
{
731+
display: flex;
732+
align-items: flex-end;
733+
gap: 10px;
734+
margin-bottom: 16px;
735+
}
736+
737+
.adminSelectForm label
738+
{
739+
margin-bottom: 7px;
740+
}
741+
742+
.adminSelect
743+
{
744+
min-width: 190px;
745+
padding-right: 34px;
746+
cursor: pointer;
747+
}
748+
749+
.adminPrimaryButton,
750+
.adminSecondaryButton
717751
{
718752
min-height: 42px;
719753
padding: 0 16px;
@@ -732,6 +766,19 @@ Admin
732766
border-color: #1765cc;
733767
}
734768

769+
.adminSecondaryButton
770+
{
771+
color: #334155;
772+
background: #ffffff;
773+
border-color: #cbd5e1;
774+
}
775+
776+
.adminSecondaryButton:hover
777+
{
778+
background: #f8fafc;
779+
border-color: #94a3b8;
780+
}
781+
735782
.adminStatGrid,
736783
.adminMetricStrip
737784
{
@@ -918,14 +965,6 @@ Admin
918965
font-size: 13px;
919966
}
920967

921-
.rankingTabs
922-
{
923-
display: flex;
924-
flex-wrap: wrap;
925-
gap: 8px;
926-
margin-bottom: 16px;
927-
}
928-
929968
.rankingForm
930969
{
931970
margin-top: 10px;

public/ranking.php

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@
3232
$rankingSettings = new RankingSettings();
3333
$message = '';
3434
$error = '';
35+
$selectedView = selectedRankingView();
3536
$selectedType = selectedRankingType($rankingSettings);
3637

3738
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
39+
$selectedView = 'controls';
3840
$postedType = isset($_POST['type']) ? (string) $_POST['type'] : 'sites';
3941
$selectedType = supportedRankingType($rankingSettings, $postedType);
4042
$token = isset($_POST['csrf_token']) ? (string) $_POST['csrf_token'] : null;
@@ -103,6 +105,13 @@ function requestIp(): string
103105
return (string) ($_SERVER['REMOTE_ADDR'] ?? 'unknown');
104106
}
105107

108+
function selectedRankingView(): string
109+
{
110+
$view = isset($_GET['view']) ? (string) $_GET['view'] : 'controls';
111+
112+
return in_array($view, ['controls', 'analytics'], true) ? $view : 'controls';
113+
}
114+
106115
function selectedRankingType(RankingSettings $settings): string
107116
{
108117
$type = isset($_GET['type']) ? (string) $_GET['type'] : 'sites';
@@ -273,6 +282,17 @@ function renderWeightInputs(array $weights): string
273282
</div>
274283
</section>
275284

285+
<nav class="adminPageTabs" aria-label="Ranking sections">
286+
<a class="<?php echo $selectedView === 'controls' ? 'active' : ''; ?>"
287+
href="ranking.php?view=controls&type=<?php echo h($selectedType); ?>">
288+
Controls
289+
</a>
290+
<a class="<?php echo $selectedView === 'analytics' ? 'active' : ''; ?>"
291+
href="ranking.php?view=analytics&type=<?php echo h($selectedType); ?>">
292+
Analytics
293+
</a>
294+
</nav>
295+
276296
<?php if ($message !== ''): ?>
277297
<p class="adminAlert adminAlertSuccess"><?php echo h($message); ?></p>
278298
<?php endif; ?>
@@ -281,10 +301,11 @@ function renderWeightInputs(array $weights): string
281301
<p class="adminAlert adminAlertDanger"><?php echo h($error); ?></p>
282302
<?php endif; ?>
283303

284-
<?php if ($analyticsError !== ''): ?>
304+
<?php if ($selectedView === 'analytics' && $analyticsError !== ''): ?>
285305
<p class="adminAlert adminAlertWarning"><?php echo h($analyticsError); ?></p>
286306
<?php endif; ?>
287307

308+
<?php if ($selectedView === 'controls'): ?>
288309
<section class="adminPanel">
289310
<div class="adminPanelHeader">
290311
<div>
@@ -293,15 +314,20 @@ function renderWeightInputs(array $weights): string
293314
</div>
294315
</div>
295316

296-
<div class="rankingTabs" role="list">
297-
<?php foreach ($rankingSettings->supportedTypes() as $type): ?>
298-
<a class="<?php echo $type === $selectedType ? 'active' : ''; ?>"
299-
href="ranking.php?type=<?php echo h($type); ?>"
300-
role="listitem">
301-
<?php echo h(ucfirst($type)); ?>
302-
</a>
303-
<?php endforeach; ?>
304-
</div>
317+
<form class="adminForm adminSelectForm" action="ranking.php" method="get">
318+
<input type="hidden" name="view" value="controls">
319+
<label for="ranking-type">Vertical</label>
320+
<select id="ranking-type" class="adminSelect" name="type" onchange="this.form.submit()">
321+
<?php foreach ($rankingSettings->supportedTypes() as $type): ?>
322+
<option value="<?php echo h($type); ?>" <?php echo $type === $selectedType ? 'selected' : ''; ?>>
323+
<?php echo h(ucfirst($type)); ?>
324+
</option>
325+
<?php endforeach; ?>
326+
</select>
327+
<noscript>
328+
<button class="adminSecondaryButton" type="submit">Load</button>
329+
</noscript>
330+
</form>
305331

306332
<form action="ranking.php" method="post" class="adminForm rankingForm">
307333
<input type="hidden" name="csrf_token" value="<?php echo h($csrfToken); ?>">
@@ -329,7 +355,9 @@ function renderWeightInputs(array $weights): string
329355
</div>
330356
</div>
331357
</section>
358+
<?php endif; ?>
332359

360+
<?php if ($selectedView === 'analytics'): ?>
333361
<section class="adminPanel">
334362
<div class="adminPanelHeader">
335363
<div>
@@ -360,6 +388,7 @@ function renderWeightInputs(array $weights): string
360388
</section>
361389
</div>
362390
</section>
391+
<?php endif; ?>
363392
</main>
364393
</div>
365394
</body>

0 commit comments

Comments
 (0)