random color on launch, dynamic map color
This commit is contained in:
parent
cd3c054ee8
commit
44b66c37fc
1 changed files with 30 additions and 4 deletions
|
|
@ -3,6 +3,22 @@ import {createRoot} from 'react-dom/client';
|
|||
import './index.css';
|
||||
import App from "./App.tsx";
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
createRoot(document.getElementById('root')!).render(
|
||||
<React.StrictMode>
|
||||
|
|
|
|||
Reference in a new issue