11<script setup>
2- import { createDirectus , rest , realtime , readItems , readSingleton , authentication } from ' @directus/sdk' ;
2+ import { createDirectus , rest , readItems , readSingleton } from ' @directus/sdk' ;
33
44const {
55 public: { tvUrl , baseUrl },
66} = useRuntimeConfig ();
77
8- const directus = createDirectus (tvUrl).with (rest ()).with (realtime ()).with (authentication ());
9- const live = await directus .request (readSingleton (' live' ));
10- const globals = await directus .request (readSingleton (' globals' , { fields: [' realtime_public_user_token' ] }));
8+ const directus = createDirectus (tvUrl).with (rest ());
119
12- const shows = await directus .request (
13- readItems (' shows' , {
14- filter: { id: { _in: live .offline_featured } },
15- }),
16- );
17-
18- const highlights = ref ([]);
19- const highlightsLoaded = ref (false );
20-
21- onMounted (async () => {
22- await directus .connect ();
23- directus .sendMessage ({ type: ' auth' , access_token: globals .realtime_public_user_token });
24-
25- directus .onWebSocket (' message' , async (message ) => {
26- if (message .type === ' auth' && message .status === ' ok' ) {
27- await subscribe ();
28- }
29- });
30-
31- async function subscribe () {
32- const { subscription } = await directus .subscribe (' live' , {
33- query: { fields: [' highlights' ] },
34- uid: ' highlights' ,
35- });
10+ const { data: live } = await useAsyncData (' live' , () => directus .request (readSingleton (' live' )));
3611
37- for await (const item of subscription ) {
38- if (item .event === ' init' && item .uid === ' highlights' ) {
39- highlights .value = item .data [0 ].highlights .filter ((highlight ) => highlight .show ).reverse ();
40- highlightsLoaded .value = true ;
41- }
12+ const { data: globals } = await useAsyncData (' globals' , () =>
13+ directus .request (readSingleton (' globals' , { fields: [' realtime_public_user_token' ] })),
14+ );
4215
43- if (item .event === ' update' && item .uid === ' highlights' ) {
44- highlights .value = item .data [0 ].highlights .filter ((highlight ) => highlight .show ).reverse ();
45- }
46- }
47- }
48- });
16+ const { data: shows } = await useAsyncData (' shows' , () =>
17+ directus .request (
18+ readItems (' shows' , {
19+ filter: { id: { _in: live .value .offline_featured } },
20+ }),
21+ ),
22+ );
4923
5024definePageMeta ({
5125 layout: ' tv' ,
@@ -104,15 +78,17 @@ const isChatOpen = ref(true);
10478 frameborder =" 0"
10579 referrerpolicy =" strict-origin-when-cross-origin"
10680 ></iframe >
107- <div class =" chat" :class =" { collapsed: !isChatOpen }" >
108- <iframe
109- :src =" `https://www.youtube.com/live_chat?v=${live.youtube_id}&embed_domain=localhost`"
110- allow =" autoplay"
111- allowfullscreen
112- frameborder =" 0"
113- referrerpolicy =" strict-origin-when-cross-origin"
114- ></iframe >
115- </div >
81+ <transition name =" chat-toggle" >
82+ <div v-show =" isChatOpen" class =" chat" >
83+ <iframe
84+ :src =" `https://www.youtube.com/live_chat?v=${live.youtube_id}&embed_domain=localhost`"
85+ allow =" autoplay"
86+ allowfullscreen
87+ frameborder =" 0"
88+ referrerpolicy =" strict-origin-when-cross-origin"
89+ ></iframe >
90+ </div >
91+ </transition >
11692 </div >
11793 </template >
11894 </BaseContainer >
@@ -128,7 +104,7 @@ const isChatOpen = ref(true);
128104 size =" small"
129105 outline
130106 />
131- <!-- Vimeo already has chat baked in to events -->
107+ <!-- Vimeo already has chat baked in to events so only show for YouTube -->
132108 <BaseButton
133109 v-if =" live.youtube_id"
134110 color =" primary"
@@ -142,18 +118,6 @@ const isChatOpen = ref(true);
142118 <BaseHeading :content =" live.title" size =" medium" />
143119 <BaseText :content =" live.description" color =" foreground" />
144120 </div >
145-
146- <div v-if =" highlights.length" class =" highlights" >
147- <h2 >Live Highlights</h2 >
148- <ol v-if =" highlights.length" >
149- <li v-for =" (highlight, index) in highlights" :key =" highlight.label" >
150- <a :href =" highlight.url" target =" _blank" >
151- <BaseBadge v-if =" index === 0" label =" Latest" color =" gray" />
152- <span >{{ highlight.label }}</span >
153- </a >
154- </li >
155- </ol >
156- </div >
157121 </BaseContainer >
158122 </div >
159123 </div >
@@ -224,47 +188,9 @@ const isChatOpen = ref(true);
224188 gap : 1rem ;
225189}
226190
227- .highlights {
228- margin-top : 2rem ;
229- ol {
230- padding-left : 0 ;
231- list-style-type : none ;
232- display : flex ;
233- flex-direction : column ;
234- gap : 1em ;
235- a {
236- display : block ;
237- background : rgba (255 , 255 , 255 , 0.12 );
238- border-radius : 8px ;
239- box-shadow : 0 4px 30px rgba (0 , 0 , 0 , 0.1 );
240- backdrop-filter : blur (1.8px );
241- -webkit-backdrop-filter : blur (1.8px );
242- border : 1px solid rgba (255 , 255 , 255 , 0.33 );
243- color : white ;
244- text-decoration : none ;
245- padding : 1rem ;
246- display : flex ;
247- gap : 1rem ;
248- .base-badge {
249- display : none ;
250- }
251- }
252- li :not (:first-child ) {
253- opacity : 0.5 ;
254- }
255- }
256- @media (width > 60rem ) {
257- ol a {
258- font-size : 1.25rem ;
259- .base-badge {
260- display : block !important ;
261- }
262- }
263- }
264- }
265-
266191.player-container {
267192 display : flex ;
193+ flex-direction : column ;
268194 gap : 1rem ;
269195
270196 .stream {
@@ -278,17 +204,48 @@ const isChatOpen = ref(true);
278204 .chat {
279205 flex-basis : 300px ;
280206 flex-shrink : 0 ;
281- height : 100 % ;
282- transition : flex-basis 0.4 s ease ;
283-
284- & .collapsed {
285- flex-basis : 0 ;
286- }
207+ height : 400 px ;
208+ max-height : 65 vh ;
209+ width : 100 % ;
210+ display : flex ;
211+ flex-direction : column ;
212+ overflow : visible ;
287213
288214 iframe {
289215 width : 100% ;
290216 height : 100% ;
291217 border-radius : 8px ;
218+ min-height : 380px ;
219+ }
220+ }
221+
222+ .chat-toggle-enter-active ,
223+ .chat-toggle-leave-active {
224+ transition : all 0.4s ease ;
225+ overflow : hidden ;
226+ }
227+
228+ .chat-toggle-enter-from ,
229+ .chat-toggle-leave-to {
230+ opacity : 0 ;
231+ height : 0 ;
232+ margin-bottom : 0 ;
233+ }
234+
235+ @media (width > 60rem ) {
236+ flex-direction : row ;
237+
238+ .chat {
239+ height : auto ;
240+ max-height : none ;
241+ min-height : 450px ;
242+ }
243+
244+ .chat-toggle-enter-from ,
245+ .chat-toggle-leave-to {
246+ width : 0 ;
247+ flex-basis : 0 ;
248+ margin-right : 0 ;
292249 }
293250 }
294251}
0 commit comments