Skip to content

Commit 7b3980c

Browse files
feat(layout): update layout classes and styles
1 parent 79254cc commit 7b3980c

6 files changed

Lines changed: 34 additions & 21 deletions

File tree

‎packages/layout/src/assets/css/components/layout/sidebar.css‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@
9898

9999
.dz-layout > .dz-sidebar > .dz-sidebar-header > .dz-toggle-menu {
100100
cursor: pointer;
101-
display: flex;
101+
display: none;
102102
padding: 0.4rem;
103103
transition: all ease-in var(--_layout-sidebar-transition-duration);
104104
}
105105

106-
.dz-layout > .dz-sidebar.fixed > .dz-sidebar-header > .dz-toggle-menu {
107-
display: none;
106+
.dz-layout > .dz-sidebar.collapsible > .dz-sidebar-header > .dz-toggle-menu {
107+
display: flex;
108108
}
109109

110110
.dz-layout[aria-expanded="false"]

‎packages/layout/src/assets/css/layouts/sidebar-header-layout.css‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@
4646
grid-area: header;
4747
}
4848

49-
.dz-sidebar-header-layout > header > .dz-header-container > .dz-toggle-menu {
49+
.dz-sidebar-header-layout.collapsible
50+
> header
51+
> .dz-header-container
52+
> .dz-toggle-menu {
5053
display: block;
5154
margin-left: -0.75rem;
5255
}

‎packages/layout/src/assets/css/layouts/sidebar-only-layout.css‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@
3636
grid-area: sidebar;
3737
}
3838

39+
.dz-sidebar-only-layout > .dz-sidebar {
40+
--_layout-sidebar-collapsed-width: var(
41+
--dz-layout-sidebar-collapsed-width,
42+
1.5rem
43+
);
44+
}
45+
3946
.dz-sidebar-only-layout > main {
4047
overflow-y: auto;
4148
}

‎packages/layout/src/components/Layout/Layout.tsx‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,36 @@ import { LayoutProvider, useLayoutContext } from "../../context/LayoutProvider";
55
type LayoutProperties = {
66
children?: React.ReactNode;
77
className?: string;
8+
collapsible?: boolean;
89
fixed?: boolean;
910
userMenuLocation?: "sidebar" | "header";
1011
};
1112

1213
const LayoutComponent = ({
1314
children,
1415
className,
16+
collapsible = false,
1517
fixed,
1618
userMenuLocation,
1719
}: LayoutProperties) => {
1820
const { menuDesktopOpen, menuMobileOpen } = useLayoutContext();
1921
const isLargeScreen = useMediaQuery("(min-width: 576px)");
2022

23+
let classNames = "dz-layout";
24+
if (className) {
25+
classNames += ` ${className}`;
26+
}
27+
if (fixed) {
28+
classNames += " fixed";
29+
}
30+
if (collapsible) {
31+
classNames += " collapsible";
32+
}
33+
classNames = classNames.trimEnd();
34+
2135
return (
2236
<div
23-
className={`dz-layout ${className || ""} ${
24-
fixed ? "fixed" : ""
25-
}`.trimEnd()}
37+
className={classNames}
2638
aria-expanded={isLargeScreen ? menuDesktopOpen : menuMobileOpen}
2739
data-user-menu-location={userMenuLocation}
2840
>
@@ -34,13 +46,15 @@ const LayoutComponent = ({
3446
export const Layout = ({
3547
children,
3648
className,
49+
collapsible = false,
3750
fixed,
3851
userMenuLocation,
3952
}: LayoutProperties) => {
4053
return (
4154
<LayoutProvider>
4255
<LayoutComponent
4356
className={className}
57+
collapsible={collapsible}
4458
fixed={fixed}
4559
userMenuLocation={userMenuLocation}
4660
>

‎packages/layout/src/components/Layout/Sidebar/Sidebar.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const Sidebar = ({
5656
};
5757

5858
return (
59-
<div className={`dz-sidebar ${!collapsible ? "fixed" : ""}`.trim()}>
59+
<div className={`dz-sidebar ${collapsible ? "collapsible" : ""}`.trim()}>
6060
{children || renderContent()}
6161
</div>
6262
);

‎packages/layout/src/layouts/SidebarHeaderLayout.tsx‎

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ export interface SidebarHeaderLayoutProperties {
1616
headerAddon?: React.ReactNode;
1717
navigationMenu?: NavMenuType;
1818
noLocaleSwitcher?: boolean;
19-
noLogo?: boolean;
20-
noSidebarHeader?: boolean;
21-
noSidebarFooter?: boolean;
22-
noToggle?: boolean;
2319
title?: string | React.ReactNode;
2420
userMenu?: NavMenuItemType;
2521
userMenuMode?: NavGroupDisplayMode;
@@ -30,17 +26,13 @@ export interface SidebarHeaderLayoutProperties {
3026
export const SidebarHeaderLayout = ({
3127
children,
3228
className,
33-
collapsible,
29+
collapsible = true,
3430
customHeader,
3531
customSidebar,
3632
displayNavIcons = true,
3733
headerAddon,
3834
navigationMenu,
3935
noLocaleSwitcher = false,
40-
noLogo = false,
41-
noSidebarHeader,
42-
noSidebarFooter = false,
43-
noToggle = false,
4436
title,
4537
userMenu,
4638
userMenuMode,
@@ -50,16 +42,15 @@ export const SidebarHeaderLayout = ({
5042
return (
5143
<Layout
5244
className={`dz-sidebar-header-layout ${className || ""}`.trimEnd()}
45+
collapsible={collapsible}
5346
userMenuLocation={userMenuLocation}
5447
>
5548
{customHeader || (
5649
<Header
5750
displayNavIcons={displayNavIcons}
5851
headerAddon={headerAddon}
5952
menu={userMenu}
60-
noLogo={noLogo}
6153
noLocaleSwitcher={noLocaleSwitcher}
62-
noToggle={noToggle}
6354
title={title}
6455
/>
6556
)}
@@ -68,8 +59,6 @@ export const SidebarHeaderLayout = ({
6859
collapsible={collapsible}
6960
displayNavIcons={displayNavIcons}
7061
navigationMenu={navigationMenu}
71-
noHeader={noSidebarHeader}
72-
noFooter={noSidebarFooter}
7362
noLocaleSwitcher={noLocaleSwitcher}
7463
userMenu={userMenu}
7564
userMenuMode={userMenuMode}

0 commit comments

Comments
 (0)