File tree Expand file tree Collapse file tree 6 files changed +27
-9
lines changed Expand file tree Collapse file tree 6 files changed +27
-9
lines changed Original file line number Diff line number Diff line change
1
+ import { Outlet , ScrollRestoration } from "react-router-dom" ;
2
+
3
+ export const Layout = ( ) => {
4
+ return (
5
+ < div >
6
+ < Outlet />
7
+ < ScrollRestoration />
8
+ </ div >
9
+ ) ;
10
+ } ;
Original file line number Diff line number Diff line change 1
1
import { createBrowserRouter , RouterProvider } from "react-router-dom" ;
2
2
import { ItemsIndex } from "../pages/items" ;
3
3
import { ItemsShow } from "../pages/items/show" ;
4
+ import { Layout } from "./Layout" ;
4
5
5
6
const router = createBrowserRouter ( [
6
7
{
7
8
path : "/" ,
8
- element : < ItemsIndex /> ,
9
- } ,
10
- {
11
- path : "/items/:id" ,
12
- element : < ItemsShow /> ,
9
+ element : < Layout /> ,
10
+ children : [
11
+ {
12
+ index : true ,
13
+ element : < ItemsIndex /> ,
14
+ } ,
15
+ {
16
+ path : "/items/:id" ,
17
+ element : < ItemsShow /> ,
18
+ } ,
19
+ ] ,
13
20
} ,
14
21
] ) ;
15
22
Original file line number Diff line number Diff line change @@ -694,6 +694,8 @@ const closedSidebarStyle = css({
694
694
justifyContent : "space-between" ,
695
695
maxWidth : 48 ,
696
696
padding : `${ getSpace ( 1 ) } px ${ getSpace ( 1 / 2 ) } px ${ getSpace ( 2 ) } px` ,
697
+ position : "sticky" ,
698
+ top : 0 ,
697
699
698
700
...viewport . S ( {
699
701
display : "none" ,
Original file line number Diff line number Diff line change @@ -11,7 +11,5 @@ export const Contents = ({ children }: Props) => {
11
11
12
12
const contentsStyle = css ( {
13
13
gridArea : "contents" ,
14
- height : "100vh" ,
15
- overflowX : "auto" ,
16
14
width : "100%" ,
17
15
} ) ;
Original file line number Diff line number Diff line change @@ -18,9 +18,8 @@ const mainStyle = css({
18
18
"sidebar contents"
19
19
` ,
20
20
gridTemplateColumns : "auto minmax(450px, 1fr)" ,
21
- height : "100vh" ,
22
21
23
22
...viewport . S ( {
24
- gridTemplateColumns : "auto 1fr" ,
23
+ gridTemplateColumns : "auto minmax(0, 1fr)" , // Setting min width to prevent widening
25
24
} ) ,
26
25
} ) ;
Original file line number Diff line number Diff line change @@ -14,4 +14,6 @@ export const Sidebar = ({ children }: Props) => {
14
14
const sidebarStyle = css ( {
15
15
backgroundColor : Colors . gray0 ,
16
16
gridArea : "sidebar" ,
17
+ position : "sticky" ,
18
+ zIndex : 1 ,
17
19
} ) ;
You can’t perform that action at this time.
0 commit comments