Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c168c96820 | |||
| b70fa47bbc | |||
| bd35029fc1 | |||
| 92dc5df96b | |||
| 3d34262203 | |||
| 1bc2e883a1 | |||
| 8a8a17f44d | |||
| 8f46470a26 |
-13
@@ -5,19 +5,6 @@
|
|||||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Vite + React</title>
|
<title>Vite + React</title>
|
||||||
<style>
|
|
||||||
* {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
box-sizing: border-box;
|
|
||||||
|
|
||||||
font-family: Arial, Helvetica, sans-serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
background-color: #ecfeff;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
|||||||
Generated
+1257
-20
File diff suppressed because it is too large
Load Diff
+4
-2
@@ -10,9 +10,9 @@
|
|||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"info": "^1.0.0",
|
||||||
"react": "^19.1.0",
|
"react": "^19.1.0",
|
||||||
"react-dom": "^19.1.0",
|
"react-dom": "^19.1.0"
|
||||||
"react-icons": "^5.6.0"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.25.0",
|
"@eslint/js": "^9.25.0",
|
||||||
@@ -23,6 +23,8 @@
|
|||||||
"eslint-plugin-react-hooks": "^5.2.0",
|
"eslint-plugin-react-hooks": "^5.2.0",
|
||||||
"eslint-plugin-react-refresh": "^0.4.19",
|
"eslint-plugin-react-refresh": "^0.4.19",
|
||||||
"globals": "^16.0.0",
|
"globals": "^16.0.0",
|
||||||
|
"sass": "^1.99.0",
|
||||||
|
"sass-embedded": "^1.99.0",
|
||||||
"vite": "^6.3.5"
|
"vite": "^6.3.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-60
@@ -1,72 +1,29 @@
|
|||||||
import styles from './App.module.css'
|
import styles from './styles/App.module.scss'
|
||||||
import SneakersImage from './assets/images/sneakers-image.jpg'
|
import React, { useState, useCallback } from 'react'
|
||||||
import { FaRegUser } from 'react-icons/fa'
|
|
||||||
|
|
||||||
function handleClick(i) {
|
function CounterButton({label, onClick}) {
|
||||||
console.log(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
function Header() {
|
|
||||||
const handleChange = event => {
|
|
||||||
const newValue = event.target.value;
|
|
||||||
console.log(`Новое значение ${newValue}`);
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<header className={styles.header}>
|
<button onClick={onClick} className={styles.counter_button}>{label}</button>
|
||||||
<div>
|
|
||||||
<h2>Store</h2>
|
|
||||||
<input type='text ' placeholder='Search...' onChange={handleChange} />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<FaRegUser size={24} color='#3258e3' />
|
|
||||||
<button>Profile</button>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
function CounterDisplay({value}) {
|
||||||
function Product() {
|
return (<div className={styles.counter_display}>
|
||||||
const handlerMouseEnter = event => {
|
Значение счетчика: <b>{value}</b>
|
||||||
const img = event.target;
|
</div>)
|
||||||
img.style.border = '5px solid yellow';
|
|
||||||
}
|
|
||||||
const handlerMouseOut = event => {
|
|
||||||
const img = event.target;
|
|
||||||
img.style.border = '';
|
|
||||||
console.log(event);
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<div className={styles.product}>
|
|
||||||
<img src={SneakersImage} alt='' onMouseEnter={handlerMouseEnter} onMouseOut={handlerMouseOut} />
|
|
||||||
<div className={styles.content}>
|
|
||||||
<div className={styles.title}>
|
|
||||||
<h4>Sneakers Red & White 2025</h4>
|
|
||||||
<button onClick={() => handleClick(0)} onMouseEnter={handlerMouseEnter} onMouseOut={handlerMouseOut}>+</button>
|
|
||||||
</div>
|
|
||||||
<p className={styles.description}>NIKE</p>
|
|
||||||
<p className={styles.price}>$38.00</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
|
const [counter,setCounter] = useState(0);
|
||||||
|
|
||||||
|
const increment = () => setCounter(prev => prev + 1);
|
||||||
|
const decrement = () => setCounter(prev => prev - 1);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={styles.container}>
|
<h2>Практика по созданию счетчика с колбэками</h2>
|
||||||
<Header />
|
<CounterButton label="Увеличить" onClick={increment} />
|
||||||
<ul className={styles.list}>
|
<CounterButton label="уменьшить" onClick={decrement} />
|
||||||
<li>
|
<CounterDisplay value={counter} />
|
||||||
<Product />
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<Product />
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<Product />
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,123 +0,0 @@
|
|||||||
@use './assets/styles/variables' as *;
|
|
||||||
|
|
||||||
.header {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
padding: 20px;
|
|
||||||
background-color: white;
|
|
||||||
|
|
||||||
border-bottom-left-radius: 10px;
|
|
||||||
border-bottom-right-radius: 10px;
|
|
||||||
|
|
||||||
div {
|
|
||||||
&:first-child {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 20px;
|
|
||||||
|
|
||||||
h2 {
|
|
||||||
color: $primary-color;
|
|
||||||
}
|
|
||||||
|
|
||||||
input {
|
|
||||||
border-radius: 5px;
|
|
||||||
outline: none;
|
|
||||||
font-size: 16px;
|
|
||||||
border: 1px solid gainsboro;
|
|
||||||
padding: 5px 10px;
|
|
||||||
|
|
||||||
&:focus {
|
|
||||||
border: 1px solid $primary-color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&:last-child {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 10px;
|
|
||||||
|
|
||||||
button {
|
|
||||||
outline: 0;
|
|
||||||
border: 0;
|
|
||||||
border-radius: 5px;
|
|
||||||
padding: 5px 15px;
|
|
||||||
font-size: 16px;
|
|
||||||
background-color: $primary-color;
|
|
||||||
color: $white-color;
|
|
||||||
font-weight: 600;
|
|
||||||
cursor: pointer;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background-color: $seconday-color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.container {
|
|
||||||
max-width: 1220px;
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.list {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
border-radius: 10px;
|
|
||||||
margin-top: 100px; /* временно */
|
|
||||||
padding: 20px;
|
|
||||||
background-color: white;
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.product {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
width: 350px;
|
|
||||||
gap: 20px;
|
|
||||||
border-radius: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.title {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
h4 {
|
|
||||||
font-size: 18px;
|
|
||||||
}
|
|
||||||
|
|
||||||
button {
|
|
||||||
background-color: black;
|
|
||||||
color: white;
|
|
||||||
border: 0;
|
|
||||||
border-radius: 50%;
|
|
||||||
outline: 0;
|
|
||||||
|
|
||||||
font-size: 20px;
|
|
||||||
padding: 5px 10px;
|
|
||||||
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
img {
|
|
||||||
border-radius: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.description {
|
|
||||||
color: gray;
|
|
||||||
}
|
|
||||||
|
|
||||||
.price {
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 23 KiB |
@@ -1,5 +1,6 @@
|
|||||||
import { StrictMode } from 'react'
|
import { StrictMode } from 'react'
|
||||||
import { createRoot } from 'react-dom/client'
|
import { createRoot } from 'react-dom/client'
|
||||||
|
|
||||||
import App from './App.jsx'
|
import App from './App.jsx'
|
||||||
|
|
||||||
createRoot(document.getElementById('root')).render(
|
createRoot(document.getElementById('root')).render(
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
.container {
|
||||||
|
display:flex;
|
||||||
|
flex-direction: row;
|
||||||
|
border: 1px solid black;
|
||||||
|
border-radius: 5px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
p {
|
||||||
|
padding: 5px 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.counter {
|
||||||
|
&_display{
|
||||||
|
border: 1px solid black;
|
||||||
|
border-width: 3px;
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 10px;
|
||||||
|
width: 300px;
|
||||||
|
}
|
||||||
|
&_button{
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user