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(useColorMode): disableTransition support pseudo-elements #3129

Merged
merged 3 commits into from
Jun 6, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion packages/core/useColorMode/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,18 @@ export function useColorMode<T extends string = BasicColorMode>(
let style: HTMLStyleElement | undefined
if (disableTransition) {
style = window!.document.createElement('style')
style.appendChild(document.createTextNode('*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}'))
const styleString = `
*,
*::before,
*::after {
-webkit-transition: none !important;
-moz-transition: none !important;
-o-transition: none !important;
-ms-transition: none !important;
transition: none !important;
}
`
Copy link
Member

Choose a reason for hiding this comment

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

Please keep it minified, as this is a string literal and the minifier won't do it.

style.appendChild(document.createTextNode(styleString))
window!.document.head.appendChild(style)
}

Expand Down