Skip to content

Commit

Permalink
feat: allow Text as VClick's top-level child (#1214) (#1285)
Browse files Browse the repository at this point in the history
  • Loading branch information
KermanX committed Feb 11, 2024
1 parent b9d29f9 commit 1fe6120
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions packages/client/builtin/VClick.ts
Expand Up @@ -4,7 +4,8 @@
* Learn more: https://sli.dev/guide/animations.html#click-animations
*/

import { createVNode, defineComponent } from 'vue'
import type { PropType, VNode } from 'vue'
import { Text, defineComponent, h } from 'vue'
import VClicks from './VClicks'

export default defineComponent({
Expand All @@ -21,17 +22,28 @@ export default defineComponent({
type: Boolean,
default: false,
},
wrapText: {
type: Function as PropType<(text: VNode) => VNode>,
default: (text: VNode) => h('span', text),
},
},
render() {
return createVNode(
return h(
VClicks,
{
every: 99999,
at: this.at,
hide: this.hide,
fade: this.fade,
},
{ default: this.$slots.default },
{
default: () =>
this.$slots.default?.().map(v =>
v.type === Text
? this.wrapText(v)
: v,
),
},
)
},
})

0 comments on commit 1fe6120

Please sign in to comment.