Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dark mode #64

Merged
merged 12 commits into from
Feb 10, 2021
Merged

Add dark mode #64

merged 12 commits into from
Feb 10, 2021

Conversation

CLDXiang
Copy link
Contributor

@CLDXiang CLDXiang commented Feb 9, 2021

fix #46

新增

  • 右上角新增一个 moon 按钮作为深色模式的 Swticher(快捷键 Ctrl+D,覆盖了 Chrome 添加书签的快捷键)
  • 依照 TailwindCSS 官方文档中 darkMode 引入的实现方式做了这些事:
    • public/index.html<head> 中增加了一段脚本,从 localStorage 或系统默认深色模式配置初始化页面深色模式状态
    • darkMode Switcher 的 dispatch 逻辑中,在用户主动触发切换时写入 localStorage 并切换当前 document 的 dark 类名
    • 在 store 中引入了 useDarkMode Hook,在 store 中进行管理,第一次进入应用会继承系统深色模式设定。
    • 用户触发切换深色模式时,会随 store.state 写入 localStorage 并切换当前 document 的 dark 类名
  • 现在可以通过按照 TailwindCSS 做法在元素类名前加 dark: 配置深色模式样式
  • 使用 TailwindCSS 基础色板修改了绝大多数元素配色,以下两部分有意暂时未做修改(如果其他部分未适配深色模式说明是我遗漏了):
    • “Buy me a coffee” Modal,因为有浅色底二维码图片,如果需要的话需要另外弄一张深色底二维码图片再进行适配
    • 涉及到 logo 和主要按钮使用的紫罗兰色,在深色模式下看起来也不错,所以没有修改颜色

额外工作

  • 添加了 git eol 配置以兼容 windows 开发环境
  • .vscode/settings.json 添加了 "css.validate": false,因为本项目引入了 TailwindCSS,在 TailwindCSS 官方插件文档 中建议去掉原生的 CSS 检查以支持如 @apply 等语法

待讨论

  • 是否需要快捷键?
  • 页面深色模式元素配色如何选取?需要专门设计一下色板吗?

@vercel
Copy link

vercel bot commented Feb 9, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/kaiyiwing/qwerty-learner/3b4huocrr
✅ Preview: https://qwerty-learner-git-fork-cldxiang-feat-dark-mode.kaiyiwing.vercel.app

@chengluyu chengluyu added Area: User Interface Animation, elements, inputs, layout, etc. Priority: Medium Considered to be average priority. labels Feb 9, 2021
@chengluyu
Copy link
Collaborator

chengluyu commented Feb 9, 2021

感谢您的贡献,我们会在合并完现在两个高优先级 PR 后再来仔细处理这个 PR。

我建议安排一个快捷键,因为其他按钮也都有快捷键。

关于色板的选取,可以参考《8 Tips for Dark Theme Design》这篇文章里的规则。

@CLDXiang
Copy link
Contributor Author

CLDXiang commented Feb 9, 2021

配色没有完全按照 《8 Tips for Dark Theme Design》 中的建议做,原因是 TailwindCSS 自带色板在不做扩展的情况下有些难以满足其中诸如对比度等要求,作为深色模式初稿我还是暂时先使用 TailwindCSS 提供的配色方案以保证配色的协调性。

@CLDXiang CLDXiang marked this pull request as ready for review February 9, 2021 14:30
@chengluyu chengluyu added Priority: High Considered to be high priority. and removed Priority: Medium Considered to be average priority. labels Feb 9, 2021
Copy link
Contributor

@sdu-gyf sdu-gyf left a comment

Choose a reason for hiding this comment

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

would you like to remove the empty file src/components/Modals/index.module.css ?

Copy link
Owner

@RealKai42 RealKai42 left a comment

Choose a reason for hiding this comment

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

未适配 Donate 界面
Donate 界面通过点击 Footer 的咖啡图标弹出

@CLDXiang
Copy link
Contributor Author

CLDXiang commented Feb 9, 2021

would you like to remove the empty file src/components/Modals/index.module.css ?

fixed

@CLDXiang
Copy link
Contributor Author

CLDXiang commented Feb 9, 2021

未适配 Donate 界面
Donate 界面通过点击 Footer 的咖啡图标弹出

@Kaiyiwing 在 PR comment 中有说明,或许需要提供深色背景二维码图片再进行适配

@RealKai42
Copy link
Owner

未适配 Donate 界面
Donate 界面通过点击 Footer 的咖啡图标弹出

@Kaiyiwing 在 PR comment 中有说明,或许需要提供深色背景二维码图片再进行适配

我简单查了一下,深色的二维码识别有问题,所以我觉得可以暂时将 Donate 其他部分适配深色,暂不处理二维码?

@CLDXiang
Copy link
Contributor Author

CLDXiang commented Feb 9, 2021

未适配 Donate 界面
Donate 界面通过点击 Footer 的咖啡图标弹出

@Kaiyiwing 在 PR comment 中有说明,或许需要提供深色背景二维码图片再进行适配

我简单查了一下,深色的二维码识别有问题,所以我觉得可以暂时将 Donate 其他部分适配深色,暂不处理二维码?

ok,我稍后弄一下

@CLDXiang CLDXiang requested a review from sdu-gyf February 9, 2021 16:11
@sdu-gyf
Copy link
Contributor

sdu-gyf commented Feb 9, 2021

目前您的 pr 基于的分支应该落后于 dev 分支了,麻烦您重新 pull 一下,感谢!

@sdu-gyf
Copy link
Contributor

sdu-gyf commented Feb 9, 2021

目前您的 pr 基于的分支应该落后于 dev 分支了,麻烦您重新 pull 一下,感谢!

我们刚在 dev 分支进行了一次更新,所以会出现 Conflicting file

@RealKai42
Copy link
Owner

目前您的 pr 基于的分支应该落后于 dev 分支了,麻烦您重新 pull 一下,感谢!

我们刚在 dev 分支进行了一次更新,所以会出现 Conflicting file

这次更新有点大,我建议让 @chengluyu 一起进行 merge吧

src/pages/Typing/hooks/useSwitcherState.ts Show resolved Hide resolved
src/pages/Typing/hooks/useSwitcherState.ts Outdated Show resolved Hide resolved
@sdu-gyf
Copy link
Contributor

sdu-gyf commented Feb 9, 2021

目前您的 pr 基于的分支应该落后于 dev 分支了,麻烦您重新 pull 一下,感谢!

我们刚在 dev 分支进行了一次更新,所以会出现 Conflicting file

这次更新有点大,我建议让 @chengluyu 一起进行 merge吧

好的。

@RealKai42
Copy link
Owner

@CLDXiang 刚刚给您 Github 预留的邮箱发了邀请,如果有兴趣欢迎加入我们

@CLDXiang
Copy link
Contributor Author

CLDXiang commented Feb 9, 2021

@CLDXiang 刚刚给您 Github 预留的邮箱发了邀请,如果有兴趣欢迎加入我们

嗯嗯,这个项目挺好玩的,但我似乎没有收到邮件

@CLDXiang CLDXiang changed the base branch from master to dev February 9, 2021 17:24
@CLDXiang CLDXiang marked this pull request as draft February 9, 2021 17:25
@RealKai42
Copy link
Owner

RealKai42 commented Feb 9, 2021

这个 pr 由我在负责 merge 到 dev 了
所以麻烦改成 非 draft 吧,对 dark mode 的后续改进可以作为新的 pr

@CLDXiang
Copy link
Contributor Author

CLDXiang commented Feb 9, 2021

这个 pr 由我在负责 merge 到 dev 了
所以我将它改成 非 draft pr 了

ok,那我就先不动这个 branch 了?dev 新更新的部分也需要加上深色样式

@CLDXiang CLDXiang marked this pull request as ready for review February 9, 2021 17:32
@RealKai42
Copy link
Owner

RealKai42 commented Feb 9, 2021

@CLDXiang 刚刚给您 Github 预留的邮箱发了邀请,如果有兴趣欢迎加入我们

嗯嗯,这个项目挺好玩的,但我似乎没有收到邮件

我刚刚重新发送了一下到 cldxiang@qq.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: User Interface Animation, elements, inputs, layout, etc. Priority: High Considered to be high priority.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: 希望加入深色模式, 照顾暗黑风VS Code用户的视觉体验
4 participants