Skip to content

Commit e8e473b

Browse files
feat!: remove unstable scoped css hack and slot
1 parent 63d956e commit e8e473b

File tree

3 files changed

+41
-79
lines changed

3 files changed

+41
-79
lines changed

playground/App.vue

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
2-
import { ref } from 'vue'
3-
import { type FreecasterPlayerSlots, FreecasterStyle } from '../src'
2+
import { shallowRef, ref, computed } from 'vue'
3+
import { FreecasterStyle, type Player } from '../src'
44
55
const customElement = import.meta.env.VITE_CUSTOM_ELEMENT
66
@@ -15,9 +15,15 @@
1515
const index = ref(0)
1616
const id = ref('')
1717
18+
const player = shallowRef<Player>()
1819
const paused = ref(false)
1920
const muted = ref(true)
2021
const currentTime = ref(0)
22+
const fullscreen = ref(false)
23+
const volume = ref<number>()
24+
const readyState = ref<number>()
25+
const currentSubtitles = ref<TextTrack>()
26+
const subtitles = ref<TextTrack[]>()
2127
const preview = ref(false)
2228
2329
function onSubmit(): void {
@@ -107,27 +113,41 @@
107113
controls
108114
autoplay
109115
subtitles-default-lang="fr"
110-
#default="state"
116+
v-model="player"
111117
v-model:paused="paused"
112118
v-model:muted="muted"
113119
v-model:current-time="currentTime"
114-
>
115-
<div class="controls">
116-
<button @click="paused = !paused">
117-
{{ paused ? 'play' : 'pause' }}
118-
</button>
119-
<button @click="muted = !muted">
120-
{{ muted ? 'unmute' : 'mute' }}
121-
</button>
122-
<button @click="currentTime -= 5">
123-
backward
124-
</button>
125-
<button @click="currentTime += 5">
126-
forward
127-
</button>
128-
</div>
129-
<pre>{{ formatObject(state) }}</pre>
130-
</FreecasterPlayer>
120+
v-model:fullscreen="fullscreen"
121+
v-model:volume="volume"
122+
v-model:ready-state="readyState"
123+
v-model:current-subtitles="currentSubtitles"
124+
v-model:subtitles="subtitles"
125+
/>
126+
<div class="controls">
127+
<button @click="paused = !paused">
128+
{{ paused ? 'play' : 'pause' }}
129+
</button>
130+
<button @click="muted = !muted">
131+
{{ muted ? 'unmute' : 'mute' }}
132+
</button>
133+
<button @click="currentTime -= 5">
134+
backward
135+
</button>
136+
<button @click="currentTime += 5">
137+
forward
138+
</button>
139+
</div>
140+
<pre>{{ formatObject({
141+
player,
142+
paused,
143+
muted,
144+
fullscreen,
145+
currentTime,
146+
volume,
147+
readyState,
148+
currentSubtitles,
149+
subtitles
150+
}) }}</pre>
131151
</div>
132152
<div>
133153
<a

readme.md

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ attached to an element ref.
5656
### Player component
5757

5858
The `FreecasterPlayer` component is a wrapper around the `usePlayer` composable.
59-
It also provides models and slot props for the player state.
59+
It also provides models for the player state.
6060

6161
```vue
6262
<script setup lang="ts">
@@ -89,33 +89,7 @@ It also provides models and slot props for the player state.
8989
</template>
9090
```
9191

92-
```vue
93-
<script setup lang="ts">
94-
import { FreecasterPlayer } from '@plutotcool/vue-freecaster'
95-
</script>
96-
97-
<template>
98-
<FreecasterPlayer
99-
video-id="..."
100-
#default="{
101-
player,
102-
muted,
103-
paused,
104-
volume,
105-
currentTime,
106-
readyState,
107-
fullscreen,
108-
subtitles,
109-
currentSubtitles
110-
}"
111-
>
112-
<!-- ... !-->
113-
</FreecasterPlayer>
114-
</template>
115-
```
116-
11792
- [Component props](https://plutotcool.github.io/vue-freecaster/interfaces/_FreecasterPlayer__.FreecasterPlayerProps.html)
118-
- [Component slots](https://plutotcool.github.io/vue-freecaster/interfaces/_FreecasterPlayer__.FreecasterPlayerSlots.html)
11993
- [Component events](https://plutotcool.github.io/vue-freecaster/types/_FreecasterPlayer__.FreecasterPlayerEmits.html)
12094

12195
### Custom elements

src/components/FreecasterPlayer.vue

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,9 @@
77
88
}
99
10-
export interface FreecasterPlayerSlots {
11-
default(props: {
12-
player: Player | undefined
13-
paused: boolean
14-
muted: boolean
15-
fullscreen: boolean
16-
currentTime: number
17-
volume: number
18-
readyState: number
19-
currentSubtitles: TextTrack | undefined
20-
subtitles: TextTrack[]
21-
}): any
22-
}
23-
2410
export type FreecasterPlayerEmits = PlayerEvents
2511
26-
const scopeId = getCurrentInstance().vnode.scopeId
27-
2812
const props = defineProps<FreecasterPlayerProps>()
29-
const slots = defineSlots<FreecasterPlayerSlots>()
3013
const emit = defineEmits<FreecasterPlayerEmits>()
3114
3215
const player = defineModel<Player>()
@@ -107,7 +90,6 @@
10790
<div
10891
ref="element"
10992
v-bind="{
110-
...(scopeId ? { [scopeId]: '' } : null),
11193
...attrs,
11294
...attributes
11395
}"
@@ -116,18 +98,4 @@
11698
attributes.class
11799
].filter(Boolean)"
118100
/>
119-
<slot
120-
name="default"
121-
v-bind="{
122-
player,
123-
paused,
124-
muted,
125-
fullscreen,
126-
volume,
127-
currentTime,
128-
readyState,
129-
currentSubtitles,
130-
subtitles
131-
}"
132-
/>
133101
</template>

0 commit comments

Comments
 (0)