Repository navigation
删掉没有调用者的脚手架,深浅色实时跟随系统 - #5
Merged
Merged
Conversation
Button 的 asChild、四个 variant 与六个 size 全仓库零调用者,实际只用到 ghost/default × icon/default 两档;留两档后 cva 也不需要,64 行降到 36 行。radix-ui 只为 asChild 而装, class-variance-authority 与 tw-animate-css 同样无人使用——animate-pulse 是 Tailwind 核心类。 三个依赖移除后锁文件少 82 个包,入口 JS 291.43 → 286.24 kB,CSS 37.29 → 31.83 kB。 format.ts 的 MODES 没有调用者,主题不显示流量口径;clock、navigate、ApiError 三个 export 只在本文件内被用到,收回导出。 深浅色此前在首次访问就把系统偏好写进 localStorage,此后系统再切换不再跟随,等于把「跟随 系统」变成一次性快照。改为只有点击切换时才落盘,未落盘时实时跟随 prefers-color-scheme。
此前把 DARK_MEDIA.matches 拷进 state,监听器要等 effect 才挂上:落在首次渲染与挂载 之间的那次切换没有人听见,而按日夜计划切换的下一次在几小时之后。改用 useSyncExternalStore 直接订阅,窗口消失,代码也短一截。 同时把「只有点击才落盘」这条约束写进注释:面板在同源的 /admin/ 下共用 theme 这个 key, 任何一个 app 在加载时写盘都会把其余的钉死。
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.
删掉三个没有调用者的依赖与随之而来的死代码,并修掉深浅色只在首次访问跟随系统的问题。
buttonVariants与asChild全仓库零调用者。留两档后 cva 也不需要,64 行降到 36 行。radix-ui(只为asChild而装)、class-variance-authority、tw-animate-css(零处使用,animate-pulse是 Tailwind 核心类)。锁文件少 82 个包,入口 JS 291.43 → 286.24 kB,CSS 37.29 → 31.83 kB。format.ts里没有调用者的MODES;clock、navigate、ApiError三个 export 只在本文件内被用到,收回导出。localStorage,之后系统再切换不再跟随。改为只在点击切换时落盘,未落盘时实时跟随prefers-color-scheme。tsc -b、oxlint、npm test、npm run build通过;浏览器实测:未点过切换时随系统实时变化,点过之后固定。