Skip to content

Commit 4369c13

Browse files
author
Gianmarco Manni
committed
final
1 parent e11f9e2 commit 4369c13

6 files changed

Lines changed: 64 additions & 36 deletions

File tree

src/lib/Layout/PanelSideBarLayout/PanelSideBar/PanelSidebar.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@ import { PanelItem } from "./Definitions/PanelItem";
66
import { PanelSideBarItem } from "./PanelSideBarItem";
77

88
export const PanelSideBar = <TPanelItemId extends string, TPanelItem>() => {
9-
const { activePanelId, menuItems, setActivePanel, toggledMenuItemIds, toggleMenuItem, renderFirstItemsLevelAsTiles, renderTilesAsLinks, LinkRenderer, theme } = usePanelSideBarContext<
10-
TPanelItemId,
11-
TPanelItem
12-
>();
9+
const {
10+
activePanelId,
11+
menuItems,
12+
setActivePanel,
13+
toggledMenuItemIds,
14+
toggleMenuItem,
15+
renderFirstItemsLevelAsTiles,
16+
renderTilesAsLinks,
17+
LinkRenderer,
18+
theme,
19+
} = usePanelSideBarContext<TPanelItemId, TPanelItem>();
1320

1421
const className = classNames(
1522
"panel-layout",
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import { PanelItem } from "../Definitions/PanelItem";
22

3+
const getActivePanelInternal = <TPanelItemId extends string, TPanelItem>(
4+
items: PanelItem<TPanelItemId, TPanelItem>[],
5+
): PanelItem<TPanelItemId, TPanelItem> | undefined => items.find((x) => (x.children ? getActivePanelInternal(x.children) : x.active));
36

4-
const getActivePanelInternal = <TPanelItemId extends string, TPanelItem>(items: PanelItem<TPanelItemId, TPanelItem>[])
5-
: PanelItem<TPanelItemId, TPanelItem> | undefined => items.find((x) => x.children ? getActivePanelInternal(x.children) : x.active);
6-
7-
export const getActivePanel = <TPanelItemId extends string, TPanelItem>(items: PanelItem<TPanelItemId, TPanelItem>[], defaultActivePanelId?: TPanelItemId) => getActivePanelInternal(items) ?? items.find((x) => defaultActivePanelId ? x.id === defaultActivePanelId : x.id);
8-
9-
export const hasActiveChildren = <TPanelItemId extends string, TPanelItem>(items: PanelItem<TPanelItemId, TPanelItem>[]) => !!getActivePanelInternal(items);
7+
export const getActivePanel = <TPanelItemId extends string, TPanelItem>(
8+
items: PanelItem<TPanelItemId, TPanelItem>[],
9+
defaultActivePanelId?: TPanelItemId,
10+
) => getActivePanelInternal(items) ?? items.find((x) => (defaultActivePanelId ? x.id === defaultActivePanelId : x.id));
1011

12+
export const hasActiveChildren = <TPanelItemId extends string, TPanelItem>(items: PanelItem<TPanelItemId, TPanelItem>[]) =>
13+
!!getActivePanelInternal(items);

src/lib/Layout/PanelSideBarLayout/PanelSideBarLayout.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ export interface PanelSideBarLayoutProps extends PropsWithChildren {
3434
*/
3535
useToggleButton?: boolean;
3636

37-
3837
useResponsiveLayout?: boolean;
3938
}
4039

@@ -47,23 +46,27 @@ export const PanelSideBarLayout = <TPanelItemId extends string, TPanelItem>(prop
4746
footer = undefined,
4847
collapsible = true,
4948
useToggleButton = false,
50-
useResponsiveLayout = false,
49+
useResponsiveLayout = false,
5150
} = props;
5251

53-
5452
const { isSidebarOpen, toggleSidebar, renderFirstItemsLevelAsTiles } = usePanelSideBarContext<TPanelItemId, TPanelItem>();
5553

5654
if (useResponsiveLayout && !useToggleButton) {
57-
throw new Error("Responsive layout can be used only with toggle button in the navbar!")
55+
throw new Error("Responsive layout can be used only with toggle button in the navbar!");
5856
}
5957
return (
6058
<>
61-
<PanelSidebarNavbar useToggleButton={useToggleButton} brand={brand} navbarRightItems={navbarRightItems} navbarLeftItems={navbarLeftItems} />
59+
<PanelSidebarNavbar
60+
useToggleButton={useToggleButton}
61+
brand={brand}
62+
navbarRightItems={navbarRightItems}
63+
navbarLeftItems={navbarLeftItems}
64+
/>
6265
<section
6366
id="main-section"
6467
className={classNames(
6568
{ toggled: !isSidebarOpen },
66-
{ "responsive-layout" : useResponsiveLayout},
69+
{ "responsive-layout": useResponsiveLayout },
6770
{ "section-no-tiles": !renderFirstItemsLevelAsTiles },
6871
{ "section-tiles": renderFirstItemsLevelAsTiles },
6972
)}

styles/Layout/_PanelSideBarLayout.scss

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ section.content:first-of-type {
121121
.side-nav {
122122
&__tiles {
123123
.tile {
124+
color: $sidenav-light-link-color;
124125
background-color: $sidenav-light-bg;
126+
border: 0px;
125127

126128
&:hover,
127129
&.active {
@@ -214,12 +216,19 @@ section.content:first-of-type {
214216
.side-nav {
215217
&__tiles {
216218
.tile {
219+
color: $sidenav-dark-active-bg-color;
220+
217221
background-color: $sidenav-dark-bg;
222+
border:0px;
223+
224+
&.active {
225+
border: 1px solid $sidenav-dark-active-bg-color;
226+
}
218227

219228
&:hover {
220-
color: $sidenav-dark-active-color;
221229
background-color: $sidenav-dark-active-bg-color;
222230
border-color: $sidenav-dark-active-bg-color;
231+
color: $sidenav-dark-bg;
223232
}
224233
}
225234
}
@@ -252,16 +261,6 @@ section.content:first-of-type {
252261
&.active {
253262
position: relative;
254263

255-
&:before {
256-
content: " ";
257-
position: absolute;
258-
top: 0;
259-
left: 0;
260-
width: 3px;
261-
height: 100%;
262-
background-color: $sidenav-dark-active-color;
263-
}
264-
265264
.nav-link {
266265
color: $sidenav-dark-link-active-color;
267266
font-weight: 600;
@@ -406,7 +405,16 @@ section.content:first-of-type {
406405
.section-tiles.toggled {
407406
> #side-nav {
408407
transition: $sidebar-transition;
409-
width: #{$tile-size + $slim-scrollbar-base-width};
408+
width: $tile-size;
409+
display: none;
410+
411+
li.nav-item {
412+
&.active {
413+
&:before {
414+
display: none;
415+
}
416+
}
417+
}
410418
}
411419

412420
> #side-nav-toggle {
@@ -427,7 +435,15 @@ section.content:first-of-type {
427435
.section-no-tiles.toggled {
428436
> #side-nav {
429437
transition: $sidebar-transition;
430-
width: #{$slim-scrollbar-base-width};
438+
width: 0px;
439+
440+
li.nav-item {
441+
&.active {
442+
&:before {
443+
display: none;
444+
}
445+
}
446+
}
431447
}
432448

433449
> #side-nav-toggle {

styles/Layout/index.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
@import "./variables";
22
@import "./PanelSideBarNavbar";
3-
@import "./PanelSideBarLayout";
3+
@import "./PanelSideBarLayout";

styles/Layout/variables.scss

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ $sidenav-dark-heading-color: fade-out($white, 0.75);
3333
$sidenav-dark-link-color: fade-out($white, 0.5);
3434
$sidenav-dark-icon-color: fade-out($white, 0.75);
3535
$sidenav-dark-footer-bg: $gray-800;
36-
$sidenav-dark-active-color: $white; //TODO: define different
37-
$sidenav-dark-active-bg-color: $primary-hover; // TODO: define different
38-
$sidenav-dark-active-border-color: $primary; // TODO: define different
36+
$sidenav-dark-active-color: $gray-900;
37+
$sidenav-dark-active-bg-color: $white;
38+
$sidenav-dark-active-border-color: $white;
3939
$svg-dark-attributes: "fill='white' strike='white'";
4040

4141
// Sidenav-blue
@@ -63,9 +63,8 @@ $sidenav-light-link-color: $gray-600;
6363
$sidenav-light-link-active-color: $black;
6464
$sidenav-light-icon-color: $gray-500;
6565
$sidenav-light-footer-bg: $gray-200;
66-
$sidenav-light-active-color: $white; //TODO: define different
67-
$sidenav-light-active-bg-color: $primary-hover; // TODO: define different
68-
$sidenav-light-active-border-color: $primary; // TODO: define different
66+
$sidenav-light-active-color: $primary;
67+
$sidenav-light-active-bg-color: $gray-100;
6968
$svg-light-attributes: "fill='dark' strike='dark'";
7069

7170
// Color variables for the topnav

0 commit comments

Comments
 (0)