move theme code to own file

This commit is contained in:
Vinzenz Schroeter 2024-04-14 13:32:34 +02:00
commit 52e09ae5ef

View file

@ -2,23 +2,10 @@ import React from 'react';
import {createRoot} from 'react-dom/client';
import './index.css';
import App from "./App.tsx";
import {setRandomTheme} from "./theme.ts";
function getRandomColor() {
const letters = '0123456789ABCDEF';
let color = '#';
for (let i = 0; i < 3; i++) {
color += letters[Math.floor(Math.random() * letters.length)];
}
return color;
}
// @ts-ignore
const rootStyle = document.querySelector(':root')?.style;
if (rootStyle) {
rootStyle.setProperty('--color-primary', getRandomColor());
rootStyle.setProperty('--color-secondary', getRandomColor());
rootStyle.setProperty('--color-background', getRandomColor());
}
setRandomTheme();
createRoot(document.getElementById('root')!).render(
<React.StrictMode>