Skip to content

feat: icon-button dropdown language switcher (kimi style) - #90

Merged
sunshineg merged 1 commit into
mainfrom
feat/lang-switcher-dropdown
Aug 22, 2026
Merged

feat: icon-button dropdown language switcher (kimi style)#90
sunshineg merged 1 commit into
mainfrom
feat/lang-switcher-dropdown

Conversation

@sunshineg

Copy link
Copy Markdown
Member

概述

把 www 与 ossheroes 导航的「EN / 简 / 繁」三文字并排链接替换为 kimi 风格的单图标按钮 + 下拉菜单,解决移动端拥挤折行问题。

改动

  • 新增 packages/ui/src/LangSwitcher.astro 共享组件:
    • 单个翻译图标按钮,点击展开暗色圆角下拉卡片
    • 菜单项为完整语言名 English / 简体中文 / 繁體中文,当前语言右侧 ✓ + aria-current
    • 沿用既有切换契约:localePath 生成对应语言 URL、hreflang + rel="alternate"、onclick 写 localStorage('osw-language')
    • 勾选状态构建期静态渲染,纯静态无客户端数据依赖
    • 无障碍:aria-haspopup / aria-expanded 同步、ul/li 结构、点击外部 / Esc 关闭、焦点样式
    • 样式 scoped,使用 --osw-* 设计 token,菜单相对按钮右对齐且不超视口
  • apps/www 首页导航与 apps/ossheroes Navbar 替换为共享组件
  • 清理 ossheroes global.css 中废弃的 .lang-btn 样式

验证

  • pnpm --filter www build ✅ / pnpm --filter ossheroes build ✅(1380 页)
  • verify:urls / verify:seo
  • 浏览器实测 dist 产物:下拉展开 / 点击外部关闭正常,勾选态与 aria-current 随 locale 正确 ✅
  • 任务内跨模型评审:第一轮 1 个 warning(导航双重 padding)已修复,第二轮 passed ✅

把 www 与 ossheroes 导航的「EN / 简 / 繁」三文字链接替换为 packages/ui 共享的 LangSwitcher 组件(kimi 风格):单个翻译图标按钮 + 暗色圆角下拉菜单,完整语言名 + 当前语言 ✓(aria-current),沿用 localePath 跳转 + localStorage('osw-language') 契约。支持 aria-expanded 同步、点击外部 / Esc 关闭,解决移动端三链接并排拥挤折行问题。

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a shared language switcher UI component to replace the existing inline “EN / 简 / 繁” links in the www and ossheroes navigations, improving layout on small screens while preserving the existing locale URL/SEO behavior.

Changes:

  • Added packages/ui/src/LangSwitcher.astro: icon-button dropdown language switcher with static “current locale” rendering and a small client-side toggle script.
  • Updated apps/www Home navigation and apps/ossheroes Navbar to use the shared LangSwitcher component.
  • Removed now-unused ossheroes global CSS styles for the old .lang-btn language links.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/ui/src/LangSwitcher.astro New shared dropdown language switcher component (markup, styles, and toggle behavior).
packages/ui/package.json Exports the new LangSwitcher.astro entry from the UI package.
apps/www/src/components/Home.astro Replaces inline language link trio with the shared LangSwitcher.
apps/ossheroes/src/components/Navbar.astro Replaces inline language link trio with the shared LangSwitcher.
apps/ossheroes/src/styles/global.css Removes obsolete language-switch button/link styling for the previous UI.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@sunshineg
sunshineg merged commit 346a010 into main Aug 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants