Skip to content

Commit

Permalink
Merge pull request #65 from AnglesHQ/fixing_menu_state
Browse files Browse the repository at this point in the history
storing state of menu in cookie.
  • Loading branch information
snevesbarros authored Dec 9, 2023
2 parents b774817 + e32e8d8 commit 5c6ef14
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/containers/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const App = function (props) {
const location = useLocation();
const teamRequests = new TeamRequests(axios);
const environmentRequests = new EnvironmentRequests(axios);
const [expand, setExpand] = useState(true);
const [expand, setExpand] = useState(Cookies.get('expand') === undefined || (Cookies.get('expand') === 'true'));
const {
teams,
currentTeam,
Expand Down Expand Up @@ -156,6 +156,11 @@ const App = function (props) {
Cookies.set('theme', theme);
};

const toggleMenu = () => {
Cookies.set('expand', !expand, { expires: 365 });
setExpand(!expand);
};

return (
<Container>
<Sidebar
Expand Down Expand Up @@ -218,7 +223,7 @@ const App = function (props) {
</Sidenav.Body>
<Navbar appearance="subtle" className="nav-toggle">
<Nav pullRight>
<Nav.Item style={{ width: 56, textAlign: 'center' }} onClick={() => setExpand(!expand)}>
<Nav.Item style={{ width: 56, textAlign: 'center' }} onClick={() => toggleMenu()}>
{expand ? <AngleLeftIcon /> : <AngleRightIcon />}
</Nav.Item>
</Nav>
Expand Down

0 comments on commit 5c6ef14

Please sign in to comment.