diff --git a/server/src/html/vote.rs b/server/src/html/vote.rs index 2956cd651174490a2fa4d2537b0563112d1fd885..8bb4e5c77a106aab8ce8b23ab54b856ac75ed15f 100644 --- a/server/src/html/vote.rs +++ b/server/src/html/vote.rs @@ -179,7 +179,7 @@ fn vote_hud_form( } label class="vote-hud-slider" { input type="range" id="vote-preference-slider" min="0" max="100" value="50" - data-winner="left" + data-winner="even" aria-valuemin="0" aria-valuemax="100" aria-valuenow="50" aria-label=(format!("Preference: {} vs {}", left.as_str(), right.as_str())); } @@ -360,7 +360,7 @@ pub async fn vote_page( section class="vote-compare-shell" { h1 { "compare" } (breadcrumb_path(&parent)) - div class="vote-compare-pair" { + div class="vote-compare-pair" data-winner="even" { (vote_compare_item_card(&tree, &left, "vote-compare-left", nsfw_ok)) span class="vote-compare-vs" { "vs" } (vote_compare_item_card(&tree, &right, "vote-compare-right", nsfw_ok)) diff --git a/server/static/sorter.css b/server/static/sorter.css index 73518cb62e8af63634fad7ba2b28a2e12094fe56..248eb5d10274d669063cd34cd0554984ffcfbd9b 100644 --- a/server/static/sorter.css +++ b/server/static/sorter.css @@ -860,8 +860,82 @@ h1 { } @media (max-width: 640px) { + .scope-theme { + padding: 0.75rem; + padding-bottom: 0.5rem; + overflow-x: clip; + } + .vote-page { - --vote-hud-height: 7.5rem; + /* stacked hud: ratio + slider + actions */ + --vote-hud-height: 8.25rem; + } + + .vote-compare-shell h1 { + font-size: 1.35rem; + } + + .vote-compare-pair { + /* Slider doubles as selector: one full post, or mini both at 1:1. */ + display: grid; + grid-template-columns: 1fr; + gap: 0.65rem; + margin: 0.75rem 0; + align-items: stretch; + } + + .vote-compare-pair .vote-compare-vs { + display: none; + } + + .vote-compare-pair[data-winner="left"] .vote-compare-right, + .vote-compare-pair[data-winner="right"] .vote-compare-left { + display: none; + } + + .vote-compare-pair[data-winner="even"] { + grid-template-columns: 1fr 1fr; + gap: 0.5rem; + } + + .vote-compare-pair[data-winner="even"] .vote-compare-side { + min-height: 0; + } + + .vote-compare-pair[data-winner="even"] .entity-card h2 { + font-size: 0.95rem; + line-height: 1.25; + } + + .vote-compare-pair[data-winner="even"] .entity-body, + .vote-compare-pair[data-winner="even"] .reddit-post-url, + .vote-compare-pair[data-winner="even"] .fetch-controls { + display: none; + } + + .vote-compare-pair[data-winner="even"] .reddit-post-image { + max-height: 9rem; + width: 100%; + object-fit: cover; + } + + .vote-compare-pair[data-winner="even"] .entity-section { + padding: 0.65rem; + } + + .vote-compare-side { + min-width: 0; + } + + .vote-compare-side .entity-section { + overflow-wrap: anywhere; + } + + .reddit-post-image { + max-height: min(55vh, 22rem); + width: 100%; + object-fit: contain; + background: color-mix(in oklch, var(--panel) 70%, black); } .vote-hud-inner { @@ -872,17 +946,43 @@ h1 { --vote-actions-col: 100%; } - .vote-hud .vote-ratio-readout, - .vote-hud .vote-compare-actions { + .vote-hud .vote-ratio-readout { width: auto; min-width: 0; + text-align: center; + } + + .vote-hud .vote-ratio-readout .small { + display: inline; } .vote-hud .vote-compare-actions { + width: auto; + min-width: 0; justify-content: center; } .vote-hud { - padding-bottom: max(0.45rem, env(safe-area-inset-bottom)); + padding: 0.55rem 0.65rem; + padding-bottom: max(0.55rem, env(safe-area-inset-bottom)); + } + + .vote-hud-slider input[type="range"] { + height: 2rem; + } + + .vote-hud-slider input[type="range"]::-webkit-slider-thumb { + width: 1.35rem; + height: 1.6rem; + margin-top: -0.55rem; } -} \ No newline at end of file + + .vote-hud-slider input[type="range"]::-moz-range-thumb { + width: 1.35rem; + height: 1.6rem; + } + + .vote-edge-history-row { + margin-bottom: 0.55rem; + } +} diff --git a/server/static/sorter_ui.js b/server/static/sorter_ui.js index 1a22b63ee4eb94ecf4f9c3b084b3ac5af32010be..78185ff72b272d8d422f3421e90a7b99004b8691 100644 --- a/server/static/sorter_ui.js +++ b/server/static/sorter_ui.js @@ -125,6 +125,7 @@ var leftInput = document.getElementById('vote-ratio-left'); var rightInput = document.getElementById('vote-ratio-right'); var ratioDisplay = document.getElementById('vote-ratio-display'); + var comparePair = document.querySelector('.vote-compare-pair'); function gcd(a, b) { a = Math.abs(a); b = Math.abs(b); @@ -153,6 +154,9 @@ if (rightInput) rightInput.value = String(right); var winner = left > right ? 'left' : (right > left ? 'right' : 'even'); slider.dataset.winner = winner; + // On mobile the pair uses data-winner to show only the selected side + // (or both at 50:50 when tied). Keep the attribute in sync for CSS. + if (comparePair) comparePair.dataset.winner = winner; if (ratioDisplay) { var label = winner === 'even' ? 'tie' : (winner + ' wins'); ratioDisplay.textContent = left + ':' + right + ' \u00b7 ' + label;