-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add routerhook for desktop UI and a basic sidebar menu for Decky in d…
…esktop UI
- Loading branch information
1 parent
fc95cf5
commit 7e040c1
Showing
18 changed files
with
448 additions
and
181 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,72 @@ | ||
import { FC, useEffect, useRef, useState } from 'react'; | ||
|
||
import { useDeckyState } from './DeckyState'; | ||
import PluginView from './PluginView'; | ||
import { QuickAccessVisibleState } from './QuickAccessVisibleState'; | ||
|
||
const DeckyDesktopSidebar: FC = () => { | ||
const { desktopMenuOpen, setDesktopMenuOpen } = useDeckyState(); | ||
const [closed, setClosed] = useState<boolean>(!desktopMenuOpen); | ||
const [openAnimStart, setOpenAnimStart] = useState<boolean>(desktopMenuOpen); | ||
const closedInterval = useRef<number | null>(null); | ||
|
||
useEffect(() => { | ||
const anim = requestAnimationFrame(() => setOpenAnimStart(desktopMenuOpen)); | ||
return () => cancelAnimationFrame(anim); | ||
}, [desktopMenuOpen]); | ||
|
||
useEffect(() => { | ||
closedInterval.current && clearTimeout(closedInterval.current); | ||
if (desktopMenuOpen) { | ||
setClosed(false); | ||
} else { | ||
closedInterval.current = setTimeout(() => setClosed(true), 500); | ||
} | ||
}, [desktopMenuOpen]); | ||
return ( | ||
<> | ||
<div | ||
className="deckyDesktopSidebarDim" | ||
style={{ | ||
position: 'absolute', | ||
height: 'calc(100% - 78px - 50px)', | ||
width: '100%', | ||
top: '78px', | ||
left: '0px', | ||
zIndex: 998, | ||
background: 'rgba(0, 0, 0, 0.7)', | ||
opacity: openAnimStart ? 1 : 0, | ||
display: desktopMenuOpen || !closed ? 'flex' : 'none', | ||
transition: 'opacity 0.4s cubic-bezier(0.65, 0, 0.35, 1)', | ||
}} | ||
onClick={() => setDesktopMenuOpen(false)} | ||
/> | ||
|
||
<div | ||
className="deckyDesktopSidebar" | ||
style={{ | ||
position: 'absolute', | ||
height: 'calc(100% - 78px - 50px)', | ||
width: '350px', | ||
paddingLeft: '16px', | ||
top: '78px', | ||
right: '0px', | ||
zIndex: 999, | ||
transition: 'transform 0.4s cubic-bezier(0.65, 0, 0.35, 1)', | ||
transform: openAnimStart ? 'translateX(0px)' : 'translateX(366px)', | ||
overflowY: 'scroll', | ||
// prevents chromium border jank | ||
display: desktopMenuOpen || !closed ? 'flex' : 'none', | ||
flexDirection: 'column', | ||
background: '#171d25', | ||
}} | ||
> | ||
<QuickAccessVisibleState.Provider value={desktopMenuOpen || !closed}> | ||
<PluginView desktop={true} /> | ||
</QuickAccessVisibleState.Provider> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default DeckyDesktopSidebar; |
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,44 @@ | ||
import { CSSProperties, FC, useState } from 'react'; | ||
|
||
import DeckyDesktopSidebar from './DeckyDesktopSidebar'; | ||
import DeckyIcon from './DeckyIcon'; | ||
import { useDeckyState } from './DeckyState'; | ||
|
||
const DeckyDesktopUI: FC = () => { | ||
const { desktopMenuOpen, setDesktopMenuOpen } = useDeckyState(); | ||
return ( | ||
<> | ||
<style> | ||
{` | ||
.deckyDesktopIcon { | ||
color: #67707b; | ||
} | ||
.deckyDesktopIcon:hover { | ||
color: #fff; | ||
} | ||
`} | ||
</style> | ||
<DeckyIcon | ||
className="deckyDesktopIcon" | ||
width={24} | ||
height={24} | ||
onClick={() => setDesktopMenuOpen(!desktopMenuOpen)} | ||
style={ | ||
{ | ||
position: 'absolute', | ||
top: '36px', // nav text is 34px but 36px looks nicer to me | ||
right: '10px', // <- is 16px but 10px looks nicer to me | ||
width: '24px', | ||
height: '24px', | ||
cursor: 'pointer', | ||
transition: 'color 0.3s linear', | ||
'-webkit-app-region': 'no-drag', | ||
} as CSSProperties | ||
} | ||
/> | ||
<DeckyDesktopSidebar /> | ||
</> | ||
); | ||
}; | ||
|
||
export default DeckyDesktopUI; |
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
Oops, something went wrong.