Skip to content

Commit e942806

Browse files
authored
akash(random-background-color): all set. (#17)
2 parents 92c1e60 + c67b414 commit e942806

File tree

6 files changed

+50
-21
lines changed

6 files changed

+50
-21
lines changed

src/App.jsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
// COMPONENTS
22
import Greeting from "./components/Basics/Greeting";
33
import Counter from "./components/Hooks/useStateHook/Counter";
4-
//import CounterEffect from "./components/Hooks/useEffectHook/Counter1";
54
import Form from "./project/Form";
65
import ThemeToggler from "./project/ThemeToggler";
76
import HandlingForm from "./components/Hooks/useRefHook/HandlingForm";
8-
97
// TRY IT YOURSELF COMPONENTS
108
import FormDetails from "./tryityourself/Akash/FormDetails";
9+
import RandomBackground from "./tryityourself/Akash/RandomBackground";
1110

1211
const App = () => {
13-
return <FormDetails />;
12+
return <RandomBackground />;
1413
};
1514

16-
export default App;
15+
export default App;
Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
import React from 'react'
2-
import { useState } from 'react'
1+
import React from "react";
2+
import { useState } from "react";
33
const Counter = () => {
4-
const [count, setCount] = useState(0);
5-
6-
// let a =0;
7-
// function add (){
8-
// a =+1;
9-
// console.log(a);
10-
// }
11-
console.log("Component Rendered")
4+
const [count, setCount] = useState(0);
5+
// let a =0;
6+
// function add (){
7+
// a =+1;
8+
// console.log(a);
9+
// }
10+
console.log("Component Rendered");
1211
return (
1312
<div>
14-
<button onClick={() => setCount(count +1)}>Add</button>
15-
<h1>{count}</h1>
16-
<button onClick={() => setCount(count -1)}>Subtract</button>
13+
<button onClick={() => setCount(count + 1)}>Add</button>
14+
<h1>{count}</h1>
15+
<button onClick={() => setCount(count - 1)}>Subtract</button>
1716
</div>
18-
)
19-
}
17+
);
18+
};
2019

21-
export default Counter;
20+
export default Counter;

src/index.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
@import "tailwindcss";
22
@import "./components/Hooks/useRefHook/HandlingForm.style.css";
33
@import "./tryityourself/Akash/FormDetails.style.css";
4+
@import "./tryityourself/Akash/RandomBackground.style.css";

src/tryityourself/Akash/FormDetails.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ const FormDetails = () => {
9292
<div className="background">
9393
<form className="form">
9494
<h1 className="text-3xl text-[#B3FF00] font-semibold tracking-[.125em] pb-5 text-center relative">
95-
Register<span className="text-purple-500">!</span>
95+
Reg<span className="text-purple-500">i</span>ster
96+
<span className="text-purple-500">!</span>
9697
</h1>
9798
<label className="labell" onClick={handleGuideMeName}>
9899
Full Name :
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React, { useState, useEffect } from "react";
2+
3+
const RandomBackground = () => {
4+
const [randomSplash, setRandomSplash] = useState();
5+
6+
// FUNCTION FOR COLOR CHANGE (took help for the math.random() part)
7+
const ChangeBackground = () => {
8+
const randomColors = "#" + Math.random().toString(16).slice(2, 8);
9+
setRandomSplash(randomColors);
10+
};
11+
12+
// USE EFFECT TO CHANGE BACKGROUND AT INTERVALS (took help for implying setInterval inside useEffect )
13+
useEffect(() => {
14+
const interval = setInterval(ChangeBackground, 1500);
15+
}, []);
16+
17+
return (
18+
<div className="random-bg" style={{ backgroundColor: randomSplash }}>
19+
<div className="text">Random Background Color</div>
20+
</div>
21+
);
22+
};
23+
export default RandomBackground;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.random-bg {
2+
@apply h-screen flex justify-center items-center;
3+
}
4+
.text {
5+
@apply w-[500px] h-[100px] flex justify-center items-center p-2 text-3xl font-semibold text-white border-[2.5px] border-white rounded-full bg-gray-950 shadow-xl shadow-black;
6+
}

0 commit comments

Comments
 (0)