Skip to content

Commit 65ed943

Browse files
authored
fix(layout): return JSX element (#82)
* fix(layout): fill height without overflow
1 parent ccd270a commit 65ed943

File tree

3 files changed

+102
-97
lines changed

3 files changed

+102
-97
lines changed

src/components/layout/content.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ export default function LayoutContent(props: LayoutContentProps) {
2222
const [_, set] = context.content;
2323

2424
set(<div {...combinedProps} />);
25+
26+
return <></>;
2527
}

src/components/layout/index.scss

Lines changed: 98 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,99 @@
1-
.jdd.layout {
2-
--jdd-left-sidebar-offset: 0px;
3-
--jdd-right-sidebar-offset: 0px;
4-
--jdd-sidebar-transition: "";
5-
--jdd-layout-backdrop-opacity: 0;
6-
7-
display: flex;
8-
flex-direction: column;
9-
min-height: 100vh;
10-
min-width: 100vw;
11-
12-
13-
.layout-header {
14-
order: 1;
15-
}
16-
17-
.layout-main {
18-
order: 2;
19-
flex-grow: 1;
20-
display: flex;
21-
flex-direction: row;
22-
23-
.layout-sidebar {
24-
position: sticky;
25-
top: 0;
26-
height: 100vh;
27-
height: 100dvh;
28-
overflow: scroll;
29-
}
30-
31-
.layout-content {
32-
flex-grow: 1;
33-
}
34-
}
35-
36-
.layout-footer {
37-
order: 3;
38-
}
39-
40-
&.mobile {
41-
.layout-main {
42-
.layout-sidebar {
43-
position: fixed;
44-
top: 0;
45-
transition: var(--jdd-sidebar-transition);
46-
z-index: 50;
47-
max-width: 90vw;
48-
}
49-
50-
.layout-sidebar:first-child {
51-
left: 0;
52-
transform: translate3d(min((calc(-100% + var(--jdd-left-sidebar-offset))), 0px), 0, 0);
53-
}
54-
55-
.layout-sidebar:last-child {
56-
right: 0;
57-
transform: translate3d(max((calc(100% - var(--jdd-right-sidebar-offset))), 0px), 0, 0);
58-
}
59-
}
60-
61-
.layout-backdrop {
62-
opacity: max(0, var(--jdd-layout-backdrop-opacity));
63-
position: fixed;
64-
transition: var(--jdd-sidebar-transition);
65-
inset: 0;
66-
background: rgba(var(--jdd-gray-15-rgb), 0.2);
67-
pointer-events: none;
68-
69-
.jdd-dark & {
70-
background: rgba(var(--jdd-gray-1-rgb), 0.15);
71-
}
72-
73-
}
74-
}
75-
}
76-
77-
.jdd.layout.mobile {
78-
&.open-left .layout-sidebar:first-child {
79-
transform: translate3d(calc(0px - var(--jdd-left-sidebar-offset)), 0, 0);
80-
}
81-
82-
&.open-right .layout-sidebar:last-child {
83-
transform: translate3d(var(--jdd-right-sidebar-offset), 0, 0);
84-
}
85-
86-
&.open-right, &.open-left {
87-
--jdd-layout-backdrop-opacity: 1;
88-
89-
.layout-backdrop {
90-
pointer-events: all;
91-
opacity: min(1, var(--jdd-layout-backdrop-opacity));
92-
}
93-
}
94-
}
95-
96-
body.jdd-sidebar-open {
97-
overflow-y: hidden;
1+
.jdd.layout {
2+
--jdd-left-sidebar-offset: 0px;
3+
--jdd-right-sidebar-offset: 0px;
4+
--jdd-sidebar-transition: "";
5+
--jdd-layout-backdrop-opacity: 0;
6+
7+
display: flex;
8+
flex-direction: column;
9+
min-height: 100dvh;
10+
width: 100dvw;
11+
overflow-x: hidden;
12+
overflow-y: visible;
13+
14+
15+
.layout-header {
16+
order: 1;
17+
}
18+
19+
.layout-main {
20+
order: 2;
21+
flex-grow: 1;
22+
display: flex;
23+
flex-direction: row;
24+
align-items: stretch;
25+
26+
.layout-sidebar {
27+
position: sticky;
28+
top: 0;
29+
overflow-y: auto;
30+
}
31+
32+
.layout-content {
33+
flex-grow: 1;
34+
}
35+
}
36+
37+
.layout-footer {
38+
order: 3;
39+
}
40+
41+
&.mobile {
42+
.layout-main {
43+
.layout-sidebar {
44+
position: fixed;
45+
top: 0;
46+
transition: var(--jdd-sidebar-transition);
47+
z-index: 50;
48+
max-width: 90vw;
49+
}
50+
51+
.layout-sidebar:first-child {
52+
left: 0;
53+
transform: translate3d(min((calc(-100% + var(--jdd-left-sidebar-offset))), 0px), 0, 0);
54+
}
55+
56+
.layout-sidebar:last-child {
57+
right: 0;
58+
transform: translate3d(max((calc(100% - var(--jdd-right-sidebar-offset))), 0px), 0, 0);
59+
}
60+
}
61+
62+
.layout-backdrop {
63+
opacity: max(0, var(--jdd-layout-backdrop-opacity));
64+
position: fixed;
65+
transition: var(--jdd-sidebar-transition);
66+
inset: 0;
67+
background: rgba(var(--jdd-gray-15-rgb), 0.2);
68+
pointer-events: none;
69+
70+
.jdd-dark & {
71+
background: rgba(var(--jdd-gray-1-rgb), 0.15);
72+
}
73+
74+
}
75+
}
76+
}
77+
78+
.jdd.layout.mobile {
79+
&.open-left .layout-sidebar:first-child {
80+
transform: translate3d(calc(0px - var(--jdd-left-sidebar-offset)), 0, 0);
81+
}
82+
83+
&.open-right .layout-sidebar:last-child {
84+
transform: translate3d(var(--jdd-right-sidebar-offset), 0, 0);
85+
}
86+
87+
&.open-right, &.open-left {
88+
--jdd-layout-backdrop-opacity: 1;
89+
90+
.layout-backdrop {
91+
pointer-events: all;
92+
opacity: min(1, var(--jdd-layout-backdrop-opacity));
93+
}
94+
}
95+
}
96+
97+
body.jdd-sidebar-open {
98+
overflow-y: hidden;
9899
}

src/components/layout/sidebar.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,6 @@ export default function LayoutSidebar(props: LayoutSidebarProps) {
3030
local.position === "left" ? context.sidebarLeft : context.sidebarRight;
3131

3232
set(<div {...combinedProps} />);
33+
34+
return <></>;
3335
}

0 commit comments

Comments
 (0)