Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions src/components/Footer.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
import type { Locale } from "../i18n";
import { footerMessages, messages } from "../i18n";
import { footerMessages } from "../i18n";
import EidosMark from "./EidosMark.astro";
import LanguageMenu from "./LanguageMenu.astro";

interface Props {
locale: Locale;
Expand All @@ -11,7 +12,6 @@ interface Props {

const { locale, englishPath, chinesePath } = Astro.props;
const t = footerMessages[locale];
const languageLabel = messages[locale].language;
const mainUrl = (path: string) => `https://eidos.space${locale === "zh" ? "/zh" : ""}${path}`;
const docsUrl = (path: string) => `https://docs.eidos.space${locale === "zh" ? "/zh-cn" : ""}${path}`;

Expand Down Expand Up @@ -93,20 +93,7 @@ const groups = [
<span aria-hidden="true"> · </span>
{t.fileOwnership}
</p>
<details class="site-footer-language">
<summary aria-label={languageLabel} title={languageLabel}>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true">
<circle cx="12" cy="12" r="9" />
<path d="M3 12h18M12 3c2.7 2.5 4 5.5 4 9s-1.3 6.5-4 9M12 3c-2.7 2.5-4 5.5-4 9s1.3 6.5-4 9" />
</svg>
<span>{locale === "zh" ? "中文" : "EN"}</span>
<span aria-hidden="true">⌄</span>
</summary>
<div class="site-footer-language-options">
<a href={englishPath} lang="en" aria-current={locale === "en" ? "page" : undefined}>English</a>
<a href={chinesePath} lang="zh-CN" aria-current={locale === "zh" ? "page" : undefined}>简体中文</a>
</div>
</details>
<LanguageMenu locale={locale} englishPath={englishPath} chinesePath={chinesePath} placement="above" />
</div>
</div>
</footer>
45 changes: 45 additions & 0 deletions src/components/LanguageMenu.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
import type { Locale } from "../i18n";
import { messages } from "../i18n";

interface Props {
locale: Locale;
englishPath: string;
chinesePath: string;
placement?: "above" | "below";
}
const { locale, englishPath, chinesePath, placement = "below" } = Astro.props;
const label = messages[locale].language;
---

<details class="language-menu" data-placement={placement}>
<summary aria-label={label} title={label}>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true">
<circle cx="12" cy="12" r="9" />
<path d="M3 12h18M12 3c2.7 2.5 4 5.5 4 9s-1.3 6.5-4 9M12 3c-2.7 2.5-4 5.5-4 9s1.3 6.5-4 9" />
</svg>
<span>{locale === "zh" ? "中文" : "EN"}</span>
<span class="language-chevron" aria-hidden="true">⌄</span>
</summary>
<div class="language-options">
<a href={englishPath} lang="en" aria-current={locale === "en" ? "page" : undefined}>English</a>
<a href={chinesePath} lang="zh-CN" aria-current={locale === "zh" ? "page" : undefined}>简体中文</a>
</div>
</details>

<style>
.language-menu { position: relative; flex-shrink: 0; font-family: var(--body); }
.language-menu[data-placement="above"] { justify-self: end; }
summary { display: flex; min-width: 42px; min-height: 42px; align-items: center; justify-content: center; gap: 6px; padding: 0 8px; border-radius: 8px; color: var(--ink-muted); font-size: 0.78rem; font-weight: 400; line-height: 1.5; letter-spacing: normal; text-transform: none; cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary:hover, details[open] summary { background: var(--soft); color: var(--ink); }
summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
summary svg { width: 18px; height: 18px; }
.language-chevron { margin-top: -5px; font-size: 0.95rem; }
.language-options { position: absolute; top: calc(100% + 8px); right: 0; z-index: 30; display: grid; min-width: 155px; padding: 6px; border-radius: 10px; background: var(--surface); box-shadow: 0 12px 32px oklch(0.16 0.012 230 / 12%); }
[data-placement="above"] .language-options { top: auto; bottom: calc(100% + 8px); }
.language-options a { display: flex; min-height: 36px; align-items: center; padding: 7px 11px; border-radius: 7px; color: var(--ink); font-size: 0.78rem; font-weight: 400; line-height: 1.5; letter-spacing: normal; text-transform: none; white-space: nowrap; }
.language-options a:hover { background: var(--soft); }
.language-options a[aria-current="page"] { color: var(--accent); font-weight: 600; }
@media (max-width: 700px) { .language-menu[data-placement="above"] { justify-self: start; } }
</style>
15 changes: 2 additions & 13 deletions src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Locale } from "../i18n";
import { messages } from "../i18n";
import EidosMark from "../components/EidosMark.astro";
import Footer from "../components/Footer.astro";
import LanguageMenu from "../components/LanguageMenu.astro";
import "../styles/global.css";

interface Props {
Expand Down Expand Up @@ -75,19 +76,7 @@ const themesUrl = isZh ? "/zh/themes" : "/themes";
<nav class="site-header-actions" aria-label="Primary">
<a href={docsPath}>{t.docs}</a>
<a href="https://github.com/eidos-space/registry/blob/main/CONTRIBUTING.md">{t.submit}</a>
<details class="language-menu">
<summary aria-label={t.language} title={t.language}>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true">
<circle cx="12" cy="12" r="9" />
<path d="M3 12h18M12 3c2.7 2.5 4 5.5 4 9s-1.3 6.5-4 9M12 3c-2.7 2.5-4 5.5-4 9s1.3 6.5-4 9" />
</svg>
<span aria-hidden="true">⌄</span>
</summary>
<div class="language-options">
<a href={englishPath} lang="en" aria-current={locale === "en" ? "page" : undefined}>English</a>
<a href={chinesePath} lang="zh-CN" aria-current={locale === "zh" ? "page" : undefined}>简体中文</a>
</div>
</details>
<LanguageMenu locale={locale} englishPath={englishPath} chinesePath={chinesePath} />
</nav>
</div>
</header>
Expand Down
30 changes: 4 additions & 26 deletions src/styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -130,28 +130,17 @@ summary:focus-visible {
gap: clamp(16px, 3vw, 34px);
}

.site-header-actions a {
.site-header-actions > a {
padding-block: 11px;
color: var(--ink-muted);
font-size: 0.76rem;
transition: color 160ms ease;
}

.site-header-actions a:hover { color: var(--accent); }
.site-header-actions a:nth-child(2) { color: var(--accent-hover); font-weight: 650; }
.site-header-actions a:nth-child(2):hover { color: var(--ink); }
.site-header-actions > a:hover { color: var(--accent); }
.site-header-actions > a:nth-child(2) { color: var(--accent-hover); font-weight: 650; }
.site-header-actions > a:nth-child(2):hover { color: var(--ink); }

.language-menu { position: relative; }
.language-menu summary { display: flex; min-width: 42px; min-height: 42px; align-items: center; justify-content: center; gap: 3px; border-radius: 8px; color: var(--ink-muted); cursor: pointer; list-style: none; }
.language-menu summary::-webkit-details-marker { display: none; }
.language-menu summary:hover,
.language-menu[open] summary { background: var(--soft); color: var(--ink); }
.language-menu summary svg { width: 18px; height: 18px; }
.language-menu summary span { margin-top: -5px; font-size: 0.95rem; }
.language-options { position: absolute; top: calc(100% + 8px); right: 0; display: grid; min-width: 155px; padding: 6px; border-radius: 10px; background: var(--surface); box-shadow: 0 12px 32px oklch(0.16 0.012 230 / 12%); }
.site-header .language-options a { display: flex; min-height: 36px; align-items: center; padding: 7px 11px; border-radius: 7px; color: var(--ink); font-size: 0.78rem; white-space: nowrap; }
.site-header .language-options a:hover { background: var(--soft); }
.site-header .language-options a[aria-current="page"] { color: var(--accent); font-weight: 600; }

.market-hero {
overflow: hidden;
Expand Down Expand Up @@ -481,16 +470,6 @@ summary:focus-visible {
.site-footer-motto a { text-decoration: underline; text-decoration-color: rgb(0 0 0 / 25%); text-underline-offset: 4px; }
.site-footer-motto a:hover { color: #1d1d1f; text-decoration-color: rgb(0 0 0 / 60%); }
.site-footer-motto a span { margin-left: 4px; }
.site-footer-language { position: relative; justify-self: end; }
.site-footer-language summary { display: inline-flex; min-height: 32px; align-items: center; gap: 6px; color: rgb(0 0 0 / 60%); cursor: pointer; list-style: none; }
.site-footer-language summary::-webkit-details-marker { display: none; }
.site-footer-language summary svg { width: 14px; height: 14px; }
.site-footer-language[open] summary,
.site-footer-language summary:hover { color: #1d1d1f; }
.site-footer-language-options { position: absolute; right: 0; bottom: calc(100% + 4px); z-index: 30; display: grid; min-width: 130px; background: #fff; box-shadow: 0 10px 30px rgb(0 0 0 / 12%); }
.site-footer-language-options a { display: flex; min-height: 40px; align-items: center; padding-inline: 12px; color: rgb(0 0 0 / 60%); font-size: 0.625rem; letter-spacing: 0.1em; text-transform: none; }
.site-footer-language-options a:hover { background: var(--soft); color: var(--ink); }
.site-footer-language-options a[aria-current="page"] { color: #1d1d1f; font-weight: 700; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; margin: -1px; padding: 0; border: 0; clip: rect(0, 0, 0, 0); white-space: nowrap; }

Expand All @@ -512,7 +491,6 @@ summary:focus-visible {
.site-footer-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 40px 24px; }
.site-footer-bottom { grid-template-columns: minmax(0, 1fr); gap: 12px; }
.site-footer-motto { text-align: left; }
.site-footer-language { justify-self: start; }
}

@media (max-width: 620px) {
Expand Down
Loading