Skip to content

Commit

Permalink
Merge pull request #106 from brainstormforce/sidebar-collapse
Browse files Browse the repository at this point in the history
Sidebar collapse
  • Loading branch information
vrundakansara authored Oct 3, 2024
2 parents 9545d1a + 6021cf3 commit 1f0ca41
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dist/force-ui.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-dom'), 'version' => '078fc74692ede3c0d6af');
<?php return array('dependencies' => array('react', 'react-dom'), 'version' => 'cb8b68fc4b596e83b76c');
2 changes: 1 addition & 1 deletion dist/force-ui.js

Large diffs are not rendered by default.

20 changes: 14 additions & 6 deletions src/components/sidebar/sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,21 @@ const Sidebar = ( {
useEffect( () => {
const handleScreenResize = () => {
const isSmallScreen = window.innerWidth < 1280;
if ( isSmallScreen ) {
if ( ! collapsible ) {
setIsCollapsed( false );
localStorage.removeItem( 'sidebar-collapsed' );
} else if ( isSmallScreen ) {
setIsCollapsed( true );

localStorage.setItem( 'sidebar-collapsed', JSON.stringify( true ) );
localStorage.setItem(
'sidebar-collapsed',
JSON.stringify( true )
);
} else {
const storedState = localStorage.getItem( 'sidebar-collapsed' );
setIsCollapsed( storedState ? JSON.parse( storedState ) : false );
const storedState =
localStorage.getItem( 'sidebar-collapsed' );
setIsCollapsed(
storedState ? JSON.parse( storedState ) : false
);
}

if ( sideBarRef.current ) {
Expand All @@ -62,7 +70,7 @@ const Sidebar = ( {
return () => {
window.removeEventListener( 'resize', handleScreenResize );
};
}, [ screenHeight ] );
}, [ screenHeight, collapsible ] );

return (
<SidebarContext.Provider
Expand Down

0 comments on commit 1f0ca41

Please sign in to comment.