Compare commits

..

1 Commits

Author SHA1 Message Date
laktionov-as e4d1f4fe8f start final project 2026-06-23 21:47:16 +03:00
18 changed files with 733 additions and 1058 deletions
+22
View File
@@ -0,0 +1,22 @@
{
"advertisement": [
{
"id":1,
"name":"Продаю голодного кота!",
"description":"Кот бегемот. Прокормить невозможно!",
"url":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTqlWZ1N8qSUMB1HuqN6DjnXP_D5NRGNJ-W6zLZqP-Y9Q&s=10"
},
{
"id":2,
"name":"Продаю машину",
"description":"Не бита не крашена без пробега по РФ",
"url":"https://s0.rbk.ru/v6_top_pics/media/img/9/33/347054091401339.jpeg"
},
{
"id":3,
"name":"Продаю квартиру",
"description":"Центр города, с видом на море.",
"url":"https://hoff.ru/upload/medialibrary/11c/11cb47c1d2d4f248b7dde57f479f2d47.jpg"
}
]
}
-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: rgb(249, 249, 249);
}
</style>
</head>
<body>
<div id="root"></div>
+541 -801
View File
File diff suppressed because it is too large Load Diff
+3 -2
View File
@@ -4,15 +4,17 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"server": "json-server db.json",
"dev": "vite",
"build": "vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"json-server": "^1.0.0-beta.15",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"react-icons": "^5.5.0"
"react-router-dom": "^7.18.0"
},
"devDependencies": {
"@eslint/js": "^9.25.0",
@@ -23,7 +25,6 @@
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.19",
"globals": "^16.0.0",
"sass-embedded": "^1.99.0",
"vite": "^6.3.5"
}
}
+4 -95
View File
@@ -1,103 +1,12 @@
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'
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() {
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>
)
}
import { RouterProvider } from "react-router-dom";
import { router } from './router'
import Header from './components/Header/index'
function App() {
return (
<>
<div className={styles.container}>
<Header />
</div>
<div className={styles.container}>
<ul className={styles.list}>
<li>
<Product />
</li>
<li>
<Product />
</li>
<li>
<Product />
</li>
</ul>
</div>
<RouterProvider router={router} />
</>
)
}
-141
View File
@@ -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

-5
View File
@@ -1,5 +0,0 @@
$white-color: white;
$black-color: black;
$primary-color: #3258e3;
$seconday-color: #4432e3;
+49
View File
@@ -0,0 +1,49 @@
import styles from './index.module.css'
import { useState, useEffect } from 'react'
export default function() {
const [data,setData] = useState([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
useEffect(()=>{
const controller = new AbortController();
const fetchData = async () => {
try {
const response = await fetch('http://localhost:3000/advertisement', {
signal: controller.signal // Link the abort signal to the fetch request
});
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
const result = await response.json();
setData(result);
} catch (err) {
if (err.name !== 'AbortError') {
setError(err.message);
}
} finally {
setLoading(false);
}
};
fetchData();
return () => controller.abort();
},[]);
return (
<>
<div className={styles.container}>
{data.map(item => <div key={item.id} className={styles.card}>
<h3>{item.name}</h3>
<div
className={styles.img}
style={{backgroundImage: `url(${item.url})`}}>
</div>
<p>{item.description}</p>
</div>)}
</div>
</>
)
}
+27
View File
@@ -0,0 +1,27 @@
.container {
display: flex;
flex-direction: row;
flex-wrap: wrap;
column-gap: 10px;
}
.card {
min-width: 100px;
min-height: 200px;
/*border: 1px solid black;*/
border-radius: 10px;
box-shadow: 2px 2px 5px 2px black;
}
.card h3 {
text-align: center;
}
.card p {
margin: 5px 10px;
}
.img {
width: 200px;
height: 200px;
border-radius: 5px;
background-size: cover;
background-position: center;
margin: 0 auto;
}
+17
View File
@@ -0,0 +1,17 @@
import styles from './index.module.css'
export default function() {
return (
<>
<header>
<nav>
<ul className={styles.container}>
<li><a href="/">Главная</a></li>
<li><a href="/favorite">Избранное</a></li>
<li><a href="/profile">Профиль</a></li>
</ul>
</nav>
</header>
</>
)
}
+7
View File
@@ -0,0 +1,7 @@
.container {
display: flex;
flex-direction: row;
align-items: center;
list-style: none;
column-gap: 1em;
}
+1
View File
@@ -1,5 +1,6 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
// удаляем import './index.css'
import App from './App.jsx'
createRoot(document.getElementById('root')).render(
+7
View File
@@ -0,0 +1,7 @@
export default function() {
return (
<>
<h1>Error</h1>
</>
)
}
+7
View File
@@ -0,0 +1,7 @@
export default function() {
return (
<>
<h1>Favorites</h1>
</>
)
}
+12
View File
@@ -0,0 +1,12 @@
import AdvList from '../components/AdvList/index'
export default function() {
return (
<>
<h1>Main</h1>
<div>
<AdvList />
</div>
</>
)
}
+7
View File
@@ -0,0 +1,7 @@
export default function() {
return (
<>
<h1>Profile</h1>
</>
)
}
+28
View File
@@ -0,0 +1,28 @@
import { createBrowserRouter } from 'react-router-dom'
import MainPage from './pages/Main'
import ErrorPage from './pages/Error'
import FavoritePage from './pages/Favorites'
import ProfilePage from './pages/Profile'
export const router = createBrowserRouter([
{
path: "/",
element: <MainPage />,
errorElement: <ErrorPage />,
children: [
{
path: "/",
element: <MainPage />,
loader: async () => fetch("/api/dashboard-data"),
},
]
},
{
path: "/favorite",
element: <FavoritePage />
},
{
path: "/profile",
element: <ProfilePage />
}
]);