Compare commits

..

1 Commits

Author SHA1 Message Date
laktionov-as de33066cbe Практика 2026-06-11 20:13:10 +03:00
9 changed files with 63 additions and 220 deletions
-13
View File
@@ -5,19 +5,6 @@
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<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>
<body>
<div id="root"></div>
+11 -11
View File
@@ -8,6 +8,7 @@
"name": "store-client",
"version": "0.0.0",
"dependencies": {
"immer": "^11.1.8",
"react": "^19.1.0",
"react-dom": "^19.1.0"
},
@@ -20,7 +21,6 @@
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.19",
"globals": "^16.0.0",
"react-icons": "^5.6.0",
"vite": "^6.3.5"
}
},
@@ -2055,6 +2055,16 @@
"node": ">= 4"
}
},
"node_modules/immer": {
"version": "11.1.8",
"resolved": "https://registry.npmjs.org/immer/-/immer-11.1.8.tgz",
"integrity": "sha512-/tbkHMW7y10Lx6i1crLjD4/OhNkRG+Fo7byZHtah0547nIeXYcpIXaUh0IAQY6gO5459qpGGYapcEOHtFXkIuA==",
"license": "MIT",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/immer"
}
},
"node_modules/import-fresh": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz",
@@ -2462,16 +2472,6 @@
"react": "^19.1.0"
}
},
"node_modules/react-icons": {
"version": "5.6.0",
"resolved": "https://registry.npmjs.org/react-icons/-/react-icons-5.6.0.tgz",
"integrity": "sha512-RH93p5ki6LfOiIt0UtDyNg/cee+HLVR6cHHtW3wALfo+eOHTp8RnU2kRkI6E+H19zMIs03DyxUG/GfZMOGvmiA==",
"dev": true,
"license": "MIT",
"peerDependencies": {
"react": "*"
}
},
"node_modules/react-refresh": {
"version": "0.17.0",
"resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.17.0.tgz",
+1 -1
View File
@@ -10,6 +10,7 @@
"preview": "vite preview"
},
"dependencies": {
"immer": "^11.1.8",
"react": "^19.1.0",
"react-dom": "^19.1.0"
},
@@ -22,7 +23,6 @@
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.19",
"globals": "^16.0.0",
"react-icons": "^5.6.0",
"vite": "^6.3.5"
}
}
+41 -64
View File
@@ -1,72 +1,49 @@
import styles from './App.module.css'
import SneakersImage from './assets/images/sneakers-image.jpg'
import { FaRegUser } from 'react-icons/fa'
function handleClick(i) {
console.log(i);
}
function Header() {
const handleChange = event => {
const newValue = event.target.value;
console.log(`Новое значение ${newValue}`);
}
return (
<header className={styles.header}>
<div>
<h2>Store</h2>
<input type='text ' placeholder='Search...' onChange={handleChange} />
</div>
<div>
<FaRegUser size={24} color='#3258e3' />
<button>Profile</button>
</div>
</header>
)
}
function Product() {
const handlerMouseEnter = event => {
const img = event.target;
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>
)
}
import React, { useState, useEffect } from 'react'
import { produce } from 'immer'
function App() {
const [tasks,setTasks] = useState([])
const [input,setInput] = useState('')
const addTask = () => {
if(!input.trim()) return
setTasks(currentTasks => produce(currentTasks, draft => {
draft.push({
id: Date.now(),
text: input.trim(),
done: false
})
}))
setInput('')
}
const toggleTask = id => {
setTasks(currentTask => produce(currentTask, draft => {
const task = draft.find(t => t.id === id)
if(task) {
task.done = !task.done
}
}))
}
const removeTask = id => {
setTasks(currentTask => produce(currentTask, draft => {
const index = draft.findIndex(t => t.id === id)
if (index !== -1)
draft.splice(index,1)
}))
}
return (
<>
<div className={styles.container}>
<Header />
<ul className={styles.list}>
<li>
<Product />
<h1>Практика по созданию списка задач</h1>
<input value={input} onChange={e=>setInput(e.target.value)} />
<button onClick={addTask}>Добавить</button>
<ul>{tasks.map(({id,text,done}) => (
<li key={id} style={{ textDecoration: done ? 'line-through' : 'none'}}>
<input type="checkbox" checked={done} onChange={()=> toggleTask(id)} />
{text}
<button onClick={() => removeTask(id)}>Удалить</button>
</li>
<li>
<Product />
</li>
<li>
<Product />
</li>
</ul>
</div>
))}</ul>
</>
)
}
-123
View File
@@ -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;
}
+8
View File
@@ -0,0 +1,8 @@
export function MyComponent() {
return (
<>
<h1>Hello</h1>
</>
)
}
export default MyComponent
Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

-5
View File
@@ -1,5 +0,0 @@
$white-color: white;
$black-color: black;
$primary-color: #3258e3;
$seconday-color: #4432e3;
+1 -2
View File
@@ -1,9 +1,8 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
// удаляем import './index.css'
import App from './App.jsx'
createRoot(document.getElementById('root')).render(
<StrictMode>
<App />
</StrictMode>
)