Skip to content

Commit 0455e1c

Browse files
author
Andrea Aliberti
committed
Added possibility to add custom JSX Elements as additional topbar item
1 parent 731e2c5 commit 0455e1c

3 files changed

Lines changed: 21 additions & 5 deletions

File tree

src/Layout/PanelSideBarLayout/Context/PanelSideBarLayoutContext.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,19 @@ export interface PanelSideBarLayoutProviderProps {
1717
* The user dropdown menu content.
1818
*/
1919
userDropDownMenu?: ReactNode;
20+
/**
21+
* The other menu content.
22+
*/
23+
topBarCustomItems?: JSX.Element[];
2024
}
2125

2226
const PanelSideBarLayoutContext = createContext<PanelSideBarLayoutProviderProps | null>(null);
2327

2428
export const PanelSideBarLayoutProvider = (props: PropsWithChildren<PanelSideBarLayoutProviderProps>) => {
25-
const { brand = null, children, footer = null, userDropDownMenu, userDropDownMenuToggle } = props;
29+
const { brand = null, children, footer = null, userDropDownMenu, userDropDownMenuToggle, topBarCustomItems } = props;
2630

2731
return (
28-
<PanelSideBarLayoutContext.Provider value={{ brand, footer, userDropDownMenu, userDropDownMenuToggle }}>
32+
<PanelSideBarLayoutContext.Provider value={{ brand, footer, userDropDownMenu, userDropDownMenuToggle, topBarCustomItems }}>
2933
{children}
3034
</PanelSideBarLayoutContext.Provider>
3135
);

src/Layout/PanelSideBarLayout/PanelSideBarLayout.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ export const PanelSideBarLayout = (props: PanelSideBarLayoutProps) => {
2929
const [isOpen, setIsOpen] = useState(true);
3030
const toggleSidebar = () => setIsOpen((prev) => !prev);
3131

32-
const { brand: contextBrand, footer: contextFooter, userDropDownMenu, userDropDownMenuToggle } = usePanelSideBarLayoutContext();
32+
const {
33+
brand: contextBrand,
34+
footer: contextFooter,
35+
userDropDownMenu,
36+
userDropDownMenuToggle,
37+
topBarCustomItems = [],
38+
} = usePanelSideBarLayoutContext();
3339

3440
return (
3541
<>
@@ -38,7 +44,11 @@ export const PanelSideBarLayout = (props: PanelSideBarLayoutProps) => {
3844
<div className="navbar-brand">{brand ?? contextBrand}</div>
3945

4046
{/* <NavbarUser /> */}
41-
<Nav className="navbar-user">
47+
<Nav className="navbar-user" vertical>
48+
{/*Other Custom Menu*/}
49+
{topBarCustomItems?.map((item) => (
50+
<NavItem>{item}</NavItem>
51+
))}
4252
<NavItem>
4353
<UncontrolledDropdown direction="start">
4454
<DropdownToggle nav className="user-dropdown">

styles/Layout/PanelSideBarLayout.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ $topnav-light-toggler-color: $gray-900;
109109
align-items: center;
110110
justify-content: center;
111111
align-self: flex-end;
112-
margin: 0 1rem;
112+
margin: 0 3rem;
113113
margin-left: auto;
114+
margin-right: 3rem;
114115

115116
.user-dropdown {
116117
font-weight: bold;
@@ -240,6 +241,7 @@ section.content:first-of-type {
240241

241242
@include media-breakpoint-up(md) {
242243
$toggled-width: #{$tile-size + $slim-scrollbar-base-width};
244+
243245
section.toggled {
244246
> #side-nav {
245247
transition: $sidebar-transition;

0 commit comments

Comments
 (0)