Skip to content

Commit

Permalink
fix(ui): destructure slot data binding for DarkToggle component (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
webfansplz authored Jan 8, 2024
1 parent 1e46a51 commit ed84e63
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/client/src/components/common/DockingPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ watch(activeAppRecordId, (id) => {
<VueDarkToggle>
<template #default="{ isDark, toggle }">
<VueButton outlined type="primary" @click="toggle">
<div i-carbon-sun dark:i-carbon-moon translate-y--1px /> {{ isDark.value ? 'Dark' : 'Light' }}
<div i-carbon-sun dark:i-carbon-moon translate-y--1px /> {{ isDark ? 'Dark' : 'Light' }}
</VueButton>
</template>
</VueDarkToggle>
Expand Down
7 changes: 1 addition & 6 deletions packages/ui/src/components/DarkToggle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,10 @@ function toggle(event?: MouseEvent) {
)
})
}
const context = {
mode,
isDark,
toggle,
}
</script>

<template>
<span class="$ui-dark-toggle-vtr">
<slot v-bind="context" />
<slot v-bind="{ mode, isDark, toggle }" />
</span>
</template>
4 changes: 2 additions & 2 deletions packages/ui/storybook/DarkToggle.story.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const dark = computed({
toggle(e)
}"
>
<Icon :class="isDark.value ? 'i-carbon-moon' : 'i-carbon-sun'" />
<Icon :class="isDark ? 'i-carbon-moon' : 'i-carbon-sun'" />
</Button>
</template>
</DarkToggle>
Expand All @@ -37,7 +37,7 @@ const dark = computed({
toggle(e)
}"
>
<Icon :class="isDark.value ? 'i-carbon-moon' : 'i-carbon-sun'" />
<Icon :class="isDark ? 'i-carbon-moon' : 'i-carbon-sun'" />
</Button>
</template>
</DarkToggle>
Expand Down

0 comments on commit ed84e63

Please sign in to comment.