Set browser theme-color according to selected cavnas.

Add meta tag to stop google-read-aloud bot
This commit is contained in:
HF 2022-06-29 19:52:58 +02:00
parent 16da4fc4d3
commit abeeccda88
3 changed files with 22 additions and 2 deletions

View File

@ -29,6 +29,8 @@ const Html = ({
<head>
<meta charSet="utf-8" />
<meta httpEquiv="x-ua-compatible" content="ie=edge" />
<meta name="google" content="nopagereadaloud" />
<meta name="theme-color" content="#cae3ff" />
<title>{title}</title>
<meta name="description" content={description} />
<link rel="icon" href="/favicon.ico" type="image/x-icon" />

View File

@ -73,7 +73,6 @@ function generateMainPage(lang: string): string {
css={css}
// eslint-disable-next-line max-len
code={`window.ssv=JSON.parse('${JSON.stringify(ssvR)}');`}
useCaptcha
/>,
);

View File

@ -3,11 +3,26 @@
*
*/
/*
* set theme-color meta tag that sets the color
* of address bars on phones
*/
/*
* hooks for rendering
*/
import {
getRenderer,
initRenderer,
} from '../ui/renderer';
function setThemeColorMeta(r, g, b) {
const metaThemeColor = document.querySelector('meta[name=theme-color]');
if (metaThemeColor) {
metaThemeColor.setAttribute('content', `rgb(${r}, ${g}, ${b})`);
}
}
export default (store) => (next) => (action) => {
const { type } = action;
@ -48,7 +63,11 @@ export default (store) => (next) => (action) => {
case 'SELECT_CANVAS':
case 'RECEIVE_ME': {
const renderer = getRenderer();
const { is3D } = state.canvas;
const { is3D, palette } = state.canvas;
const [r, g, b] = palette.rgb;
setThemeColorMeta(r, g, b);
if (is3D === renderer.is3D) {
renderer.updateCanvasData(state);
} else {