File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
site/src/components/WorkspacesButton Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { type ReactNode } from "react" ;
2
+ import { type SystemStyleObject } from "@mui/system" ;
3
+ import Box from "@mui/system/Box" ;
4
+
5
+ type Props = {
6
+ children : ReactNode ;
7
+ height ?: number ;
8
+ maxHeight ?: number ;
9
+ sx ?: SystemStyleObject ;
10
+ } ;
11
+
12
+ export function OverflowY ( { children, height, maxHeight, sx } : Props ) {
13
+ const computedHeight = height === undefined ? "100%" : `${ height } px` ;
14
+
15
+ // Doing Math.max check to catch cases where height is accidentally larger
16
+ // than maxHeight
17
+ const computedMaxHeight =
18
+ maxHeight === undefined
19
+ ? computedHeight
20
+ : `${ Math . max ( height ?? 0 , maxHeight ) } px` ;
21
+
22
+ return (
23
+ < Box
24
+ sx = { {
25
+ width : "100%" ,
26
+ height : computedHeight ,
27
+ maxHeight : computedMaxHeight ,
28
+ overflowY : "auto" ,
29
+ ...sx ,
30
+ } }
31
+ >
32
+ { children }
33
+ </ Box >
34
+ ) ;
35
+ }
You can’t perform that action at this time.
0 commit comments