aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/frontend/src/WindowControlsOverlayColor.tsx
blob: cfa468eaf1af8609d0d0b09d8e0fe9d350e418dc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
 * SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/>
 *
 * SPDX-License-Identifier: EPL-2.0
 */

import { useTheme } from '@mui/material/styles';
import { useEffect } from 'react';

export default function WindowControlsOverlayColor(): null {
  const {
    palette: {
      outer: { background },
    },
  } = useTheme();
  useEffect(() => {
    document.head
      .querySelectorAll('meta[name="theme-color"]')
      .forEach((meta) => meta.remove());
    const meta = document.createElement('meta');
    meta.name = 'theme-color';
    meta.content = background;
    document.head.appendChild(meta);
  }, [background]);

  return null;
}