Skip to content

Commit f1907ef

Browse files
committed
refactor(UseBattery): enhance component with props and slots support
1 parent a1616a5 commit f1907ef

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

packages/core/useBattery/component.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
1+
import type { ConfigurableNavigator, UseBatteryReturn } from '@vueuse/core'
2+
import type { Reactive, SlotsType } from 'vue'
13
import { useBattery } from '@vueuse/core'
24
import { defineComponent, reactive } from 'vue'
35

4-
export const UseBattery = /* #__PURE__ */ defineComponent({
5-
name: 'UseBattery',
6-
setup(props, { slots }) {
7-
const data = reactive(useBattery(props))
6+
interface UseBatteryProps extends ConfigurableNavigator {}
7+
interface UseBatterySlots {
8+
default: (data: Reactive<UseBatteryReturn>) => any
9+
}
810

11+
export const UseBattery = /* #__PURE__ */ defineComponent<
12+
UseBatteryProps,
13+
Record<string, never>,
14+
string,
15+
SlotsType<UseBatterySlots>
16+
>(
17+
(props, { slots }) => {
18+
const data = reactive(useBattery(props))
919
return () => {
1020
if (slots.default)
1121
return slots.default(data)
1222
}
1323
},
14-
})
24+
{
25+
name: 'UseBattery',
26+
props: ['navigator'],
27+
},
28+
)

0 commit comments

Comments
 (0)