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

[Feature request] Dynamically theme-color change with dark mode #7

Open
Unbinilium opened this issue Jun 13, 2021 · 4 comments
Open
Labels

Comments

@Unbinilium
Copy link

Unbinilium commented Jun 13, 2021

Feature request

Description

Since Apple introduced new Safari design in WWDC 2021, personally, I think that changing theme-color with dark mode dynamically would have a nicer look for upcoming Safari 15.x (maybe improve other browsers too). Or in another word the current theme-color is too bright for the dark mode, compared in the attached video.

Screen.Recording.2021-06-14.at.00.17.38.mov

Proposed Solution

Not experienced in Vue but I think something like this would did help:

// ToggleDarkButton.vue

…

const changeThemeColor = (): void => {
  const themeColorEl = window?.document.querySelector(
    'meta[name="theme-color"]'
  )

  themeColorEl?.setAttribute('content', !isDark.value ? '#3eaf7c' : '#22272e')
}

…

const setDark = (): void => {
  setDarkClass()
  changeThemeColor()
}

onMounted(() => {
  …

  watch(isDark, setDark, { immediate: true })
})

If it fine I could pull a request, thanks for reviewing.

@meteorlxy
Copy link
Member

Sounds good to me.

The color should sync with css vars

@Unbinilium
Copy link
Author

Sounds good to me.

The color should sync with css vars

PR in vuepress/core#218, but still some problem need help, see it in PR note.

@jrappen
Copy link

jrappen commented Oct 13, 2021

As a reference, this vuepress 1.x plugin might help:

https://github.com/tolking/vuepress-theme-default-prefers-color-scheme

@meteorlxy meteorlxy transferred this issue from vuepress/core Dec 3, 2023
@github-actions github-actions bot added the stale label Dec 19, 2023
Copy link

This issue is marked as stale because it has not had recent activity. Issues marked with stale will be closed if they have no activity within 7 days.

@meteorlxy meteorlxy added enhancement New feature or request package:theme-default and removed stale labels Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants