From 87e94ea6f3bbd84d4e9e0415f230e33f7ef6e884 Mon Sep 17 00:00:00 2001 From: victorAnumudu Date: Sat, 8 Apr 2023 00:40:47 +0100 Subject: [PATCH] added a function to change bg color --- src/app/modules/auth/AuthLayout.tsx | 43 ++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/src/app/modules/auth/AuthLayout.tsx b/src/app/modules/auth/AuthLayout.tsx index 99639fa..34d9492 100644 --- a/src/app/modules/auth/AuthLayout.tsx +++ b/src/app/modules/auth/AuthLayout.tsx @@ -1,10 +1,44 @@ /* eslint-disable jsx-a11y/anchor-is-valid */ -import {useEffect} from 'react' +import {useEffect, useState} from 'react' import {Outlet, Link} from 'react-router-dom' import {toAbsoluteUrl} from '../../../_res/helpers' const AuthLayout = () => { + + // INITIAL STATE FOR BACKGROUND IMAGE + let [bgImage, setBgImage] = useState({ + filter: 'grayscale(0%)' + }) + + // FUNCTION TO CHANGE BACKGROUND IMAGE + let changeBg = () => { + // let randomNum = Math.round(Math.random() * 3) + let randomNum = Number(localStorage.getItem('bg-num')) + if(randomNum){ + if(randomNum <= 1){ + setBgImage({ + filter: 'grayscale(0%)' + }) + localStorage.setItem('bg-num', '2') + }else if(randomNum <= 2){ + setBgImage({ + // filter: 'hue-rotate(90deg)' + filter: 'grayscale(100%)' + }) + localStorage.setItem('bg-num', '3') + }else{ + setBgImage({ + filter: 'sepia(50%)' + }) + localStorage.setItem('bg-num', '1') + } + }else{ + localStorage.setItem('bg-num', '2') + } + } + useEffect(() => { + changeBg() // FUNCTION TO CHANGE BACKGROUND IMAGE const root = document.getElementById('root') if (root) { root.style.height = '100%' @@ -16,10 +50,11 @@ const AuthLayout = () => { } }, []) - return ( -
+ return ( +
+ {/* begin::Body */} -
+
{/* begin::Form */}
{/* begin::Wrapper */}