Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 50265b1454 | |||
| 80fd4ed7cc | |||
| 91a6340078 | |||
| 102da1ad75 | |||
| a84b1972e7 | |||
| 2ba1a63832 | |||
| 9367009fdf | |||
| e0ba3a0f45 | |||
| df845c3ae7 | |||
| 7a5be1d876 |
+13
@@ -5,6 +5,19 @@
|
|||||||
<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: rgb(249, 249, 249);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
|||||||
Generated
+17
-7
@@ -9,7 +9,8 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"react": "^19.1.0",
|
"react": "^19.1.0",
|
||||||
"react-dom": "^19.1.0"
|
"react-dom": "^19.1.0",
|
||||||
|
"react-icons": "^5.5.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.25.0",
|
"@eslint/js": "^9.25.0",
|
||||||
@@ -321,9 +322,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@bufbuild/protobuf": {
|
"node_modules/@bufbuild/protobuf": {
|
||||||
"version": "2.12.0",
|
"version": "2.5.2",
|
||||||
"resolved": "https://registry.npmjs.org/@bufbuild/protobuf/-/protobuf-2.12.0.tgz",
|
"resolved": "https://registry.npmjs.org/@bufbuild/protobuf/-/protobuf-2.5.2.tgz",
|
||||||
"integrity": "sha512-B/XlCaFIP8LOwzo+bz5uFzATYokcwCKQcghqnlfwSmM5eX/qTkvDBnDPs+gXtX/RyjxJ4DRikECcPJbyALA8FA==",
|
"integrity": "sha512-foZ7qr0IsUBjzWIq+SuBLfdQCpJ1j8cTuNNT4owngTHoN5KsJb8L9t65fzz7SCeSWzescoOil/0ldqiL041ABg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "(Apache-2.0 AND BSD-3-Clause)"
|
"license": "(Apache-2.0 AND BSD-3-Clause)"
|
||||||
},
|
},
|
||||||
@@ -2829,6 +2830,15 @@
|
|||||||
"react": "^19.1.0"
|
"react": "^19.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/react-icons": {
|
||||||
|
"version": "5.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-icons/-/react-icons-5.5.0.tgz",
|
||||||
|
"integrity": "sha512-MEFcXdkP3dLo8uumGI5xN3lDFNsRtrjbOEKDLD7yv76v4wpnEq2Lt2qeHaQOr34I/wPN3s3+N08WkQ+CW37Xiw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/react-refresh": {
|
"node_modules/react-refresh": {
|
||||||
"version": "0.17.0",
|
"version": "0.17.0",
|
||||||
"resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.17.0.tgz",
|
"resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.17.0.tgz",
|
||||||
@@ -3396,9 +3406,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/sync-message-port": {
|
"node_modules/sync-message-port": {
|
||||||
"version": "1.2.0",
|
"version": "1.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/sync-message-port/-/sync-message-port-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/sync-message-port/-/sync-message-port-1.1.3.tgz",
|
||||||
"integrity": "sha512-gAQ9qrUN/UCypHtGFbbe7Rc/f9bzO88IwrG8TDo/aMKAApKyD6E3W4Cm0EfhfBb6Z6SKt59tTCTfD+n1xmAvMg==",
|
"integrity": "sha512-GTt8rSKje5FilG+wEdfCkOcLL7LWqpMlr2c3LRuKt/YXxcJ52aGSbGBAdI4L3aaqfrBt6y711El53ItyH1NWzg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
+2
-1
@@ -11,7 +11,8 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"react": "^19.1.0",
|
"react": "^19.1.0",
|
||||||
"react-dom": "^19.1.0"
|
"react-dom": "^19.1.0",
|
||||||
|
"react-icons": "^5.5.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.25.0",
|
"@eslint/js": "^9.25.0",
|
||||||
|
|||||||
-15
@@ -1,15 +0,0 @@
|
|||||||
.container {
|
|
||||||
/* display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
flex-wrap: nowrap;*/
|
|
||||||
height: 500px;
|
|
||||||
overflow: auto;
|
|
||||||
border: 1px solid black;
|
|
||||||
}
|
|
||||||
.item {
|
|
||||||
font-size: 16pt;
|
|
||||||
border: 1px dotted gray;
|
|
||||||
/*margin: 5px 10px;
|
|
||||||
padding: 10px;*/
|
|
||||||
border-radius: 5px;
|
|
||||||
}
|
|
||||||
+93
-41
@@ -1,51 +1,103 @@
|
|||||||
import { useEffect, useRef, useState } from 'react';
|
import styles from './App.module.scss'
|
||||||
import styles from './App.module.scss';
|
import SneakersImage from './assets/images/sneakers-image.jpg'
|
||||||
|
import { FaRegUser } from 'react-icons/fa'
|
||||||
|
import { FaHeart } from "react-icons/fa";
|
||||||
|
import { BsCheckSquare } from "react-icons/bs";
|
||||||
|
import { useState } from 'react'
|
||||||
|
|
||||||
const InfiniteList = () => {
|
function Header() {
|
||||||
const [items, setItems] = useState([...Array(20).keys()]); // Initial data
|
const handleChange = event => {
|
||||||
const loaderRef = useRef(null);
|
const newValue = event.target.value
|
||||||
|
console.log('Новое значение:', newValue)
|
||||||
|
}
|
||||||
|
|
||||||
const loadMore = () => {
|
return (
|
||||||
setItems((prev) => [...prev, ...Array(10).keys()].map((_, i) => prev.length + i));
|
<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>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
function Product() {
|
||||||
const observer = new IntersectionObserver((entries) => {
|
function LikeCounter() {
|
||||||
if (entries[0].isIntersecting) {
|
const [likes,setLikes] = useState(0);
|
||||||
loadMore(); // Load next batch when the loader is seen
|
return (
|
||||||
}
|
<>
|
||||||
});
|
<h2>Лайков: {likes}</h2>
|
||||||
|
{likes < 10 && <button onClick={() => setLikes(likes + 1)}>👍 Лайк</button>}
|
||||||
if (loaderRef.current) observer.observe(loaderRef.current);
|
{likes > 0 && <button onClick={() => setLikes(0)}>🔄 Сбросить</button> }
|
||||||
return () => observer.disconnect();
|
{likes >= 10 && <h3>Вы достигли лимита!</h3>}
|
||||||
}, []);
|
<div className={styles.progress}>
|
||||||
|
<div className={styles.value} style={{ width: `${likes*10}%`}}></div>
|
||||||
return (
|
</div>
|
||||||
<ul>
|
</>
|
||||||
{items.map(item => <li key={item} className={ styles.item }>Item {item}</li>)}
|
)
|
||||||
<div ref={loaderRef}>Loading more...</div>
|
}
|
||||||
</ul>
|
|
||||||
);
|
function handleClick() {
|
||||||
};
|
console.log('Working!')
|
||||||
|
}
|
||||||
function App() {
|
|
||||||
const generatedBigDataSet = () => {
|
function Counter() {
|
||||||
return Array.from({ length: 100 }, (_, index) => ({
|
const [isLiked,setIsLiked] = useState(false);
|
||||||
id: index,
|
|
||||||
name: `Элемент № ${index}`,
|
const toggleLike = () => {
|
||||||
value: Math.floor(Math.random() * 1000)
|
setIsLiked(!isLiked);
|
||||||
}))
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<BsCheckSquare
|
||||||
|
onClick={toggleLike}
|
||||||
|
fill={isLiked==true ? 'red' : 'grey'}
|
||||||
|
size={44}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
const [data] = useState(generatedBigDataSet);
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={styles.product}>
|
||||||
|
<img src={SneakersImage} alt='' />
|
||||||
|
<div className={styles.content}>
|
||||||
|
<div className={styles.title}>
|
||||||
|
<h4>Sneakers Red & White 2025</h4>
|
||||||
|
<button onClick={event => handleClick(event)}>+</button>
|
||||||
|
</div>
|
||||||
|
<p className={styles.description}>NIKE</p>
|
||||||
|
<p className={styles.price}>$38.00</p>
|
||||||
|
</div>
|
||||||
|
<LikeCounter />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function App() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div>
|
<div className={styles.container}>
|
||||||
<h2>Визуализация большого списка</h2>
|
<Header />
|
||||||
<div className={ styles.container }>
|
</div>
|
||||||
<InfiniteList />
|
<div className={styles.container}>
|
||||||
</div>
|
<ul className={styles.list}>
|
||||||
</div>
|
<li>
|
||||||
|
<Product />
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<Product />
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<Product />
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,141 @@
|
|||||||
|
@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;
|
||||||
|
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;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
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 {
|
||||||
|
border: 1px solid $primary-color;
|
||||||
|
background-color: $white-color;
|
||||||
|
color: $primary-color;
|
||||||
|
border-radius: 5px;
|
||||||
|
outline: 0;
|
||||||
|
|
||||||
|
font-size: 20px;
|
||||||
|
padding: 5px 10px;
|
||||||
|
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: $seconday-color;
|
||||||
|
color: $white-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.description {
|
||||||
|
color: gray;
|
||||||
|
}
|
||||||
|
|
||||||
|
.price {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
@@ -0,0 +1,5 @@
|
|||||||
|
$white-color: white;
|
||||||
|
$black-color: black;
|
||||||
|
|
||||||
|
$primary-color: #3258e3;
|
||||||
|
$seconday-color: #4432e3;
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
import { StrictMode } from 'react'
|
import { StrictMode } from 'react'
|
||||||
import { createRoot } from 'react-dom/client'
|
import { createRoot } from 'react-dom/client'
|
||||||
// удаляем import './index.css'
|
|
||||||
import App from './App.jsx'
|
import App from './App.jsx'
|
||||||
|
|
||||||
createRoot(document.getElementById('root')).render(
|
createRoot(document.getElementById('root')).render(
|
||||||
|
|||||||
Reference in New Issue
Block a user