Skip to content

Commit 8f24619

Browse files
authored
improvements (#115)
1 parent 1bda829 commit 8f24619

File tree

4 files changed

+312
-33
lines changed

4 files changed

+312
-33
lines changed

my-app/src/model.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export const model = {
77
//instead of passing searchcouses lambda function down into the searchbarview.
88
/* courses returned from SearchbarPresenter (search is applied on top of filteredCourses[]) to be shown in the ListView */
99
currentSearch: [],
10+
11+
sidebarIsOpen: true,
1012
/* current query text */
1113
currentSearchText: "",
1214
scrollPosition: 0,
@@ -238,4 +240,19 @@ export const model = {
238240
// cache the result
239241
return avgRtg;
240242
},
243+
244+
setSidebarState(state) {
245+
this.sidebarIsOpen = state;
246+
},
247+
248+
getSidebarState() {
249+
return this.sidebarIsOpen;
250+
},
251+
252+
toggleSidebarIsOpen() {
253+
this.sidebarIsOpen = !this.sidebarIsOpen;
254+
}
255+
256+
257+
241258
};

my-app/src/pages/App.jsx

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,73 +6,71 @@ import { FilterPresenter } from "../presenters/FilterPresenter.jsx";
66
import { Routes, Route } from 'react-router-dom';
77
import SharedView from '../pages/SharedView.jsx';
88
import { slide as Menu } from 'react-burger-menu';
9+
import { observer } from 'mobx-react-lite';
10+
911

10-
function MainAppLayout({ model }) {
11-
const [sidebarIsOpen, setSidebarIsOpen] = useState(true);
1212

13-
const toggleSidebar = () => {
14-
setSidebarIsOpen(!sidebarIsOpen);
15-
}
13+
function MainAppLayout({ model }) {
1614

15+
const [sidebarIsOpen, setSidebarIsOpen] = useState(model.sidebarIsOpen);
1716

1817
return (
1918
/* The sidebar styling(under the menu)*/
2019
<div className=" flex h-screen w-screen bg-[#6246a8] ">
2120
{ /* If sidebar is open, set length to 400px, else it should not be visible */}
2221
<div className={`${sidebarIsOpen ? 'w-[400px]' : 'w-0'}`}>
2322
<Menu
24-
width={400} // menu width
25-
isOpen={sidebarIsOpen}
23+
width={400}
24+
isOpen={model.sidebarIsOpen}
2625
onStateChange={(state) => setSidebarIsOpen(state.isOpen)}
27-
className="bg-gradient-to-t from-[#6246a8] to-[#6747c0] z-0 h-screen" // The menu styling
26+
className="bg-gradient-to-t from-[#6246a8] to-[#6747c0] z-0 h-screen"
2827
noOverlay
2928
styles={{
3029
bmMenuWrap: {
3130
zIndex: '10'
32-
}
31+
},
32+
bmBurgerButton: {
33+
position: 'fixed',
34+
top: '20px',
35+
left: '20px',
36+
width: '36px',
37+
height: '30px'
38+
},
3339
}}
40+
customBurgerIcon={ <img src="https://img.icons8.com/ios-filled/50/ffffff/menu-2.png" /> }
3441
>
35-
{/* The menu contents */}
36-
<SidebarPresenter model={model} />
42+
<SidebarPresenter model={model}/>
3743
</Menu>
3844
</div>
3945

46+
47+
4048
<div className="flex-1 h-full flex flex-col ">
4149

50+
4251
<div className="bg-gradient-to-t from-[#6246a8] to-[#6747c0] text-white">
4352
<div className="flex items-center">
44-
{/* The button to open the menu */}
45-
<button
46-
onClick={toggleSidebar}
47-
className="p-2 ml-2 text-white hover:bg-purple-700 rounded"
48-
>
49-
<img
50-
src="https://img.icons8.com/ios-filled/50/ffffff/menu-2.png"
51-
alt="menu icon"
52-
className="w-6 h-6"
53-
/>
54-
</button>
55-
<SearchbarPresenter model={model} />
53+
<SearchbarPresenter model={model}/>
5654
</div>
5755
</div>
5856

5957

6058
<div className="flex-auto border bg-[#121212] relative">
61-
<ListViewPresenter model={model} />
59+
<ListViewPresenter model={model}/>
6260
</div>
6361

64-
<FilterPresenter model={model} />
62+
<FilterPresenter model={model}/>
6563
</div>
6664
</div>)
6765
}
6866

69-
function App({ model }) {
67+
function App({model}) {
7068
return (
7169
<Routes>
72-
<Route path="/" element={<MainAppLayout model={model} />} />
73-
<Route path="/share" element={<SharedView model={model} />} />
70+
<Route path="/" element={<MainAppLayout model={model}/>}/>
71+
<Route path="/share" element={<SharedView model={model}/>}/>
7472
</Routes>
7573
);
7674
}
7775

78-
export default App;
76+
export default observer(App);

my-app/src/styles.css

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,15 @@
2626
.bm-burger-button {
2727
position: absolute;
2828
width: 36px;
29-
height: 36px;
30-
left: 36px;
31-
top: 36px;
32-
}
29+
height: 30px;
30+
left: 20px;
31+
top: 20px;
32+
}
33+
34+
35+
.bm-menu-wrap {
36+
position: fixed;
37+
height: 100%;
38+
z-index: 10;
39+
}
40+

0 commit comments

Comments
 (0)