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

feat(theme): allow providing custom toggle-appearance function #2844

Merged
merged 2 commits into from Aug 25, 2023

Conversation

brc-dd
Copy link
Member

@brc-dd brc-dd commented Aug 24, 2023

Demo: https://64e7754fb34be10008d647e3--vitepress-docs.netlify.app/ (won't be there in docs)

closes #2347


PS: if you want to change component appearance conditionally, do something like this:

const enableTransition = ref(false)

onMounted(() => {
  enableTransition.value = 'startViewTransition' in document && window.matchMedia('(prefers-reduced-motion: no-preference)').matches
})

<DefaultTheme.Layout :class="{ 'enable-transition': enableTransition }" />

.enable-transition .VPSwitchAppearance        { width: 22px !important; }
.enable-transition .VPSwitchAppearance .check { transform: none !important; }

But note that this will cause layout shifts and is not recommended.

@brc-dd brc-dd changed the title feat(theme): allow providing toggle-appearance function feat(theme): allow providing custom toggle-appearance function Aug 24, 2023
@brc-dd brc-dd marked this pull request as ready for review August 24, 2023 16:05
@brc-dd brc-dd merged commit 0be280a into main Aug 25, 2023
7 checks passed
@brc-dd brc-dd deleted the appearance-hook branch August 25, 2023 18:50
brc-dd added a commit that referenced this pull request Aug 26, 2023
Co-authored-by: Hooray Hu <304327508@qq.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant