Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4472759509 | |||
| 09b3da5f18 | |||
| 50becd2dca | |||
| a31d35508a |
-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: rgb(249, 249, 249);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
|||||||
Generated
+7
-17
@@ -9,8 +9,7 @@
|
|||||||
"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",
|
||||||
@@ -322,9 +321,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@bufbuild/protobuf": {
|
"node_modules/@bufbuild/protobuf": {
|
||||||
"version": "2.5.2",
|
"version": "2.12.0",
|
||||||
"resolved": "https://registry.npmjs.org/@bufbuild/protobuf/-/protobuf-2.5.2.tgz",
|
"resolved": "https://registry.npmjs.org/@bufbuild/protobuf/-/protobuf-2.12.0.tgz",
|
||||||
"integrity": "sha512-foZ7qr0IsUBjzWIq+SuBLfdQCpJ1j8cTuNNT4owngTHoN5KsJb8L9t65fzz7SCeSWzescoOil/0ldqiL041ABg==",
|
"integrity": "sha512-B/XlCaFIP8LOwzo+bz5uFzATYokcwCKQcghqnlfwSmM5eX/qTkvDBnDPs+gXtX/RyjxJ4DRikECcPJbyALA8FA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "(Apache-2.0 AND BSD-3-Clause)"
|
"license": "(Apache-2.0 AND BSD-3-Clause)"
|
||||||
},
|
},
|
||||||
@@ -2830,15 +2829,6 @@
|
|||||||
"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",
|
||||||
@@ -3406,9 +3396,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/sync-message-port": {
|
"node_modules/sync-message-port": {
|
||||||
"version": "1.1.3",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/sync-message-port/-/sync-message-port-1.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/sync-message-port/-/sync-message-port-1.2.0.tgz",
|
||||||
"integrity": "sha512-GTt8rSKje5FilG+wEdfCkOcLL7LWqpMlr2c3LRuKt/YXxcJ52aGSbGBAdI4L3aaqfrBt6y711El53ItyH1NWzg==",
|
"integrity": "sha512-gAQ9qrUN/UCypHtGFbbe7Rc/f9bzO88IwrG8TDo/aMKAApKyD6E3W4Cm0EfhfBb6Z6SKt59tTCTfD+n1xmAvMg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
+1
-2
@@ -11,8 +11,7 @@
|
|||||||
},
|
},
|
||||||
"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
@@ -0,0 +1,15 @@
|
|||||||
|
.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;
|
||||||
|
}
|
||||||
+37
-89
@@ -1,102 +1,50 @@
|
|||||||
import styles from './App.module.scss'
|
import { useEffect, useRef, useState } from 'react';
|
||||||
import SneakersImage from './assets/images/sneakers-image.jpg'
|
import styles from './App.module.scss';
|
||||||
import { FaRegUser } from 'react-icons/fa'
|
|
||||||
import { FaHeart } from "react-icons/fa";
|
|
||||||
import { BsCheckSquare } from "react-icons/bs";
|
|
||||||
import { useState } from 'react'
|
|
||||||
|
|
||||||
function Header() {
|
const InfiniteList = () => {
|
||||||
const handleChange = event => {
|
const [items, setItems] = useState([...Array(20).keys()]); // Initial data
|
||||||
const newValue = event.target.value
|
const loaderRef = useRef(null);
|
||||||
console.log('Новое значение:', newValue)
|
|
||||||
|
const loadMore = () => {
|
||||||
|
setItems((prev) => [...prev, ...Array(10).keys()].map((_, i) => prev.length + i));
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const observer = new IntersectionObserver((entries) => {
|
||||||
|
if (entries[0].isIntersecting) {
|
||||||
|
loadMore(); // Load next batch when the loader is seen
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (loaderRef.current) observer.observe(loaderRef.current);
|
||||||
|
return () => observer.disconnect();
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<header className={styles.header}>
|
<ul>
|
||||||
<div>
|
{items.map(item => <li key={item} className={ styles.item }>Item {item}</li>)}
|
||||||
<h2>Store</h2>
|
<div ref={loaderRef}>Loading more...</div>
|
||||||
<input type='text ' placeholder='Search...' onChange={handleChange} />
|
</ul>
|
||||||
</div>
|
);
|
||||||
<div>
|
};
|
||||||
<FaRegUser size={24} color='#3258e3' />
|
|
||||||
<button>Profile</button>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function Product() {
|
|
||||||
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} style={{ width: `${likes*10}%`}}></div>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleClick() {
|
|
||||||
console.log('Working!')
|
|
||||||
}
|
|
||||||
|
|
||||||
function Counter() {
|
|
||||||
const [isLiked,setIsLiked] = useState(false);
|
|
||||||
|
|
||||||
const toggleLike = () => {
|
|
||||||
setIsLiked(!isLiked);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<BsCheckSquare
|
|
||||||
onClick={toggleLike}
|
|
||||||
fill={isLiked==true ? 'red' : 'grey'}
|
|
||||||
size={44}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
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() {
|
function App() {
|
||||||
|
const generatedBigDataSet = () => {
|
||||||
|
return Array.from({ length: 100 }, (_, index) => ({
|
||||||
|
id: index,
|
||||||
|
name: `Элемент № ${index}`,
|
||||||
|
value: Math.floor(Math.random() * 1000)
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
const [data] = useState(generatedBigDataSet);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<div>
|
||||||
|
<h2>Визуализация большого списка</h2>
|
||||||
<div className={ styles.container }>
|
<div className={ styles.container }>
|
||||||
<Header />
|
<InfiniteList />
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.container}>
|
|
||||||
<ul className={styles.list}>
|
|
||||||
<li>
|
|
||||||
<Product />
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<Product />
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<Product />
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,141 +0,0 @@
|
|||||||
@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.
|
Before Width: | Height: | Size: 23 KiB |
@@ -1,5 +0,0 @@
|
|||||||
$white-color: white;
|
|
||||||
$black-color: black;
|
|
||||||
|
|
||||||
$primary-color: #3258e3;
|
|
||||||
$seconday-color: #4432e3;
|
|
||||||
@@ -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 './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