From 15c780b0e08062328e3708e38f47c3361da1f345 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 6 Aug 2022 11:40:07 -0700 Subject: Better logo handling --- modern/src/login/LoginLayout.js | 9 ++------- modern/src/login/LoginPage.js | 14 ++------------ modern/src/login/LogoImage.js | 42 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 19 deletions(-) create mode 100644 modern/src/login/LogoImage.js (limited to 'modern/src') diff --git a/modern/src/login/LoginLayout.js b/modern/src/login/LoginLayout.js index 83a87500..8f2ee6ca 100644 --- a/modern/src/login/LoginLayout.js +++ b/modern/src/login/LoginLayout.js @@ -2,7 +2,7 @@ import React from 'react'; import { useMediaQuery, Paper } from '@mui/material'; import makeStyles from '@mui/styles/makeStyles'; import { useTheme } from '@mui/material/styles'; -import logoSvg from '../resources/images/logo.svg'; +import LogoImage from './LogoImage'; const useStyles = makeStyles((theme) => ({ root: { @@ -13,7 +13,6 @@ const useStyles = makeStyles((theme) => ({ display: 'flex', justifyContent: 'center', alignItems: 'center', - color: theme.palette.secondary.contrastText, background: theme.palette.primary.main, paddingBottom: theme.spacing(5), width: theme.dimensions.sidebarWidth, @@ -49,11 +48,7 @@ const LoginLayout = ({ children }) => { return (
- {!useMediaQuery(theme.breakpoints.down('lg')) && ( - - - - )} + {!useMediaQuery(theme.breakpoints.down('lg')) && }
diff --git a/modern/src/login/LoginPage.js b/modern/src/login/LoginPage.js index 87192a3f..e3b5f39b 100644 --- a/modern/src/login/LoginPage.js +++ b/modern/src/login/LoginPage.js @@ -12,8 +12,8 @@ import { sessionActions } from '../store'; import { useLocalization, useTranslation } from '../common/components/LocalizationProvider'; import LoginLayout from './LoginLayout'; import usePersistedState from '../common/util/usePersistedState'; -import logoSvg from '../resources/images/logo.svg'; import { nativePostMessage } from '../common/components/NativeInterface'; +import LogoImage from './LogoImage'; const useStyles = makeStyles((theme) => ({ options: { @@ -26,10 +26,6 @@ const useStyles = makeStyles((theme) => ({ flexDirection: 'column', gap: theme.spacing(2), }, - logoContainer: { - textAlign: 'center', - color: theme.palette.primary.main, - }, extraContainer: { display: 'flex', gap: theme.spacing(2), @@ -105,13 +101,7 @@ const LoginPage = () => { )}
- {useMediaQuery(theme.breakpoints.down('lg')) && ( -
- - - -
- )} + {useMediaQuery(theme.breakpoints.down('lg')) && } ({ + image: { + alignSelf: 'center', + maxWidth: '240px', + maxHeight: '120px', + width: 'auto', + height: 'auto', + visibility: 'hidden', + }, +})); + +const LogoImage = ({ color }) => { + const classes = useStyles(); + + const element = useRef(null); + + return ( + { + const imageDocument = element.current.contentDocument; + imageDocument.querySelectorAll('svg').forEach((element) => { + const style = imageDocument.createElement('style'); + style.appendChild(imageDocument.createTextNode(`g { color: ${color}; }`)); + element.insertAdjacentElement('afterbegin', style); + element.innerHTML += ''; + }); + element.current.style.visibility = 'visible'; + }} + /> + ); +}; + +export default LogoImage; -- cgit v1.2.3