move theme code to own file
This commit is contained in:
parent
44b66c37fc
commit
52e09ae5ef
1 changed files with 50 additions and 21 deletions
|
|
@ -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>
|
||||
|
|
|
|||
Reference in a new issue