mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-09 20:29:36 +02:00
persist queue sidebar panel sizing
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { lazy, Suspense, useCallback, useMemo, useRef, useState } from 'react';
|
import { lazy, Suspense, useCallback, useMemo, useRef, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Group, Panel, Separator } from 'react-resizable-panels';
|
import { Group, Panel, Separator, useDefaultLayout } from 'react-resizable-panels';
|
||||||
|
|
||||||
import styles from './sidebar-play-queue.module.css';
|
import styles from './sidebar-play-queue.module.css';
|
||||||
|
|
||||||
@@ -50,6 +50,12 @@ export const SidebarPlayQueue = () => {
|
|||||||
const showVisualizer = showVisualizerInSidebar && type === PlayerType.WEB && webAudio;
|
const showVisualizer = showVisualizerInSidebar && type === PlayerType.WEB && webAudio;
|
||||||
const showPanel = showLyricsInSidebar || showVisualizer;
|
const showPanel = showLyricsInSidebar || showVisualizer;
|
||||||
|
|
||||||
|
// Persist the layout of the sidebar play queue container
|
||||||
|
const { defaultLayout, onLayoutChange } = useDefaultLayout({
|
||||||
|
id: 'sidebar-play-queue-container',
|
||||||
|
storage: localStorage,
|
||||||
|
});
|
||||||
|
|
||||||
// Filter and order panels based on what's enabled
|
// Filter and order panels based on what's enabled
|
||||||
const orderedPanels = useMemo(() => {
|
const orderedPanels = useMemo(() => {
|
||||||
if (combinedLyricsAndVisualizer) {
|
if (combinedLyricsAndVisualizer) {
|
||||||
@@ -77,7 +83,7 @@ export const SidebarPlayQueue = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{index > 0 && <Separator className={styles.resizeHandle} />}
|
{index > 0 && <Separator className={styles.resizeHandle} />}
|
||||||
<Panel defaultSize={50} key="queue" minSize={20}>
|
<Panel defaultSize={50} id="queue" key="queue" minSize={20}>
|
||||||
<div className={styles.playQueueSection}>
|
<div className={styles.playQueueSection}>
|
||||||
<PlayQueue
|
<PlayQueue
|
||||||
listKey={ItemListKey.SIDE_QUEUE}
|
listKey={ItemListKey.SIDE_QUEUE}
|
||||||
@@ -94,7 +100,12 @@ export const SidebarPlayQueue = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{index > 0 && <Separator className={styles.resizeHandle} />}
|
{index > 0 && <Separator className={styles.resizeHandle} />}
|
||||||
<Panel defaultSize={50} key="combined" minSize={20}>
|
<Panel
|
||||||
|
defaultSize={totalPanels > 2 ? 25 : 50}
|
||||||
|
id="combined"
|
||||||
|
key="combined"
|
||||||
|
minSize={20}
|
||||||
|
>
|
||||||
<CombinedLyricsAndVisualizerPanel />
|
<CombinedLyricsAndVisualizerPanel />
|
||||||
</Panel>
|
</Panel>
|
||||||
</>
|
</>
|
||||||
@@ -105,7 +116,12 @@ export const SidebarPlayQueue = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{index > 0 && <Separator className={styles.resizeHandle} />}
|
{index > 0 && <Separator className={styles.resizeHandle} />}
|
||||||
<Panel defaultSize={totalPanels > 2 ? 25 : 50} key="lyrics" minSize={15}>
|
<Panel
|
||||||
|
defaultSize={totalPanels > 2 ? 25 : 50}
|
||||||
|
id="lyrics"
|
||||||
|
key="lyrics"
|
||||||
|
minSize={15}
|
||||||
|
>
|
||||||
<LyricsPanel />
|
<LyricsPanel />
|
||||||
</Panel>
|
</Panel>
|
||||||
</>
|
</>
|
||||||
@@ -116,7 +132,12 @@ export const SidebarPlayQueue = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{index > 0 && <Separator className={styles.resizeHandle} />}
|
{index > 0 && <Separator className={styles.resizeHandle} />}
|
||||||
<Panel defaultSize={totalPanels > 2 ? 25 : 50} key="visualizer" minSize={15}>
|
<Panel
|
||||||
|
defaultSize={totalPanels > 2 ? 25 : 50}
|
||||||
|
id="visualizer"
|
||||||
|
key="visualizer"
|
||||||
|
minSize={15}
|
||||||
|
>
|
||||||
<VisualizerPanel />
|
<VisualizerPanel />
|
||||||
</Panel>
|
</Panel>
|
||||||
</>
|
</>
|
||||||
@@ -134,7 +155,12 @@ export const SidebarPlayQueue = () => {
|
|||||||
type={ItemListKey.SIDE_QUEUE}
|
type={ItemListKey.SIDE_QUEUE}
|
||||||
/>
|
/>
|
||||||
{showPanel ? (
|
{showPanel ? (
|
||||||
<Group orientation="vertical" style={{ flex: 1, minHeight: 0 }}>
|
<Group
|
||||||
|
defaultLayout={defaultLayout}
|
||||||
|
onLayoutChange={onLayoutChange}
|
||||||
|
orientation="vertical"
|
||||||
|
style={{ flex: 1, minHeight: 0 }}
|
||||||
|
>
|
||||||
{orderedPanels.map((panel, index) =>
|
{orderedPanels.map((panel, index) =>
|
||||||
renderPanel(panel, index, orderedPanels.length),
|
renderPanel(panel, index, orderedPanels.length),
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user