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
support defaultDarkMode #796
Comments
1, |
How do we do that with templateBuild? I did a google and find nothing. Link?
…On Tue, Apr 5, 2022 at 9:17 AM Mr.Hope ***@***.***> wrote:
Closed #796 <#796>.
—
Reply to this email directly, view it on GitHub
<#796 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABJYKUMLPKKHCPZ5L27DL3DVDRRR3ANCNFSM5STI4UHA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Sorry, I meant how-to-use-templateBuild-to-specify-default-darkMode. And
the doc on template build does not have information on how to use it even
for other things. How do we know how to use it?
…On Tue, Apr 5, 2022 at 9:22 AM Mr.Hope ***@***.***> wrote:
https://v2.vuepress.vuejs.org/reference/theme-api.html#templatebuild
—
Reply to this email directly, view it on GitHub
<#796 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABJYKUI4DTYGBWBVADNKHU3VDRSDRANCNFSM5STI4UHA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
We are not expecting to teach you everything. And the docs should be clear enough: |
<!DOCTYPE html>
<html lang="{{ lang }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="generator" content="VuePress {{ version }}">
<style>
:root {
--c-bg: #fff;
}
html.dark {
--c-bg: #22272e;
}
html, body {
background-color: var(--c-bg);
}
</style>
<script>
const userMode = localStorage.getItem('vuepress-color-scheme');
if(!userMode) localStorage.setItem('vuepress-color-scheme', 'xxx'); // xxx is the one you like
const systemDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
if (userMode === 'dark' || (userMode !== 'light' && systemDarkMode)) {
document.documentElement.classList.toggle('dark', true);
}
</script>
<!--vuepress-ssr-head-->
<!--vuepress-ssr-resources-->
<!--vuepress-ssr-styles-->
</head>
<body>
<div id="app"><!--vuepress-ssr-app--></div>
<!--vuepress-ssr-scripts-->
</body>
</html> Slightly edited from the orignal |
Place the above template somewhere in your project, and add |
Unless the docs is totally missing description or there are missing apis, this kind of problems should be regarded on your side. Even tools like vue and react are not providing demos for every apis. If you read through the whole docs, understanding that api should not be hard, but it does if you just see the option description, and that't not our problem. We would like to give some simple hints on how you can achieve something, but we do not have reposonability impletement that for you just because you can not understand how to achieve that. Just as a reminder, this is an open source project, which means we can ( and I will) ignore some personal cutomize help. |
Also, if the above way is hacky for you, https://v2.vuepress.vuejs.org/reference/default-theme/extending.html can be another way. |
First of all, I really appreciate your effort in helping around, and make
vuepress great option for creating content site (almost, I did find there
are things missing, like blog2). You are really kind on actions, and I
totally understand you have to maintain a clear boundary.
for your next suggestion: you mean do something like:
<script setup>
const userMode = localStorage.getItem('vuepress-color-scheme');
if(!userMode) localStorage.setItem('vuepress-color-scheme', 'xxx');
// xxx is the one you like
const systemDarkMode = window.matchMedia &&
window.matchMedia('(prefers-color-scheme: dark)').matches;
if (userMode === 'dark' || (userMode !== 'light' && systemDarkMode)) {
document.documentElement.classList.toggle('dark', true);
}
import ParentLayout from
***@***.***/theme-default/lib/client/layouts/Layout.vue'
</script>
but I do think both options requires significant increase in term of level
of understanding of how vuepress works (templateBuild is not mentioned here
https://v2.vuepress.vuejs.org/advanced/architecture.html#overview) in the
needed to control default dark mode. But then again, I think it is your
decision in terms of whether defaultdarkmode should be exposed in
accessible fashion like darkmode (should really be darkModeToggle if you
ask me) or not.
Again, thanks for your effort, really prompt, and understood covid is
hurting all of us. Hang in there.
Sean.
…On Tue, Apr 5, 2022 at 9:39 AM Mr.Hope ***@***.***> wrote:
the doc on template build does not have information on how to use it even
for other things. How do we know how to use it?
Unless the docs is totally missing description or there are missing apis,
this kind of problems should be regarded on your side.
We would like to give some simple hints on how you can achieve something,
but we do not have reposonability impletement that for you just because you
can not understand how to achieve that.
Just as a reminder, this is an open source project, which means we can (
and I will) ignore some personal cutomize help.
—
Reply to this email directly, view it on GitHub
<#796 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABJYKUP3NMLLJSJGETJKJJTVDRUFDANCNFSM5STI4UHA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
You may overide the darkmode toggle button using alias or theme extending, and setting a new default value, the understanding above is incorrrect. For details you may check the hint in my theme here:
Defaul theme could be similar. |
many thanks, will come back to this tmr.
…On Tue, Apr 5, 2022 at 8:51 PM Mr.Hope ***@***.***> wrote:
You may overide the darkmode toggle button using alias or theme extending,
and setting a new default value, the understanding above is incorrrect.
For details you may check the hint in my theme here:
-
https://vuepress-theme-hope.github.io/v2/cookbook/advanced/replace.html#replace-components
-
https://vuepress-theme-hope.github.io/v2/cookbook/advanced/extend.html#theme-extending
—
Reply to this email directly, view it on GitHub
<#796 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABJYKUMNI2KGGJVRLOUQCFTVDUC3DANCNFSM5STI4UHA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I agree with the OP @xiaoyunwu here. I am new to vuepress and find it is odd that there is no config option to default the theme to dark. The templateBuild approach shown here is way too complicated and cumbersome. |
Feature request
Right now, the default-them use the prefers-color-scheme via const darkStorage = useStorage('vuepress-color-scheme', 'auto'), so builder does not have explicit control on the default darkMode.
Description
support defaultMarkMode which should be auto, light or dark. Where auto is defined by perfers-color-scheme.
Proposed Solution
There should be a configuration defaultDarkMode so that builder can specify in the config.ts.
The text was updated successfully, but these errors were encountered: