diff --git a/src/app/main/layout.tsx b/src/app/main/layout.tsx index e45aa09..74df8f1 100644 --- a/src/app/main/layout.tsx +++ b/src/app/main/layout.tsx @@ -86,6 +86,7 @@ export default function RootLayout ({ const [versions, setVersions] = useState(null) const [account, setAccount] = useState(null) + const [sidebarShowGames, setSidebarShowGames] = useState(false) const [linuxUseWine, setLinuxUseWine] = useState(false) const [linuxWineCommand, setLinuxWineCommand] = useState('wine %path%') @@ -827,6 +828,9 @@ export default function RootLayout ({ } watchSettings('theme', v => setTheme(v ?? 'dark')) + watchSettings('sidebarShowGames', v => + setSidebarShowGames(v ?? true) + ) watchSettings('linuxUseWine', v => setLinuxUseWine(v ?? false)) watchSettings('linuxWineCommand', v => setLinuxWineCommand(v ?? 'wine %path%') @@ -892,6 +896,7 @@ export default function RootLayout ({ settings, versions, account, + sidebarShowGames, linuxUseWine, linuxWineCommand, theme, diff --git a/src/components/ExpandArrow.tsx b/src/components/ExpandArrow.tsx new file mode 100644 index 0000000..1e53952 --- /dev/null +++ b/src/components/ExpandArrow.tsx @@ -0,0 +1,12 @@ +import '@/styles/dropdown.css' +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' +import { faChevronDown } from '@fortawesome/free-solid-svg-icons' + +export default function ExpandArrow ({ open }: { open: boolean }) { + return ( + + ) +} diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index d92a282..f223607 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -24,6 +24,7 @@ import { getCurrentWindow } from '@tauri-apps/api/window' import { Lexend } from 'next/font/google' import React, { useState } from 'react' import { message } from '@tauri-apps/plugin-dialog' +import ExpandArrow from './ExpandArrow' const lexend = Lexend({ subsets: ['latin'] @@ -44,7 +45,8 @@ export default function Sidebar () { settings, developerMode, accountName, - accountAdmin + accountAdmin, + sidebarShowGames } = useGlobal() const pathname = usePathname() @@ -138,8 +140,21 @@ export default function Sidebar () { }} > Library + {(pathname === '/main/library' || + pathname.startsWith('/main/game')) && ( +
{ + e.preventDefault() + await settings?.set('sidebarShowGames', !sidebarShowGames) + }} + > + +
+ )} {(pathname === '/main/library' || pathname.startsWith('/main/game')) && + sidebarShowGames && serverVersionList?.games .filter(g => serverVersionList.versions diff --git a/src/providers/GlobalProvider.tsx b/src/providers/GlobalProvider.tsx index 56d1fd7..4d22151 100644 --- a/src/providers/GlobalProvider.tsx +++ b/src/providers/GlobalProvider.tsx @@ -54,6 +54,7 @@ type GlobalCtxType = { settings: Store | null versions: Store | null account: Store | null + sidebarShowGames: boolean linuxUseWine: boolean linuxWineCommand: string theme: string