Skip to content

Commit a64371d

Browse files
author
Gianmarco Manni
committed
x
1 parent a4cfa71 commit a64371d

2 files changed

Lines changed: 114 additions & 39 deletions

File tree

src/lib/Layout/PanelSideBarLayout/PanelSideBar/Context/PanelSideBarContext.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ export const PanelSideBarProvider = <TPanelItemId extends string, TPanelItem>(
4242

4343
const [activePanelId, setActivePanelId] = useState(getActivePanel(menuItems, defaultActivePanelId)?.id);
4444
const setActivePanel = (panelId: TPanelItemId) => setActivePanelId(panelId);
45-
const [toggledMenuItemIds, setToggledMenuItemIds] = useState<TPanelItemId[]>(activePanelId ? [activePanelId] : []);
45+
46+
const preExpandedMenuItemIds = menuItems.filter((x) => x.expanded).map((x) => x.id);
47+
const [toggledMenuItemIds, setToggledMenuItemIds] = useState<TPanelItemId[]>(activePanelId ? preExpandedMenuItemIds.concat(activePanelId) : preExpandedMenuItemIds);
4648
const toggleMenuItem: MenuItemToggleFn<TPanelItemId> = (menuItemId) => {
4749
setToggledMenuItemIds((prev) => {
4850
const idExists = !!prev.find((id) => id == menuItemId);

styles/Layout/_PanelSideBarLayout.scss

Lines changed: 111 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,9 @@ section.content:first-of-type {
115115
background-color: $sidenav-light-bg;
116116
.side-nav {
117117
&__tiles {
118-
119118
.tile {
120119
background-color: $sidenav-light-bg;
121-
120+
122121
&:hover,
123122
&.active {
124123
color: $sidenav-light-active-color;
@@ -127,26 +126,26 @@ section.content:first-of-type {
127126
}
128127
}
129128
}
130-
129+
131130
&__items {
132131
&::-webkit-scrollbar {
133132
width: 0.25rem;
134133
}
135-
134+
136135
&::-webkit-scrollbar-thumb {
137136
background-color: $sidenav-light-color;
138137
}
139-
138+
140139
&::-webkit-scrollbar-track-piece {
141140
background-color: $sidenav-light-bg;
142141
}
143142

144143
li.nav-item {
145-
color: $sidenav-light-color;
144+
color: $sidenav-light-color;
146145

147-
&.active{
146+
&.active {
148147
position: relative;
149-
148+
150149
&:before {
151150
content: " ";
152151
position: absolute;
@@ -156,7 +155,7 @@ section.content:first-of-type {
156155
height: 100%;
157156
background-color: $primary;
158157
}
159-
158+
160159
.nav-link {
161160
color: $sidenav-light-link-active-color;
162161
font-weight: 600;
@@ -171,31 +170,31 @@ section.content:first-of-type {
171170
&.menu-open .nav-link.dropdown-toggle::after {
172171
@include chevron-light-down();
173172
}
174-
173+
175174
.nav-link {
176175
color: $sidenav-light-link-color;
177-
176+
178177
.sb-nav-link-icon {
179178
color: $sidenav-light-icon-color;
180179
}
181-
180+
182181
.sb-sidenav-collapse-arrow {
183182
color: $sidenav-light-icon-color;
184183
}
185-
184+
186185
&:hover {
187186
color: $sidenav-light-link-active-color;
188187
}
189-
188+
190189
&.active {
191190
color: $sidenav-light-link-active-color;
192-
191+
193192
.sb-nav-link-icon {
194193
color: $sidenav-light-link-active-color;
195194
}
196195
}
197196
}
198-
197+
199198
&.dropdown-toggle::after {
200199
@include chevron-light-right();
201200
}
@@ -211,24 +210,24 @@ section.content:first-of-type {
211210
&__tiles {
212211
.tile {
213212
background-color: $sidenav-dark-bg;
214-
215-
&:hover{
213+
214+
&:hover {
216215
color: $sidenav-dark-active-color;
217216
background-color: $sidenav-dark-active-bg-color;
218217
border-color: $sidenav-dark-active-bg-color;
219218
}
220219
}
221220
}
222-
221+
223222
&__items {
224223
&::-webkit-scrollbar {
225224
width: 0.25rem;
226225
}
227-
226+
228227
&::-webkit-scrollbar-thumb {
229228
background-color: $sidenav-dark-color;
230229
}
231-
230+
232231
&::-webkit-scrollbar-track-piece {
233232
background-color: $sidenav-dark-bg;
234233
}
@@ -239,15 +238,15 @@ section.content:first-of-type {
239238
div {
240239
color: $sidenav-dark-link-active-color;
241240
}
242-
}
241+
}
243242
}
244-
243+
245244
li.nav-item {
246245
color: $sidenav-dark-color;
247-
248-
&.active{
246+
247+
&.active {
249248
position: relative;
250-
249+
251250
&:before {
252251
content: " ";
253252
position: absolute;
@@ -257,7 +256,7 @@ section.content:first-of-type {
257256
height: 100%;
258257
background-color: $sidenav-dark-active-color;
259258
}
260-
259+
261260
.nav-link {
262261
color: $sidenav-dark-link-active-color;
263262
font-weight: 600;
@@ -267,11 +266,11 @@ section.content:first-of-type {
267266
color: $sidenav-dark-active-color;
268267
background-color: $sidenav-dark-bg;
269268
}
270-
269+
271270
&.menu-open .nav-link.dropdown-toggle::after {
272271
@include chevron-dark-down();
273272
}
274-
&.dropdown-toggle::after {
273+
.nav-link.dropdown-toggle::after {
275274
@include chevron-dark-right();
276275
}
277276
}
@@ -283,10 +282,9 @@ section.content:first-of-type {
283282
background-color: $sidenav-blue-bg;
284283
.side-nav {
285284
&__tiles {
286-
287285
.tile {
288286
background-color: $sidenav-blue-bg;
289-
287+
290288
&:hover,
291289
&.active {
292290
color: $sidenav-blue-active-color;
@@ -295,28 +293,28 @@ section.content:first-of-type {
295293
}
296294
}
297295
}
298-
296+
299297
&__items {
300298
&::-webkit-scrollbar {
301299
width: 0.25rem;
302300
}
303-
301+
304302
&::-webkit-scrollbar-thumb {
305303
background-color: $sidenav-blue-color;
306304
}
307-
305+
308306
&::-webkit-scrollbar-track-piece {
309307
background-color: $sidenav-blue-bg;
310308
}
311309

312310
li.nav-item {
313311
color: $sidenav-blue-color;
314-
312+
315313
&:hover {
316314
color: $sidenav-blue-active-color;
317315
background-color: $sidenav-blue-active-color;
318316
}
319-
317+
320318
.nav-link {
321319
color: white;
322320
}
@@ -367,7 +365,6 @@ section.content:first-of-type {
367365
color: $sidenav-dark-bg;
368366
}
369367
}
370-
371368
}
372369

373370
&.side-nav-toggle-light {
@@ -396,7 +393,6 @@ section.content:first-of-type {
396393
background-color: $sidenav-blue-hover;
397394
}
398395
}
399-
400396
}
401397

402398
@include media-breakpoint-up(xs) {
@@ -444,3 +440,80 @@ section.content:first-of-type {
444440
}
445441
}
446442
}
443+
444+
$zindex-content: 1037 !default;
445+
$zindex-sidenav: 1038 !default;
446+
$zindex-topnav: 1039 !default;
447+
448+
// Responsive styling for the sidenav layout
449+
@include media-breakpoint-down(lg) {
450+
#main-section.responsive-layout {
451+
#side-nav {
452+
position: fixed;
453+
left: 0;
454+
bottom: 0;
455+
right: 0;
456+
top: $topnav-base-height;
457+
width: $sidenav-base-width;
458+
flex-basis: $sidenav-base-width;
459+
flex-shrink: 0;
460+
transition: transform 0.15s ease-in-out;
461+
z-index: $zindex-sidenav;
462+
// Mobile first transform - by default the sidenav will be moved off-canvas
463+
transform: translateX(-$sidenav-base-width);
464+
465+
@include media-breakpoint-up(lg) {
466+
box-shadow: 0 0 0.5rem 0.125rem rgba($color: $gray-500, $alpha: 0.75);
467+
}
468+
}
469+
470+
#main-content-body {
471+
position: relative;
472+
margin-left: 0;
473+
display: flex;
474+
flex-direction: column;
475+
justify-content: space-between;
476+
min-width: 0;
477+
flex-grow: 1;
478+
min-height: 100vh;
479+
}
480+
481+
&.toggled {
482+
#side-nav {
483+
transform: translateX(0);
484+
box-shadow: unset;
485+
}
486+
487+
#main-content-body {
488+
&:before {
489+
content: "";
490+
display: block;
491+
position: absolute;
492+
top: 0;
493+
width: 100%;
494+
height: 100%;
495+
background: $black;
496+
z-index: $zindex-content;
497+
opacity: 0.5;
498+
transition: opacity 0.3s ease-in-out;
499+
}
500+
}
501+
}
502+
}
503+
504+
// Behavior for the sidenav collapse on screens larger than the med breakpoint
505+
#layout-sidenav.toggled {
506+
#layout-sidenav__nav {
507+
transform: translateX(-$sidenav-base-width);
508+
}
509+
510+
#layout-sidenav__content {
511+
margin-left: 0;
512+
513+
// Removes the sidenav overlay on screens larger than the med breakpoint
514+
&:before {
515+
display: none;
516+
}
517+
}
518+
}
519+
}

0 commit comments

Comments
 (0)