✨ (chilled) add loader when loading music
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
<img src="@/assets/logo.svg" alt="binôme" />
|
<img class="logo" src="@/assets/logo.svg" alt="binôme" />
|
||||||
<router-view />
|
<router-view />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -11,11 +11,12 @@
|
|||||||
#app {
|
#app {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
svg {
|
img.logo {
|
||||||
margin: 0.1rem;
|
margin-top: 1rem;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
18
src/assets/loader.svg
Executable file
18
src/assets/loader.svg
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#f8efba" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<line x1="12" y1="2" x2="12" y2="6">
|
||||||
|
</line>
|
||||||
|
<line x1="12" y1="18" x2="12" y2="22">
|
||||||
|
</line>
|
||||||
|
<line x1="4.93" y1="4.93" x2="7.76" y2="7.76">
|
||||||
|
</line>
|
||||||
|
<line x1="16.24" y1="16.24" x2="19.07" y2="19.07">
|
||||||
|
</line>
|
||||||
|
<line x1="2" y1="12" x2="6" y2="12">
|
||||||
|
</line>
|
||||||
|
<line x1="18" y1="12" x2="22" y2="12">
|
||||||
|
</line>
|
||||||
|
<line x1="4.93" y1="19.07" x2="7.76" y2="16.24">
|
||||||
|
</line>
|
||||||
|
<line x1="16.24" y1="7.76" x2="19.07" y2="4.93">
|
||||||
|
</line>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 612 B |
@@ -1,5 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="chilled-music" v-show="false">
|
<div class="chilled-music">
|
||||||
|
<img v-if="!ready" src="@/assets/loader.svg" alt="loading" />
|
||||||
|
<section v-show="false">
|
||||||
<div
|
<div
|
||||||
class="chilled-music plyr__video-embed"
|
class="chilled-music plyr__video-embed"
|
||||||
id="player"
|
id="player"
|
||||||
@@ -9,6 +11,7 @@
|
|||||||
data-plyr-provider="youtube"
|
data-plyr-provider="youtube"
|
||||||
data-plyr-embed-id="5qap5aO4i9A"
|
data-plyr-embed-id="5qap5aO4i9A"
|
||||||
></div>
|
></div>
|
||||||
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -20,7 +23,8 @@ import {
|
|||||||
onMounted,
|
onMounted,
|
||||||
watchEffect,
|
watchEffect,
|
||||||
reactive,
|
reactive,
|
||||||
onUnmounted
|
onUnmounted,
|
||||||
|
ref
|
||||||
} from '@vue/composition-api'
|
} from '@vue/composition-api'
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
@@ -32,6 +36,7 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
|
const ready = ref(false)
|
||||||
const chilledcow = reactive<{ video: Plyr | null }>({
|
const chilledcow = reactive<{ video: Plyr | null }>({
|
||||||
video: null
|
video: null
|
||||||
})
|
})
|
||||||
@@ -48,7 +53,7 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
const init = () => {
|
||||||
chilledcow.video = new Plyr('#player', {
|
chilledcow.video = new Plyr('#player', {
|
||||||
youtube: {
|
youtube: {
|
||||||
noCookie: true,
|
noCookie: true,
|
||||||
@@ -62,16 +67,21 @@ export default defineComponent({
|
|||||||
options: [240]
|
options: [240]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
chilledcow.video.on('error', init)
|
||||||
chilledcow.video.on('play', onPlay)
|
chilledcow.video.on('play', onPlay)
|
||||||
chilledcow.video.on('pause', onPause)
|
chilledcow.video.on('pause', onPause)
|
||||||
chilledcow.video.on('ready', () => {
|
chilledcow.video.on('ready', () => {
|
||||||
|
ready.value = true
|
||||||
if (props.play) {
|
if (props.play) {
|
||||||
chilledcow.video?.play()
|
chilledcow.video?.play()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
|
|
||||||
|
onMounted(init)
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
|
chilledcow.video?.off('error', init)
|
||||||
chilledcow.video?.off('play', onPlay)
|
chilledcow.video?.off('play', onPlay)
|
||||||
chilledcow.video?.off('pause', onPause)
|
chilledcow.video?.off('pause', onPause)
|
||||||
chilledcow.video?.destroy()
|
chilledcow.video?.destroy()
|
||||||
@@ -80,6 +90,25 @@ export default defineComponent({
|
|||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
props.play ? chilledcow.video?.play() : chilledcow.video?.pause()
|
props.play ? chilledcow.video?.play() : chilledcow.video?.pause()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
ready
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
@keyframes rotating {
|
||||||
|
from {
|
||||||
|
transform: rotate(0deg);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
animation: rotating 4s linear infinite;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -2,7 +2,9 @@
|
|||||||
<div class="zone-music plume" v-if="isMusicAvailable">
|
<div class="zone-music plume" v-if="isMusicAvailable">
|
||||||
<div class="pm-field">
|
<div class="pm-field">
|
||||||
<label for="use-music" data-pm-holder>
|
<label for="use-music" data-pm-holder>
|
||||||
<span :class="{ selected: !hasMusic, disabled: hasMusic }">focus</span>
|
<span class="focus" :class="{ selected: !hasMusic, disabled: hasMusic }"
|
||||||
|
>focus</span
|
||||||
|
>
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
name="use-music"
|
name="use-music"
|
||||||
@@ -11,10 +13,21 @@
|
|||||||
@change="setHasMusic(!hasMusic)"
|
@change="setHasMusic(!hasMusic)"
|
||||||
data-pm-checkbox-toggle
|
data-pm-checkbox-toggle
|
||||||
/>
|
/>
|
||||||
<span :class="{ selected: hasMusic, disabled: !hasMusic }">chill</span>
|
<span
|
||||||
|
class="chill"
|
||||||
|
:class="{ selected: hasMusic, disabled: !hasMusic }"
|
||||||
|
>
|
||||||
|
chill
|
||||||
|
<ChilledMusic
|
||||||
|
class="chilled-music"
|
||||||
|
v-if="hasMusic"
|
||||||
|
:play="play"
|
||||||
|
@play="play"
|
||||||
|
@pause="pause"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<ChilledMusic v-if="hasMusic" :play="play" @play="play" @pause="pause" />
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -52,7 +65,13 @@ export default defineComponent({
|
|||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@import '@/styles/variables';
|
@import '@/styles/variables';
|
||||||
|
|
||||||
|
.pm-field {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
label[data-pm-holder] {
|
label[data-pm-holder] {
|
||||||
|
flex: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
@@ -63,6 +82,20 @@ label[data-pm-holder] {
|
|||||||
&.selected {
|
&.selected {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
&.focus {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
&.chill {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-start;
|
||||||
|
|
||||||
|
.chilled-music {
|
||||||
|
margin-left: 0.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.pm-field {
|
.pm-field {
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ a {
|
|||||||
|
|
||||||
.fade-enter-active,
|
.fade-enter-active,
|
||||||
.fade-leave-active {
|
.fade-leave-active {
|
||||||
transition: opacity 0.25s ease;
|
transition: opacity 0.25s ease-out;
|
||||||
}
|
}
|
||||||
.fade-enter,
|
.fade-enter,
|
||||||
.fade-leave-to {
|
.fade-leave-to {
|
||||||
|
|||||||
Reference in New Issue
Block a user