1+ /* eslint-disable stylistic/no-mixed-operators */
12import {
23 createEffect ,
34 createMemo ,
@@ -8,13 +9,15 @@ import {
89 onCleanup ,
910 onMount ,
1011 type Setter ,
12+ Show ,
1113 Switch ,
1214} from 'solid-js' ;
1315
1416import * as z from 'zod' ;
1517
1618import {
1719 type ProviderName ,
20+ ProviderNames ,
1821 providerNames ,
1922 ProviderNameSchema ,
2023 type ProviderState ,
@@ -23,7 +26,14 @@ import { currentLyrics, lyricsStore, setLyricsStore } from '../store';
2326import { _ytAPI } from '../index' ;
2427import { config } from '../renderer' ;
2528
26- import type { YtIcons } from '@/types/icons' ;
29+ import '@mdui/icons/chevron-left.js' ;
30+ import '@mdui/icons/chevron-right.js' ;
31+ import '@mdui/icons/check-circle.js' ;
32+ import '@mdui/icons/warning.js' ;
33+ import '@mdui/icons/error.js' ;
34+ import '@mdui/icons/star.js' ;
35+ import '@mdui/icons/star-border.js' ;
36+
2737import type { PlayerAPIEvents } from '@/types/player-api-events' ;
2838
2939const LocalStorageSchema = z . object ( {
@@ -47,7 +57,8 @@ const shouldSwitchProvider = (providerData: ProviderState) => {
4757const providerBias = ( p : ProviderName ) =>
4858 ( lyricsStore . lyrics [ p ] . state === 'done' ? 1 : - 1 ) +
4959 ( lyricsStore . lyrics [ p ] . data ?. lines ?. length ? 2 : - 1 ) +
50- ( lyricsStore . lyrics [ p ] . data ?. lines ?. length && p === 'YTMusic' ? 1 : 0 ) +
60+ // eslint-disable-next-line prettier/prettier
61+ ( lyricsStore . lyrics [ p ] . data ?. lines ?. length && p === ProviderNames . YTMusic ? 1 : 0 ) +
5162 ( lyricsStore . lyrics [ p ] . data ?. lyrics ? 1 : - 1 ) ;
5263
5364const pickBestProvider = ( ) => {
@@ -60,7 +71,6 @@ const pickBestProvider = () => {
6071 }
6172
6273 const providers = Array . from ( providerNames ) ;
63-
6474 providers . sort ( ( a , b ) => providerBias ( b ) - providerBias ( a ) ) ;
6575
6676 return { provider : providers [ 0 ] , force : false } ;
@@ -175,50 +185,16 @@ export const LyricsPicker = (props: {
175185 } ) ;
176186 } ;
177187
178- const chevronLeft : YtIcons = 'yt-icons:chevron_left' ;
179- const chevronRight : YtIcons = 'yt-icons:chevron_right' ;
180-
181- const successIcon : YtIcons = 'yt-icons:check-circle' ;
182- const errorIcon : YtIcons = 'yt-icons:error' ;
183- const notFoundIcon : YtIcons = 'yt-icons:warning' ;
184-
185188 return (
186189 < div class = "lyrics-picker" ref = { props . setStickRef } >
187190 < div class = "lyrics-picker-left" >
188- < yt-icon-button
189- class = "style-scope ytmusic-player-bar"
190- icon = { chevronLeft }
191- onClick = { previous }
192- role = { 'button' }
193- >
194- < span class = "yt-icon-shape style-scope yt-icon yt-spec-icon-shape" >
195- < div
196- style = { {
197- 'width' : '100%' ,
198- 'height' : '100%' ,
199- 'display' : 'flex' ,
200- 'align-items' : 'center' ,
201- 'fill' : 'currentcolor' ,
202- } }
203- >
204- < svg
205- class = "style-scope yt-icon"
206- fill = "#FFFFFF"
207- height = { '40px' }
208- preserveAspectRatio = "xMidYMid meet"
209- viewBox = "0 -960 960 960"
210- width = { '40px' }
211- >
212- < g class = "style-scope yt-icon" >
213- < path
214- class = "style-scope yt-icon"
215- d = "M560.67-240 320-480.67l240.67-240.66L608-674 414.67-480.67 608-287.33 560.67-240Z"
216- />
217- </ g >
218- </ svg >
219- </ div >
220- </ span >
221- </ yt-icon-button >
191+ < mdui-button-icon >
192+ < mdui-icon-chevron-left
193+ onClick = { previous }
194+ role = "button"
195+ style = { { padding : '5px' } }
196+ />
197+ </ mdui-button-icon >
222198 </ div >
223199
224200 < div class = "lyrics-picker-content" >
@@ -247,9 +223,8 @@ export const LyricsPicker = (props: {
247223 />
248224 </ Match >
249225 < Match when = { currentLyrics ( ) . state === 'error' } >
250- < yt-icon
251- icon = { errorIcon }
252- style = { { padding : '5px' , transform : 'scale(0.8)' } }
226+ < mdui-icon-error
227+ style = { { padding : '5px' , scale : '0.8' } }
253228 tabindex = "-1"
254229 />
255230 </ Match >
@@ -260,9 +235,8 @@ export const LyricsPicker = (props: {
260235 currentLyrics ( ) . data ?. lyrics )
261236 }
262237 >
263- < yt-icon
264- icon = { successIcon }
265- style = { { padding : '5px' , transform : 'scale(0.8)' } }
238+ < mdui-icon-check-circle
239+ style = { { padding : '5px' , scale : '0.8' } }
266240 tabindex = "-1"
267241 />
268242 </ Match >
@@ -273,9 +247,8 @@ export const LyricsPicker = (props: {
273247 ! currentLyrics ( ) . data ?. lyrics
274248 }
275249 >
276- < yt-icon
277- icon = { notFoundIcon }
278- style = { { padding : '5px' , transform : 'scale(0.8)' } }
250+ < mdui-icon-warning
251+ style = { { padding : '5px' , scale : '0.8' } }
279252 tabindex = "-1"
280253 />
281254 </ Match >
@@ -284,20 +257,14 @@ export const LyricsPicker = (props: {
284257 class = "description ytmusic-description-shelf-renderer"
285258 text = { { runs : [ { text : provider ( ) } ] } }
286259 />
287- < yt-icon
288- icon = {
289- starredProvider ( ) === provider ( )
290- ? 'yt-sys-icons:star-filled'
291- : 'yt-sys-icons:star'
292- }
293- onClick = { toggleStar }
294- style = { {
295- padding : '5px' ,
296- transform : 'scale(0.8)' ,
297- cursor : 'pointer' ,
298- } }
299- tabindex = "-1"
300- />
260+ < mdui-button-icon onClick = { toggleStar } tabindex = { - 1 } >
261+ < Show
262+ fallback = { < mdui-icon-star-border /> }
263+ when = { starredProvider ( ) === provider ( ) }
264+ >
265+ < mdui-icon-star />
266+ </ Show >
267+ </ mdui-button-icon >
301268 </ div >
302269 ) }
303270 </ Index >
@@ -318,41 +285,14 @@ export const LyricsPicker = (props: {
318285 </ ul >
319286 </ div >
320287
321- < div class = "lyrics-picker-right" >
322- < yt-icon-button
323- class = "style-scope ytmusic-player-bar"
324- icon = { chevronRight }
325- onClick = { next }
326- role = { 'button' }
327- >
328- < span class = "yt-icon-shape style-scope yt-icon yt-spec-icon-shape" >
329- < div
330- style = { {
331- 'width' : '100%' ,
332- 'height' : '100%' ,
333- 'display' : 'flex' ,
334- 'align-items' : 'center' ,
335- 'fill' : 'currentcolor' ,
336- } }
337- >
338- < svg
339- class = "style-scope yt-icon"
340- fill = "#FFFFFF"
341- height = { '40px' }
342- preserveAspectRatio = "xMidYMid meet"
343- viewBox = "0 -960 960 960"
344- width = { '40px' }
345- >
346- < g class = "style-scope yt-icon" >
347- < path
348- class = "style-scope yt-icon"
349- d = "M521.33-480.67 328-674l47.33-47.33L616-480.67 375.33-240 328-287.33l193.33-193.34Z"
350- />
351- </ g >
352- </ svg >
353- </ div >
354- </ span >
355- </ yt-icon-button >
288+ < div class = "lyrics-picker-left" >
289+ < mdui-button-icon >
290+ < mdui-icon-chevron-right
291+ onClick = { next }
292+ role = "button"
293+ style = { { padding : '5px' } }
294+ />
295+ </ mdui-button-icon >
356296 </ div >
357297 </ div >
358298 ) ;
0 commit comments