diff options
| -rw-r--r-- | app/views/layouts/_nav_switchers.html.erb | 23 | ||||
| -rw-r--r-- | app/views/layouts/admin.html.erb | 1 | ||||
| -rw-r--r-- | config/locales/de.yml | 1 | ||||
| -rw-r--r-- | config/locales/en.yml | 1 | ||||
| -rw-r--r-- | public/stylesheets/admin.css | 36 |
5 files changed, 60 insertions, 2 deletions
diff --git a/app/views/layouts/_nav_switchers.html.erb b/app/views/layouts/_nav_switchers.html.erb new file mode 100644 index 00000000..9c3b222e --- /dev/null +++ b/app/views/layouts/_nav_switchers.html.erb | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | <%= link_to url_for(locale: (:en unless I18n.locale == :en)), | ||
| 2 | class: "nav_toggle", | ||
| 3 | "aria-label" => t(".switch_locale"), title: t(".switch_locale") do %> | ||
| 4 | <%= I18n.locale == :en ? "DE" : "EN" %> | ||
| 5 | <% end %> | ||
| 6 | <%= check_box_tag "scheme_override", 1, false, class: "nav_toggle_input" %> | ||
| 7 | <%= label_tag "scheme_override", class: "nav_toggle", | ||
| 8 | "aria-label" => t(".scheme_override"), title: t(".scheme_override") do %> | ||
| 9 | <%= icon("contrast", library: "tabler", "aria-hidden": true) %> | ||
| 10 | <% end %> | ||
| 11 | |||
| 12 | <%= javascript_tag nonce: true do %> | ||
| 13 | (function () { | ||
| 14 | var box = document.getElementById("scheme_override"); | ||
| 15 | try { | ||
| 16 | if (localStorage.getItem("override-prefers-color-scheme")) box.checked = true; | ||
| 17 | box.addEventListener("change", function () { | ||
| 18 | if (box.checked) localStorage.setItem("override-prefers-color-scheme", 1); | ||
| 19 | else localStorage.removeItem("override-prefers-color-scheme"); | ||
| 20 | }); | ||
| 21 | } catch (e) { /* storage unavailable: the toggle still works per page */ } | ||
| 22 | })(); | ||
| 23 | <% end %> | ||
diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index f6ceaaff..6ac9b756 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | <div id="navigation"> | 27 | <div id="navigation"> |
| 28 | <div id="main_navigation"> | 28 | <div id="main_navigation"> |
| 29 | <%= render :partial => 'admin/menu' if current_user %> | 29 | <%= render :partial => 'admin/menu' if current_user %> |
| 30 | <%= render :partial => 'layouts/nav_switchers' %> | ||
| 30 | </div> | 31 | </div> |
| 31 | <div id="search_widget" style="display: none;"> | 32 | <div id="search_widget" style="display: none;"> |
| 32 | <div> | 33 | <div> |
diff --git a/config/locales/de.yml b/config/locales/de.yml index 51fafe21..d1551fcf 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml | |||
| @@ -281,6 +281,7 @@ de: | |||
| 281 | menu: | 281 | menu: |
| 282 | dashboard: "Dashboard" | 282 | dashboard: "Dashboard" |
| 283 | search: "Suche" | 283 | search: "Suche" |
| 284 | scheme_override: "Hell/Dunkel umschalten" | ||
| 284 | log_out: "Abmelden" | 285 | log_out: "Abmelden" |
| 285 | index: | 286 | index: |
| 286 | title: "cccms Dashboard" | 287 | title: "cccms Dashboard" |
diff --git a/config/locales/en.yml b/config/locales/en.yml index b3678187..ac370852 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml | |||
| @@ -234,6 +234,7 @@ en: | |||
| 234 | menu: | 234 | menu: |
| 235 | dashboard: "Dashboard" | 235 | dashboard: "Dashboard" |
| 236 | search: "Search" | 236 | search: "Search" |
| 237 | scheme_override: "Toggle light/dark" | ||
| 237 | log_out: "Log out" | 238 | log_out: "Log out" |
| 238 | index: | 239 | index: |
| 239 | title: "cccms dashboard" | 240 | title: "cccms dashboard" |
diff --git a/public/stylesheets/admin.css b/public/stylesheets/admin.css index c6f82827..f697c4e2 100644 --- a/public/stylesheets/admin.css +++ b/public/stylesheets/admin.css | |||
| @@ -57,6 +57,14 @@ | |||
| 57 | --radius: 6px; | 57 | --radius: 6px; |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | @media (prefers-color-scheme: light) { | ||
| 61 | :root:has(#scheme_override:checked) { color-scheme: dark; } | ||
| 62 | } | ||
| 63 | |||
| 64 | @media (prefers-color-scheme: dark) { | ||
| 65 | :root:has(#scheme_override:checked) { color-scheme: light; } | ||
| 66 | } | ||
| 67 | |||
| 60 | /* ============================================================ | 68 | /* ============================================================ |
| 61 | Base elements | 69 | Base elements |
| 62 | ============================================================ */ | 70 | ============================================================ */ |
| @@ -369,13 +377,13 @@ form.button_to.destructive button[type="submit"]:hover { | |||
| 369 | form.button_to.computation input[type="submit"], | 377 | form.button_to.computation input[type="submit"], |
| 370 | form.button_to.computation button[type="submit"] { | 378 | form.button_to.computation button[type="submit"] { |
| 371 | color: var(--compute); | 379 | color: var(--compute); |
| 372 | background-color: var(--compute-solid); | 380 | background-color: var(--compute-surface); |
| 373 | } | 381 | } |
| 374 | 382 | ||
| 375 | form.button_to.computation input[type="submit"]:hover, | 383 | form.button_to.computation input[type="submit"]:hover, |
| 376 | form.button_to.computation button[type="submit"]:hover { | 384 | form.button_to.computation button[type="submit"]:hover { |
| 377 | color: var(--on-solid); | 385 | color: var(--on-solid); |
| 378 | background-color: var(--compute); | 386 | background-color: var(--compute-solid); |
| 379 | } | 387 | } |
| 380 | 388 | ||
| 381 | form.button_to.computation input[type="submit"]:disabled, | 389 | form.button_to.computation input[type="submit"]:disabled, |
| @@ -420,6 +428,7 @@ input[type="submit"]:hover { | |||
| 420 | } | 428 | } |
| 421 | 429 | ||
| 422 | #main_navigation a, | 430 | #main_navigation a, |
| 431 | #main_navigation label.nav_toggle, | ||
| 423 | #main_navigation form.button_to button { | 432 | #main_navigation form.button_to button { |
| 424 | display: inline-flex; | 433 | display: inline-flex; |
| 425 | text-decoration: none; | 434 | text-decoration: none; |
| @@ -433,11 +442,16 @@ input[type="submit"]:hover { | |||
| 433 | } | 442 | } |
| 434 | 443 | ||
| 435 | #main_navigation a:hover, | 444 | #main_navigation a:hover, |
| 445 | #main_navigation label.nav_toggle:hover, | ||
| 436 | #main_navigation form.button_to button:hover { | 446 | #main_navigation form.button_to button:hover { |
| 437 | color: var(--surface); | 447 | color: var(--surface); |
| 438 | background-color: var(--text); | 448 | background-color: var(--text); |
| 439 | } | 449 | } |
| 440 | 450 | ||
| 451 | #main_navigation label.nav_toggle { | ||
| 452 | cursor: pointer; | ||
| 453 | } | ||
| 454 | |||
| 441 | #main_navigation svg, | 455 | #main_navigation svg, |
| 442 | .action_button svg, | 456 | .action_button svg, |
| 443 | form.button_to svg { | 457 | form.button_to svg { |
| @@ -445,6 +459,24 @@ form.button_to svg { | |||
| 445 | height: 1.25rem; | 459 | height: 1.25rem; |
| 446 | } | 460 | } |
| 447 | 461 | ||
| 462 | #main_navigation input.nav_toggle_input { | ||
| 463 | position: absolute; | ||
| 464 | width: 1px; | ||
| 465 | height: 1px; | ||
| 466 | overflow: hidden; | ||
| 467 | clip-path: inset(50%); | ||
| 468 | } | ||
| 469 | |||
| 470 | #main_navigation input.nav_toggle_input:focus-visible + label.nav_toggle { | ||
| 471 | outline: 2px solid var(--accent); | ||
| 472 | outline-offset: 2px; | ||
| 473 | } | ||
| 474 | |||
| 475 | #main_navigation input.nav_toggle_input:checked + label.nav_toggle { | ||
| 476 | color: var(--accent); | ||
| 477 | background-color: var(--accent-surface); | ||
| 478 | } | ||
| 479 | |||
| 448 | #dashboard_search { | 480 | #dashboard_search { |
| 449 | margin-bottom: 1.5rem; | 481 | margin-bottom: 1.5rem; |
| 450 | } | 482 | } |
