diff options
author | Anton Tananaev <anton@traccar.org> | 2022-08-06 11:40:07 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-08-06 11:40:07 -0700 |
commit | 15c780b0e08062328e3708e38f47c3361da1f345 (patch) | |
tree | 8162c6cf042ff4e6488013c92ce888fd46c90932 /modern/src/login/LogoImage.js | |
parent | 1a4086a8bbca15a5f197f2f4ead79d9dd045f251 (diff) | |
download | trackermap-web-15c780b0e08062328e3708e38f47c3361da1f345.tar.gz trackermap-web-15c780b0e08062328e3708e38f47c3361da1f345.tar.bz2 trackermap-web-15c780b0e08062328e3708e38f47c3361da1f345.zip |
Better logo handling
Diffstat (limited to 'modern/src/login/LogoImage.js')
-rw-r--r-- | modern/src/login/LogoImage.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/modern/src/login/LogoImage.js b/modern/src/login/LogoImage.js new file mode 100644 index 00000000..d3f4b1ce --- /dev/null +++ b/modern/src/login/LogoImage.js @@ -0,0 +1,42 @@ +import React, { useRef } from 'react'; +import { makeStyles } from '@mui/styles'; +import image from '../resources/images/logo.svg'; + +const useStyles = makeStyles(() => ({ + image: { + alignSelf: 'center', + maxWidth: '240px', + maxHeight: '120px', + width: 'auto', + height: 'auto', + visibility: 'hidden', + }, +})); + +const LogoImage = ({ color }) => { + const classes = useStyles(); + + const element = useRef(null); + + return ( + <object + type="image/svg+xml" + data={image} + aria-label="logo" + className={classes.image} + ref={element} + onLoad={() => { + 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; |