From 07c89f39a20bbb3c0899e6ab9718be150ffc5431 Mon Sep 17 00:00:00 2001 From: Carbon Date: Sat, 5 Dec 2026 19:14:27 +0800 Subject: [PATCH] fix(site): simplify the header and add a language menu --- site/app.js | 17 ++++++++++++++++ site/guide/index.html | 16 ++++++++++++++- site/index.html | 15 +++++++++++--- site/nav-icons.svg | 9 +++++++++ site/style.css | 43 +++++++++++++++++++++++++++------------- site/zh/guide/index.html | 16 ++++++++++++++- site/zh/index.html | 15 +++++++++++--- 7 files changed, 109 insertions(+), 22 deletions(-) create mode 100644 site/nav-icons.svg diff --git a/site/app.js b/site/app.js index 5388ca8..654f263 100644 --- a/site/app.js +++ b/site/app.js @@ -45,6 +45,23 @@ for (const install of document.querySelectorAll('.install')) { }); } +// Native details handles activation, including when JavaScript is disabled. +const picker = document.querySelector('.language-picker'); +if (picker) { + document.addEventListener('click', event => { + if (!picker.contains(event.target)) picker.open = false; + }); + picker.addEventListener('focusout', event => { + if (event.relatedTarget && !picker.contains(event.relatedTarget)) picker.open = false; + }); + document.addEventListener('keydown', event => { + if (event.key === 'Escape' && picker.open) { + picker.open = false; + picker.querySelector('summary').focus(); + } + }); +} + // The header gains a surface once the page scrolls. const header = document.querySelector('.site-header'); if (header) { diff --git a/site/guide/index.html b/site/guide/index.html index df8e6a9..5efad92 100644 --- a/site/guide/index.html +++ b/site/guide/index.html @@ -17,7 +17,21 @@ - +