File tree Expand file tree Collapse file tree 6 files changed +50
-21
lines changed
components/Hooks/useStateHook Expand file tree Collapse file tree 6 files changed +50
-21
lines changed Original file line number Diff line number Diff line change 1
1
// COMPONENTS
2
2
import Greeting from "./components/Basics/Greeting" ;
3
3
import Counter from "./components/Hooks/useStateHook/Counter" ;
4
- //import CounterEffect from "./components/Hooks/useEffectHook/Counter1";
5
4
import Form from "./project/Form" ;
6
5
import ThemeToggler from "./project/ThemeToggler" ;
7
6
import HandlingForm from "./components/Hooks/useRefHook/HandlingForm" ;
8
-
9
7
// TRY IT YOURSELF COMPONENTS
10
8
import FormDetails from "./tryityourself/Akash/FormDetails" ;
9
+ import RandomBackground from "./tryityourself/Akash/RandomBackground" ;
11
10
12
11
const App = ( ) => {
13
- return < FormDetails /> ;
12
+ return < RandomBackground /> ;
14
13
} ;
15
14
16
- export default App ;
15
+ export default App ;
Original file line number Diff line number Diff line change 1
- import React from ' react'
2
- import { useState } from ' react'
1
+ import React from " react" ;
2
+ import { useState } from " react" ;
3
3
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" ) ;
12
11
return (
13
12
< 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 >
17
16
</ div >
18
- )
19
- }
17
+ ) ;
18
+ } ;
20
19
21
- export default Counter ;
20
+ export default Counter ;
Original file line number Diff line number Diff line change 1
1
@import "tailwindcss" ;
2
2
@import "./components/Hooks/useRefHook/HandlingForm.style.css" ;
3
3
@import "./tryityourself/Akash/FormDetails.style.css" ;
4
+ @import "./tryityourself/Akash/RandomBackground.style.css" ;
Original file line number Diff line number Diff line change @@ -92,7 +92,8 @@ const FormDetails = () => {
92
92
< div className = "background" >
93
93
< form className = "form" >
94
94
< 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 >
96
97
</ h1 >
97
98
< label className = "labell" onClick = { handleGuideMeName } >
98
99
Full Name :
Original file line number Diff line number Diff line change
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 ;
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments