@@ -2,20 +2,20 @@ import { styled, Typography } from "@mui/material";
22import IconButton from "components/IconButton" ;
33import { CloseIcon } from "components/Icons" ;
44import StyledLink from "components/StyledLink" ;
5- import { useAuthContext } from "features/auth/AuthProvider" ;
65import { Trans , useTranslation } from "i18n" ;
76import { usePersistedState } from "platform/usePersistedState" ;
7+ import { useEffect , useRef } from "react" ;
88import { tosRoute } from "routes" ;
99import { useIsMounted } from "utils/hooks" ;
1010import { useIsNativeEmbed } from "utils/nativeLink" ;
1111
1212const StyledWrapper = styled ( "div" ) ( ( { theme } ) => ( {
1313 position : "fixed" ,
14+ bottom : 0 ,
15+ left : 0 ,
16+ right : 0 ,
1417 zIndex : theme . zIndex . snackbar ,
15- left : theme . spacing ( 0 ) ,
16- right : theme . spacing ( 0 ) ,
1718 backgroundColor : "var(--mui-palette-background-paper)" ,
18- bottom : 0 ,
1919 padding : theme . spacing ( 2 , 4 ) ,
2020 boxShadow : theme . shadows [ 4 ] ,
2121
@@ -28,8 +28,7 @@ const StyledWrapper = styled("div")(({ theme }) => ({
2828
2929const StyledCloseButton = styled ( IconButton ) ( ( { theme } ) => ( {
3030 position : "absolute" ,
31- top : theme . spacing ( 4 ) ,
32- transform : "translateY(-50%)" ,
31+ top : theme . spacing ( 1 ) ,
3332 right : theme . spacing ( 1 ) ,
3433} ) ) ;
3534
@@ -38,18 +37,33 @@ export default function CookieBanner() {
3837 // since we are using localStorage, make sure don't render unless mounted
3938 // or there will be hydration mismatches
4039 const isMounted = useIsMounted ( ) . current ;
41- const auth = useAuthContext ( ) ;
4240 const [ hasSeen , setHasSeen ] = usePersistedState ( "hasSeenCookieBanner" , false ) ;
4341 const isNativeEmbed = useIsNativeEmbed ( ) ;
42+ const bannerRef = useRef < HTMLDivElement > ( null ) ;
43+
44+ useEffect ( ( ) => {
45+ const el = bannerRef . current ;
46+ if ( ! el ) return ;
47+ const updateHeight = ( ) => {
48+ document . documentElement . style . setProperty (
49+ "--cookie-banner-height" ,
50+ `${ el . offsetHeight } px` ,
51+ ) ;
52+ } ;
53+ updateHeight ( ) ;
54+ const observer = new ResizeObserver ( updateHeight ) ;
55+ observer . observe ( el ) ;
56+ return ( ) => {
57+ observer . disconnect ( ) ;
58+ document . documentElement . style . removeProperty ( "--cookie-banner-height" ) ;
59+ } ;
60+ } , [ hasSeen , isMounted ] ) ;
4461
45- // Don't show cookie banner in native mobile app
46- // Mobile apps use app store privacy mechanisms, not cookie banners
47- // Only essential cookies are used (session/auth), which don't require consent
48- if ( auth . authState . authenticated || isNativeEmbed ) return null ;
62+ if ( isNativeEmbed ) return null ;
4963
5064 //specifically not using our snackbar, which is designed for alerts
5165 return isMounted && ! hasSeen ? (
52- < StyledWrapper aria-live = "polite" >
66+ < StyledWrapper ref = { bannerRef } aria-live = "polite" >
5367 < StyledCloseButton
5468 aria-label = { t ( "close" ) }
5569 onClick = { ( ) => setHasSeen ( true ) }
0 commit comments