-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
mebtte
committed
Nov 28, 2023
1 parent
0b6b1be
commit c831c2c
Showing
12 changed files
with
120 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import Cache from '#/utils/cache'; | ||
import Cache from '@/utils/cache'; | ||
import { Tab } from './constants'; | ||
|
||
export enum CacheKey { | ||
TAB = 'tab', | ||
SELECTED_TAB = 'selected_tab', | ||
} | ||
|
||
export default new Cache< | ||
CacheKey, | ||
{ | ||
[CacheKey.TAB]: Tab; | ||
[CacheKey.SELECTED_TAB]: Tab; | ||
} | ||
>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
apps/pwa/src/pages/player/playlist_playqueue_drawer/tab_list.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import TabList from '@/components/tab_list'; | ||
import { t } from '@/i18n'; | ||
import { CSSProperties, useContext } from 'react'; | ||
import useTitlebarArea from '@/utils/use_titlebar_area_rect'; | ||
import { Tab, TAB_LIST_HEIGHT } from './constants'; | ||
import context from '../context'; | ||
|
||
const TAB_MAP_LABEL: Record<Tab, string> = { | ||
[Tab.PLAYLIST]: t('playlist'), | ||
[Tab.PLAYQUEUE]: t('playqueue'), | ||
}; | ||
const style: CSSProperties = { | ||
position: 'absolute', | ||
top: 0, | ||
left: 0, | ||
width: '100%', | ||
|
||
paddingInline: 20, | ||
backdropFilter: 'blur(5px)', | ||
}; | ||
|
||
function Wrapper({ | ||
selectedTab, | ||
onChange, | ||
}: { | ||
selectedTab: Tab; | ||
onChange: (tab: Tab) => void; | ||
}) { | ||
const { height } = useTitlebarArea(); | ||
const { playlist, playqueue } = useContext(context); | ||
const getCount = (tab: Tab) => { | ||
switch (tab) { | ||
case Tab.PLAYLIST: { | ||
return playlist.length; | ||
} | ||
case Tab.PLAYQUEUE: { | ||
return playqueue.length; | ||
} | ||
default: { | ||
return 0; | ||
} | ||
} | ||
}; | ||
return ( | ||
<TabList | ||
current={selectedTab} | ||
onChange={onChange} | ||
tabList={Object.values(Tab).map((tab) => { | ||
const count = getCount(tab); | ||
return { | ||
tab, | ||
label: `${TAB_MAP_LABEL[tab]}${count > 0 ? ` (${count})` : ''}`, | ||
}; | ||
})} | ||
style={{ | ||
...style, | ||
height: height + TAB_LIST_HEIGHT, | ||
paddingBlockStart: height, | ||
}} | ||
/> | ||
); | ||
} | ||
|
||
export default Wrapper; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.