Repository navigation
主题按钮改单击循环切换(去掉下拉菜单) - #15
Merged
Merged
Conversation
Switch the theme toggle button from a dropdown menu to a single-click cycle (system -> light -> dark -> system), updating aria-label and title with current and next mode info. Checkpoint: DDMWQ_iXf4K3Mow0Rkxql
🚀 Deploying Preview to Cloudflare 🚀Preview URL: https://tds-conv-01a1bbd7-8cfe-7427-8eb1-4d26e08588fa-workerhub.pama.workers.dev (commit 36788b1)This URL reflects your latest Preview deploymentPreview Deployments by commit
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
theme-toggle.tsx对DropdownMenu的引用与 DOM 节点。Changes
src/components/site/theme-toggle.tsx:DropdownMenu系列组件的引入与结构,改用原生<Button type="button">的onClick驱动状态流转。NEXT_THEME_MODE、THEME_LABELS与THEME_ICONS映射常量与getNextMode、getThemeAriaLabel纯函数。aria-label与title为「主题:当前档,点击切换到下一档」(例如「主题:亮色,点击切换到暗色」),Enter / Space 原生键盘事件即可触发切换。THEME_STORAGE_KEY(hub-theme)、applyTheme样式与 dataset 规则、自动档媒体查询监听以及 localStorage 异常静默降级逻辑。tests/theme-toggle.test.ts:readStoredMode边界防御以及applyTheme在三种模式下的 DOM 更新。Testing
pnpm test: 135 项测试全数通过(134 项通过,1 项外部网络核验按预期跳过)。pnpm lint:astro check0 errors / 0 warnings / 0 hints,Prettier 格式检查通过。pnpm astro build: 24 个静态页面构建成功,检查生成的静态 HTML 确认主题按钮呈现为原生<button>并附带准确的当前/下一档aria-label,无菜单 DOM 残留。theme-toggle.tsx中已无任何DropdownMenu残留。