Add missing sidebar configuration

This commit is contained in:
jeffvli 2023-06-14 00:45:10 -07:00
parent 7fa4641dfe
commit ba8e23e8d4
3 changed files with 64 additions and 44 deletions

View file

@ -1,4 +1,4 @@
import { useCallback, useState } from 'react'; import { ChangeEvent, useCallback, useState } from 'react';
import { Group } from '@mantine/core'; import { Group } from '@mantine/core';
import { Reorder, useDragControls } from 'framer-motion'; import { Reorder, useDragControls } from 'framer-motion';
import isEqual from 'lodash/isEqual'; import isEqual from 'lodash/isEqual';
@ -54,10 +54,10 @@ const DraggableSidebarItem = ({ item, handleChangeDisabled }: DraggableSidebarIt
}; };
export const SidebarSettings = () => { export const SidebarSettings = () => {
const { sidebarItems } = useGeneralSettings(); const settings = useGeneralSettings();
const { setSidebarItems } = useSettingsStoreActions(); const { setSidebarItems, setSettings } = useSettingsStoreActions();
const [localSidebarItems, setLocalSidebarItems] = useState(sidebarItems); const [localSidebarItems, setLocalSidebarItems] = useState(settings.sidebarItems);
const handleSave = () => { const handleSave = () => {
setSidebarItems(localSidebarItems); setSidebarItems(localSidebarItems);
@ -78,12 +78,26 @@ export const SidebarSettings = () => {
); );
}, []); }, []);
const isSaveButtonDisabled = isEqual(sidebarItems, localSidebarItems); const handleSetSidebarPlaylistList = (e: ChangeEvent<HTMLInputElement>) => {
setSettings({
general: {
...settings,
sidebarPlaylistList: e.target.checked,
},
});
};
const isSaveButtonDisabled = isEqual(settings.sidebarItems, localSidebarItems);
return ( return (
<> <>
<SettingsOptions <SettingsOptions
control={<Switch />} control={
<Switch
checked={settings.sidebarPlaylistList}
onChange={handleSetSidebarPlaylistList}
/>
}
description="Show playlist list in sidebar" description="Show playlist list in sidebar"
title="Sidebar playlist list" title="Sidebar playlist list"
/> />

View file

@ -12,7 +12,8 @@ interface ListItemProps extends FlexProps {
const StyledItem = styled(Flex)` const StyledItem = styled(Flex)`
width: 100%; width: 100%;
font-weight: 700; font-weight: 600;
font-size: 1.1rem;
font-family: var(--content-font-family); font-family: var(--content-font-family);
&:focus-visible { &:focus-visible {

View file

@ -136,6 +136,7 @@ export const Sidebar = () => {
const sidebar = useSidebarStore(); const sidebar = useSidebarStore();
const { setSideBar } = useAppStoreActions(); const { setSideBar } = useAppStoreActions();
const { windowBarStyle } = useWindowSettings(); const { windowBarStyle } = useWindowSettings();
const { sidebarPlaylistList } = useGeneralSettings();
const imageUrl = useCurrentSong()?.imageUrl; const imageUrl = useCurrentSong()?.imageUrl;
const server = useCurrentServer(); const server = useCurrentServer();
@ -229,6 +230,8 @@ export const Sidebar = () => {
mx="1rem" mx="1rem"
my="0.5rem" my="0.5rem"
/> />
{sidebarPlaylistList && (
<>
<Group <Group
position="apart" position="apart"
pt="1rem" pt="1rem"
@ -267,6 +270,8 @@ export const Sidebar = () => {
</Group> </Group>
</Group> </Group>
<SidebarPlaylistList data={playlistsQuery.data} /> <SidebarPlaylistList data={playlistsQuery.data} />
</>
)}
</MotionStack> </MotionStack>
<AnimatePresence <AnimatePresence
initial={false} initial={false}