Skip to content

Commit 1d1c638

Browse files
moshetanzerbenjamincanacvercel[bot]
authored
fix(ColorModeButton): use css to display color mode icon (#5394)
Co-authored-by: Benjamin Canac <canacb1@gmail.com> Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
1 parent 1d0f39d commit 1d1c638

File tree

2 files changed

+12
-76
lines changed

2 files changed

+12
-76
lines changed

src/runtime/components/color-mode/ColorModeButton.vue

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ const props = withDefaults(defineProps<ColorModeButtonProps>(), {
2727
color: 'neutral',
2828
variant: 'ghost'
2929
})
30-
defineSlots<{
31-
fallback(props?: {}): any
32-
}>()
3330
3431
const { t } = useLocale()
3532
const colorMode = useColorMode()
@@ -48,21 +45,17 @@ const isDark = computed({
4845
</script>
4946

5047
<template>
51-
<ClientOnly v-if="!colorMode?.forced">
52-
<UButton
53-
v-bind="{
54-
...buttonProps,
55-
'icon': props.icon || (isDark ? appConfig.ui.icons.dark : appConfig.ui.icons.light),
56-
'aria-label': isDark ? t('colorMode.switchToLight') : t('colorMode.switchToDark'),
57-
...$attrs
58-
}"
59-
@click="isDark = !isDark"
60-
/>
61-
62-
<template #fallback>
63-
<slot name="fallback">
64-
<div class="size-8" />
65-
</slot>
48+
<UButton
49+
v-bind="{
50+
...buttonProps,
51+
'aria-label': isDark ? t('colorMode.switchToLight') : t('colorMode.switchToDark'),
52+
...$attrs
53+
}"
54+
@click="isDark = !isDark"
55+
>
56+
<template #leading="{ ui }">
57+
<UIcon :class="ui.leadingIcon({ class: props.ui?.leadingIcon })" class="hidden dark:inline" :name="appConfig.ui.icons.dark" />
58+
<UIcon :class="ui.leadingIcon({ class: props.ui?.leadingIcon })" class="inline dark:hidden" :name="appConfig.ui.icons.light" />
6659
</template>
67-
</ClientOnly>
60+
</UButton>
6861
</template>

src/runtime/vue/components/color-mode/ColorModeButton.vue

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)