Skip to content

Commit

Permalink
feat: persistent width
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikbossart committed Oct 30, 2023
1 parent f434fa3 commit 9ae8765
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/dm-core-plugins/src/explorer/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ type TProps = {

export default function Sidebar(props: TProps) {
const { children } = props
const [width, setWidth] = useState<number>(defaultWidth)
const [width, setWidth] = useState<number>(
parseInt(String(localStorage.getItem('explorerWidth'))) ?? defaultWidth
)
const isResized = useRef<boolean>(false)

useEffect(() => {
localStorage.setItem('explorerWidth', String(width))
}, [width])

useEffect(() => {
window.addEventListener('mousemove', (e) => {
if (!isResized.current) {
Expand Down

0 comments on commit 9ae8765

Please sign in to comment.