From 2a6167441a3a3754be2cbd13bd63710b0421128e Mon Sep 17 00:00:00 2001 From: jeffvli Date: Thu, 17 Nov 2022 01:42:53 -0800 Subject: [PATCH] Add queue drawer --- src/renderer/layouts/default-layout.tsx | 121 ++++++++++++++++++++---- 1 file changed, 101 insertions(+), 20 deletions(-) diff --git a/src/renderer/layouts/default-layout.tsx b/src/renderer/layouts/default-layout.tsx index b98919eec..43520e63c 100644 --- a/src/renderer/layouts/default-layout.tsx +++ b/src/renderer/layouts/default-layout.tsx @@ -1,7 +1,9 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; -import { motion } from 'framer-motion'; +import { useDisclosure } from '@mantine/hooks'; +import { AnimatePresence, motion, Variants } from 'framer-motion'; import isElectron from 'is-electron'; import throttle from 'lodash/throttle'; +import { TbArrowBarLeft } from 'react-icons/tb'; import { Outlet } from 'react-router'; import styled from 'styled-components'; import { UserDetailResponse } from '@/renderer/api/users.api'; @@ -66,7 +68,7 @@ const RightSidebarContainer = styled(motion.div)` `; const PlayerbarContainer = styled.footer` - z-index: 50; + z-index: 100; grid-area: player; background: var(--playerbar-bg); filter: drop-shadow(0 -3px 1px rgba(0, 0, 0, 10%)); @@ -93,6 +95,24 @@ const ResizeHandle = styled.div<{ } `; +const QueueDrawer = styled(motion.div)` + background: var(--sidebar-bg); + border-left: var(--sidebar-border); +`; + +const QueueDrawerButton = styled(motion.div)` + position: absolute; + top: 35%; + right: 0; + z-index: 55; + display: flex; + align-items: center; + width: 50px; + height: 25vh; + opacity: 0.3; + user-select: none; +`; + interface DefaultLayoutProps { shell?: boolean; } @@ -100,6 +120,7 @@ interface DefaultLayoutProps { export const DefaultLayout = ({ shell }: DefaultLayoutProps) => { const sidebar = useAppStore((state) => state.sidebar); const setSidebar = useAppStore((state) => state.setSidebar); + const [opened, drawerHandler] = useDisclosure(false); const sidebarRef = useRef(null); const rightSidebarRef = useRef(null); @@ -109,6 +130,42 @@ export const DefaultLayout = ({ shell }: DefaultLayoutProps) => { const login = useAuthStore((state) => state.login); const setSettings = useSettingsStore((state) => state.setSettings); + const queueDrawerVariants: Variants = { + closed: { + height: 'calc(100% - 120px)', + position: 'absolute', + right: 0, + width: 0, + }, + open: { + height: 'calc(100% - 120px)', + position: 'absolute', + right: 0, + transition: { + duration: 0.5, + ease: 'anticipate', + }, + width: '30vw', + zIndex: 75, + }, + }; + + const queueSidebarVariants: Variants = { + closed: { + transition: { duration: 0.5 }, + x: 1000, + }, + open: { + transition: { + duration: 0.5, + ease: 'anticipate', + }, + width: sidebar.rightWidth, + x: 0, + zIndex: 75, + }, + }; + useEffect(() => { if (!isElectron()) { setSettings({ @@ -205,28 +262,52 @@ export const DefaultLayout = ({ shell }: DefaultLayoutProps) => { /> - {sidebar.rightExpanded && ( - drawerHandler.open()} > - { - e.preventDefault(); - startResizing('right'); - }} - /> - - + + )} + + {opened && ( + drawerHandler.close()} + > + + + )} + + + {sidebar.rightExpanded && ( + + { + e.preventDefault(); + startResizing('right'); + }} + /> + + + )} + )} -