diff --git a/packages/extension/src/index.tsx b/packages/extension/src/index.tsx index f3587658a8..bb19c2cb5c 100644 --- a/packages/extension/src/index.tsx +++ b/packages/extension/src/index.tsx @@ -245,142 +245,144 @@ const RoutesAfterReady: FunctionComponent = observer(() => { return true; })(); + const shouldUnlockPage = keyRingStore.status === "locked" && !isURLUnlockPage; + return ( {isReady ? ( - keyRingStore.status === "locked" && !isURLUnlockPage ? ( + shouldUnlockPage ? ( ) : ( - - - } /> - } /> - } /> - } - /> - } /> - } /> - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - } /> - } /> - } - /> - } - /> - } /> - } /> - } /> - } - /> - } - /> - } /> - } /> - - - - + + } /> + } /> + } /> + } + /> + } /> + } /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } /> + } + /> + } /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } /> + } /> + } + /> + } /> + } /> + } /> + } /> + } + /> + } + /> + } /> + } /> + ) ) : ( )} + ); }); -const LightModeBackground: FunctionComponent = () => { +const LightModeBackground: FunctionComponent<{ + isReady: boolean; + shouldUnlockPage: boolean; +}> = ({ isReady, shouldUnlockPage }) => { const theme = useTheme(); const location = useLocation(); useLayoutEffect(() => { - if ( - location.pathname.startsWith("/setting") || - location.pathname.startsWith("/send") - ) { - document.body.setAttribute("data-white-background", "true"); - - return () => { - document.body.removeAttribute("data-white-background"); - }; + if (isReady && !shouldUnlockPage) { + if ( + location.pathname === "/setting" || + location.pathname.startsWith("/setting/") || + location.pathname === "/send" || + location.pathname.startsWith("/send/") + ) { + document.documentElement.setAttribute("data-white-background", "true"); + document.body.setAttribute("data-white-background", "true"); + + return () => { + document.documentElement.removeAttribute("data-white-background"); + document.body.removeAttribute("data-white-background"); + }; + } } - }, [location.pathname, theme]); + }, [location.pathname, theme, isReady, shouldUnlockPage]); return null; }; diff --git a/packages/extension/src/layouts/header/header.tsx b/packages/extension/src/layouts/header/header.tsx index 323e3e46f7..4431ded93a 100644 --- a/packages/extension/src/layouts/header/header.tsx +++ b/packages/extension/src/layouts/header/header.tsx @@ -10,7 +10,6 @@ import { SpecialButton, getSpecialButtonHeightRem, } from "../../components/special-button"; -import { useLocation } from "react-router-dom"; const pxToRem = (px: number) => { const base = parseFloat( @@ -23,16 +22,21 @@ const bottomButtonPaddingRem = 0.75; const Styles = { Container: styled.div``, - HeaderContainer: styled.div<{ path?: string }>` + HeaderContainer: styled.div` height: 3.75rem; background: ${(props) => props.theme.mode === "light" - ? props.path?.startsWith("/setting") || props.path?.startsWith("/send") - ? ColorPalette.white - : ColorPalette["light-gradient"] + ? ColorPalette["light-gradient"] : ColorPalette["gray-700"]}; + body[data-white-background="true"] & { + background: ${(props) => + props.theme.mode === "light" + ? ColorPalette["white"] + : ColorPalette["gray-700"]}; + } + color: ${(props) => props.theme.mode === "light" ? ColorPalette["gray-400"] @@ -134,7 +138,6 @@ export const HeaderLayout: FunctionComponent = ({ }) => { const [height, setHeight] = React.useState(() => pxToRem(600)); const lastSetHeight = useRef(-1); - const location = useLocation(); useLayoutEffect(() => { function handleResize() { @@ -175,7 +178,7 @@ export const HeaderLayout: FunctionComponent = ({ return ( - + {left && !isNotReady ? ( {left} ) : null}