INCREMENET/DECREMENET APP(REACT CHALLENEG#9) BY THAPA






 INDEX.JS



//Current Time & date using react
// const date = new Date().toLocaleDateString();
// const currTime = new Date().toLocaleTimeString();

// ReactDOM.render(
// <>
// <h1> The Current time is {currTime} </h1>
// <p> The Current Date is {date}</p>
// </>, document.getElementById("root")
// );


//inline css

// const name = "Himanshu";
// const img1= "https://picsum.photos/id/237/200/300";
// const heading = {
// color : "aquamarine",
// fontWeight : "bold",
// textAlign:"center"

// }


// ReactDOM.render(
// <>
// <h1 style={heading}> My name is {name}</h1>
// <img src ={img1} alt="boss" />
// </>, document.getElementById("root")
// );
import React from 'react'
import ReactDOM from 'react-dom';
import "./index.css";
import App from "./App";
import ToDoLists from "./ToDoLists"

ReactDOM.render(<ToDoLists/>, document.getElementById("root"));


ToDoLists.jsx

import React, { useState } from 'react';

const ToDoLists =()=>{

const [num,setNum] = useState(0);

const incNum =()=>{
setNum(num+1);
};

const decNum=()=>{
if(num>0){
setNum(num-1);}
else{
setNum(0);
alert("Sorry Boss");
}

}


return (
<>
<div className = 'main_div'>
<div className = 'center_div'>
<h1> {num}</h1>

<div className='btn_div'>

<button onClick={incNum}>Increm</button>
<button onClick={decNum}>Decrem</button>
</div>
</div>


</div>
</>
)

};

export default ToDoLists;

index.css

.main_div{
width: 100%;
height: 100vh;
background-color:#badc58;
display: flex;
flex-direction: row ;
justify-content: center;
align-items: center;

}



.center_div{
width: 25%;
height: 60vh;
background-color:#f4f4f4;
box-shadow: 5px 5px 25px -5px rgba(0,0,0,0.5);
border-radius: 15px;
display: flex;
flex-direction: column ;
justify-content: center;
align-items: center;
}

h1{
color: white;
background: transparent;
font-size: 50px;
background-color: #3033cb;
padding: 6px 0 2px 0;
margin-bottom: 10px;
width: 100%;
box-shadow: 5px 5px 15px -5px rgba(0,0,0,0.3);
text-align: center;

}

button{
min-height: 40px;
border-radius: 5%;
border-color: transparent;
background-color: #3033cb;
color:#fff;
font-size: 20px;
border: none;
outline: none;
padding: 0 15px;
margin-top: 30px;
box-shadow: 5px 5px 15px -5px rgba(0,0,0,0.3);
}

button:hover{
background-color: #22a6b3;

}

.btn_div{
width: 100%;
display: flex;
justify-content: space-around;
align-items: center;

}


GG

Comments

Popular posts from this blog

Form Part 2

Event mini project by Thapa#33

De-mystifying 'this' keyword of Javascript