fix(mobile): support a dynamic mobile browser theme color
This commit is contained in:
parent
2c5949fecc
commit
630a5bf782
@ -95,7 +95,6 @@ export const Main: FC = () => {
|
|||||||
<link rel="authorization_endpoint" href="/api/auth/provider/indieauth" />
|
<link rel="authorization_endpoint" href="/api/auth/provider/indieauth" />
|
||||||
<meta name="msapplication-TileColor" content="#ffffff" />
|
<meta name="msapplication-TileColor" content="#ffffff" />
|
||||||
<meta name="msapplication-TileImage" content="/img/favicon/ms-icon-144x144.png" />
|
<meta name="msapplication-TileImage" content="/img/favicon/ms-icon-144x144.png" />
|
||||||
<meta name="theme-color" content="#ffffff" />
|
|
||||||
<meta
|
<meta
|
||||||
name="viewport"
|
name="viewport"
|
||||||
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
|
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* eslint-disable react/no-danger */
|
/* eslint-disable react/no-danger */
|
||||||
import { FC } from 'react';
|
import Head from 'next/head';
|
||||||
|
import { FC, useEffect, useState } from 'react';
|
||||||
import { useRecoilValue } from 'recoil';
|
import { useRecoilValue } from 'recoil';
|
||||||
import { ClientConfig } from '../../interfaces/client-config.model';
|
import { ClientConfig } from '../../interfaces/client-config.model';
|
||||||
import { clientConfigStateAtom } from '../stores/ClientConfigStore';
|
import { clientConfigStateAtom } from '../stores/ClientConfigStore';
|
||||||
@ -12,16 +13,30 @@ export const Theme: FC = () => {
|
|||||||
.filter(variable => !!appearanceVariables[variable])
|
.filter(variable => !!appearanceVariables[variable])
|
||||||
.map(variable => `--${variable}: ${appearanceVariables[variable]}`);
|
.map(variable => `--${variable}: ${appearanceVariables[variable]}`);
|
||||||
|
|
||||||
|
const [themeColor, setThemeColor] = useState('#fff');
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const color = getComputedStyle(document.documentElement).getPropertyValue(
|
||||||
|
'--theme-color-background-header',
|
||||||
|
);
|
||||||
|
setThemeColor(color);
|
||||||
|
}, [appearanceVars]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<style
|
<>
|
||||||
dangerouslySetInnerHTML={{
|
<Head>
|
||||||
__html: `
|
<meta name="theme-color" content={themeColor} />
|
||||||
|
</Head>
|
||||||
|
<style
|
||||||
|
dangerouslySetInnerHTML={{
|
||||||
|
__html: `
|
||||||
:root {
|
:root {
|
||||||
${appearanceVars.join(';\n')}
|
${appearanceVars.join(';\n')}
|
||||||
}
|
}
|
||||||
${customStyles}
|
${customStyles}
|
||||||
`,
|
`,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user