Урок 2 делали
This commit is contained in:
+29
-14
@@ -1,7 +1,9 @@
|
||||
import styles from './App.module.scss'
|
||||
import SneakersImage from './assets/images/sneakers-image.jpg'
|
||||
import { FaRegUser } from 'react-icons/fa'
|
||||
import React from 'react'
|
||||
import { FaHeart } from "react-icons/fa";
|
||||
import { BsCheckSquare } from "react-icons/bs";
|
||||
import { useState } from 'react'
|
||||
|
||||
function Header() {
|
||||
const handleChange = event => {
|
||||
@@ -24,26 +26,39 @@ function Header() {
|
||||
}
|
||||
|
||||
function Product() {
|
||||
function handleClick() {
|
||||
function LikeCounter() {
|
||||
const [likes,setLikes] = useState(0);
|
||||
return (
|
||||
<>
|
||||
<h2>Лайков: {likes}</h2>
|
||||
{likes < 10 && <button onClick={() => setLikes(likes + 1)}>👍 Лайк</button>}
|
||||
{likes > 0 && <button onClick={() => setLikes(0)}>🔄 Сбросить</button> }
|
||||
{likes >= 10 && <h3>Вы достигли лимита!</h3>}
|
||||
<div className={styles.progress}>
|
||||
<div className={styles.value}></div>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
function handleClick() {
|
||||
console.log('Working!')
|
||||
}
|
||||
|
||||
function Counter() {
|
||||
const [title,setTitle] = React.useState('');
|
||||
const [titleValue,setTitleValue] = React.useState({
|
||||
title:'',
|
||||
});
|
||||
const [isLiked,setIsLiked] = useState(false);
|
||||
|
||||
console.log(titleValue);
|
||||
const toggleLike = () => {
|
||||
setIsLiked(!isLiked);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<input
|
||||
value={title}
|
||||
type="text"
|
||||
onChange={e => setTitle(e.target.value)}
|
||||
/>
|
||||
<button onClick={setTitleValue(title)}>Установить заголовок</button>
|
||||
<BsCheckSquare
|
||||
onClick={toggleLike}
|
||||
fill={isLiked==true ? 'red' : 'grey'}
|
||||
size={44}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -59,7 +74,7 @@ function Product() {
|
||||
<p className={styles.description}>NIKE</p>
|
||||
<p className={styles.price}>$38.00</p>
|
||||
</div>
|
||||
<Counter />
|
||||
<LikeCounter />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
@use './assets/styles/variables' as *;
|
||||
|
||||
.progress {
|
||||
width: 100%;
|
||||
height: 10px;
|
||||
border: 1px solid black;
|
||||
|
||||
}
|
||||
.value {
|
||||
width:70%;
|
||||
height: 100%;
|
||||
background-color: green;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
Reference in New Issue
Block a user