mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-11-18 11:42:07 +00:00
Move colour mode and Discord controls into the mobile menu
This commit is contained in:
@@ -14,6 +14,9 @@
|
|||||||
.nav-links a { transition: opacity .2s; }
|
.nav-links a { transition: opacity .2s; }
|
||||||
.nav-links a:hover { opacity: .55; }
|
.nav-links a:hover { opacity: .55; }
|
||||||
.nav-links a.nav-cta:hover { opacity: 1; }
|
.nav-links a.nav-cta:hover { opacity: 1; }
|
||||||
|
/* Utilities (colour mode, Discord) sit in the bar on desktop and in the
|
||||||
|
collapsible menu on small screens. */
|
||||||
|
.nav-menu-tools { display: none; }
|
||||||
.nav-user-menu { position: relative; }
|
.nav-user-menu { position: relative; }
|
||||||
.nav-user-menu summary { display: flex; align-items: center; gap: 6px; list-style: none; cursor: pointer; color: var(--color-muted); font-weight: 500; }
|
.nav-user-menu summary { display: flex; align-items: center; gap: 6px; list-style: none; cursor: pointer; color: var(--color-muted); font-weight: 500; }
|
||||||
.nav-user-menu summary::-webkit-details-marker { display: none; }
|
.nav-user-menu summary::-webkit-details-marker { display: none; }
|
||||||
@@ -42,6 +45,11 @@ html[data-theme="dark"] .nav-user-menu-panel { box-shadow: 0 18px 40px rgba(0, 0
|
|||||||
.nav-links.open { display: flex; }
|
.nav-links.open { display: flex; }
|
||||||
.nav-cta { width: 100%; }
|
.nav-cta { width: 100%; }
|
||||||
.nav-links { display: none; position: absolute; top: 65px; left: 0; right: 0; padding: 24px; flex-direction: column; align-items: stretch; gap: 22px; border-radius: 10px; background: var(--color-canvas-raised); box-shadow: 0 18px 40px rgba(23,53,45,.15); }
|
.nav-links { display: none; position: absolute; top: 65px; left: 0; right: 0; padding: 24px; flex-direction: column; align-items: stretch; gap: 22px; border-radius: 10px; background: var(--color-canvas-raised); box-shadow: 0 18px 40px rgba(23,53,45,.15); }
|
||||||
|
.nav-menu-tools { display: flex; align-items: center; justify-content: space-between; gap: 18px; width: 100%; }
|
||||||
|
/* The menu owns these on small screens; keep them in the bar only when no
|
||||||
|
menu is rendered (prelaunch with no links). */
|
||||||
|
.nav-wrap:has(#nav-links) .nav-right > [role="radiogroup"],
|
||||||
|
.nav-wrap:has(#nav-links) .nav-right > .discord-link { display: none; }
|
||||||
.nav-user-menu-panel { position: static; min-width: 0; padding: 12px 0 0; background: transparent; box-shadow: none; }
|
.nav-user-menu-panel { position: static; min-width: 0; padding: 12px 0 0; background: transparent; box-shadow: none; }
|
||||||
html[data-theme="dark"] .nav-links { box-shadow: 0 18px 40px rgba(0, 0, 0, .45); }
|
html[data-theme="dark"] .nav-links { box-shadow: 0 18px 40px rgba(0, 0, 0, .45); }
|
||||||
}
|
}
|
||||||
@@ -126,6 +126,11 @@ defmodule ChesstrainerWeb.Layouts do
|
|||||||
Start training <.icon_arrow />
|
Start training <.icon_arrow />
|
||||||
</.pill_button>
|
</.pill_button>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<div class="nav-menu-tools">
|
||||||
|
<.colour_mode_toggle />
|
||||||
|
<.discord_link />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,10 @@
|
|||||||
if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
|
if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const buttons = Array.from(document.querySelectorAll("[data-phx-theme]"));
|
// Each breakpoint renders its own copy of the switch, so only the visible
|
||||||
|
// group takes part in arrow-key navigation.
|
||||||
|
const buttons = Array.from(document.querySelectorAll("[data-phx-theme]"))
|
||||||
|
.filter((button) => button.offsetParent !== null);
|
||||||
const offset = event.key === "ArrowRight" ? 1 : -1;
|
const offset = event.key === "ArrowRight" ? 1 : -1;
|
||||||
const index = (buttons.indexOf(button) + offset + buttons.length) % buttons.length;
|
const index = (buttons.indexOf(button) + offset + buttons.length) % buttons.length;
|
||||||
const next = buttons[index];
|
const next = buttons[index];
|
||||||
|
|||||||
@@ -29,6 +29,15 @@ defmodule ChesstrainerWeb.LayoutsTest do
|
|||||||
assert html =~ ~p"/users/register"
|
assert html =~ ~p"/users/register"
|
||||||
refute html =~ ~s(class="nav-user-menu")
|
refute html =~ ~s(class="nav-user-menu")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "renders the utility controls in both the bar and the mobile menu" do
|
||||||
|
html = render_component(&Layouts.navbar/1, %{current_scope: nil})
|
||||||
|
|
||||||
|
assert html =~ ~s(class="nav-menu-tools")
|
||||||
|
# One copy for the bar, one for the collapsible menu; CSS shows one.
|
||||||
|
assert length(String.split(html, ~s(role="radiogroup"))) == 3
|
||||||
|
assert length(String.split(html, ~s(class="discord-link"))) == 3
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "discord_link/1" do
|
describe "discord_link/1" do
|
||||||
|
|||||||
Reference in New Issue
Block a user