Compare commits

..

14 Commits

Author SHA1 Message Date
laktionov-as a72a5bc640 Сделали многоуровневые списки 2026-05-07 21:04:38 +03:00
isHardCoded c44b4a283c Fix: изменили description на brand 2025-06-25 15:43:44 +03:00
isHardCoded c5760f27b4 Создали props для компонента Products, отмаппили полученные товары на странице 2025-06-25 15:40:12 +03:00
isHardCoded ca519f47b1 Создали асинхронную функцию getProducts для получения продуктов с сервера 2025-06-25 15:38:08 +03:00
isHardCoded 2812645834 Установили библиотеку json-server, заполнили данные в db.json, настроили скрипт для запуска сервера 2025-06-25 15:14:13 +03:00
isHardCoded b8e88a4866 Добавили в компонент Product иконку сердца и создали состояние для нее 2025-06-18 11:45:47 +03:00
isHardCoded 102da1ad75 Fix 2025-06-16 13:50:56 +03:00
isHardCoded a84b1972e7 Стилизовали компонент Header, добавили обработчик событий onChange 2025-06-16 13:32:07 +03:00
isHardCoded 2ba1a63832 Добавили обработчик событий по клику на карточку товара, создали компонент Header, установили библиотеку react-icons 2025-06-16 12:48:23 +03:00
isHardCoded 9367009fdf Добавили каталог товаров, карточки и стилизацию для них 2025-06-08 13:05:39 +03:00
isHardCoded e0ba3a0f45 Изменили подход стилизации на CSS Modules 2025-06-08 12:26:21 +03:00
isHardCoded df845c3ae7 Вынесли свойство для шрифтов в index.html для применения их ко всем текстовым элементам 2025-06-08 12:17:15 +03:00
isHardCoded 7a5be1d876 Создали компонент Product, вынесли стили для него в отдельный файл App.css 2025-06-08 12:12:36 +03:00
isHardCoded ec325b51bc Развернули проект с помощью Vite, подготовили структуру для разработки 2025-06-08 10:23:50 +03:00
15 changed files with 3770 additions and 148 deletions
+14 -128
View File
@@ -1,138 +1,24 @@
# ---> Node
# Logs # Logs
logs logs
*.log *.log
npm-debug.log* npm-debug.log*
yarn-debug.log* yarn-debug.log*
yarn-error.log* yarn-error.log*
pnpm-debug.log*
lerna-debug.log* lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html) node_modules
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional stylelint cache
.stylelintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist dist
dist-ssr
*.local
# Gatsby files # Editor directories and files
.cache/ .vscode/*
# Comment in the public line in if your project uses Gatsby and not Next.js !.vscode/extensions.json
# https://nextjs.org/blog/next-9-1#public-directory-support .idea
# public .DS_Store
*.suo
# vuepress build output *.ntvs*
.vuepress/dist *.njsproj
*.sln
# vuepress v2.x temp and cache directory *.sw?
.temp
.cache
# vitepress build output
**/.vitepress/dist
# vitepress cache directory
**/.vitepress/cache
# Docusaurus cache and generated files
.docusaurus
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
-18
View File
@@ -1,18 +0,0 @@
MIT License
Copyright (c) 2026 laktionov-as
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
+11 -2
View File
@@ -1,3 +1,12 @@
# react # React + Vite
Уроки по React This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Currently, two official plugins are available:
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
## Expanding the ESLint configuration
If you are developing a production application, we recommend using TypeScript with type-aware lint rules enabled. Check out the [TS template](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts) for information on how to integrate TypeScript and [`typescript-eslint`](https://typescript-eslint.io) in your project.
+55
View File
@@ -0,0 +1,55 @@
{
"products": [
{
"id": 1,
"name": "Sneakers Red & White 2025",
"brand": "NIKE",
"price": 38.0,
"imageUrl": "./src/assets/images/sneakers-image.jpg"
},
{
"id": 2,
"name": "Sneakers Red & White 2025",
"brand": "NIKE",
"price": 38.0,
"imageUrl": "./src/assets/images/sneakers-image.jpg"
},
{
"id": 3,
"name": "Sneakers Red & White 2025",
"brand": "NIKE",
"price": 38.0,
"imageUrl": "./src/assets/images/sneakers-image.jpg"
}
],
"articles": [
{
"id": 1,
"title": "Статья 1",
"author": "Иванов Иван Иванович",
"createDate": "2020-01-15",
"content": "Основной текст статьи"
}
],
"projects": [
{
"id":1,
"name": "Project 1",
"status": "work",
"description": "Very important!",
"tasks": [
{
"id":1,
"title":"Task 1",
"description": "Описание задачи"
},
{
"id":2,
"title":"Task 2",
"description": "Описание задачи 2"
}
]
}
]
}
+33
View File
@@ -0,0 +1,33 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
export default [
{ ignores: ['dist'] },
{
files: ['**/*.{js,jsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
parserOptions: {
ecmaVersion: 'latest',
ecmaFeatures: { jsx: true },
sourceType: 'module',
},
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...js.configs.recommended.rules,
...reactHooks.configs.recommended.rules,
'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }],
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
},
]
+26
View File
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<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>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
+3186
View File
File diff suppressed because it is too large Load Diff
+30
View File
@@ -0,0 +1,30 @@
{
"name": "store-client",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"server": "json-server --watch db.json --port 8000",
"build": "vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"react": "^19.1.0",
"react-dom": "^19.1.0",
"react-icons": "^5.5.0",
"sass-embedded": "^1.89.2"
},
"devDependencies": {
"@eslint/js": "^9.25.0",
"@types/react": "^19.1.2",
"@types/react-dom": "^19.1.2",
"@vitejs/plugin-react": "^4.4.1",
"eslint": "^9.25.0",
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.19",
"globals": "^16.0.0",
"vite": "^6.3.5"
}
}
+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

+243
View File
@@ -0,0 +1,243 @@
import styles from './App.module.scss'
import { FaRegUser } from 'react-icons/fa'
import React, { useState, useEffect } 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>
<UserMenu isLoggedin={true} userName="Bob" role="user" />
</header>
)
}
function UserMenu({ userName }) {
const [loggedin,setLoggedin] = useState(false);
const [role, setRole] = useState('user');
if (loggedin) {
return (
<div className="user-menu">
<nav>
<a href="/settings">Настройки</a>
{role === "admin" && <a href="/admin">Панель администратора</a>}
<div>
<FaRegUser size={24} color='#3258e3' />
<button>Profile</button>
<button onClick={() => setLoggedin(false)}>Exit</button>
</div>
</nav>
</div>
);
}
return (
<div className="login-form">
<button onClick={() => setLoggedin(true)}>Войти</button>
</div>
);
}
function ArticleViewer({ articleId }) {
const [article,setArticle] = useState(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
useEffect(() => {
const fetchArticle = async () => {
try {
setLoading(true);
setError(null);
const responce = await fetch(`http://localhost:8000/articles/${articleId}`)
if(!responce.ok) {
throw new Error('Не удалось загрузить статью');
}
const data = await responce.json();
setArticle(data);
} catch(err) {
setError(err.message);
} finally {
setLoading(false);
}
}
fetchArticle();
},[articleId]);
if (loading) {
return (
<div className={styles.loading}>
<div className="spinner"></div>
<p>Загружаем статью ...</p>
</div>
);
}
if (error) {
return (
<div className={styles.error}>
<h3>Ошибка загрузки</h3>
<p>{error}</p>
<button onClick={()=>window.location.reload()}>Попробовать еще</button>
</div>
);
}
if (!article) {
return (
<div className={styles.empty}>
<p>Статья не найдена</p>
</div>
);
}
return (
<div className={styles.article}>
<h1>{article.title}</h1>
<div className="article-meta">
<span>Автор: {article.author}</span>
<span>Дата: {new Date(article.createDate).toLocaleDateString()}</span>
</div>
<div className="article-body">{article.content}</div>
</div>
);
}
function ProjectDashboard({ projects }) {
return (
<div className={styles.dashboard}>
<h1>Панель управления проектами</h1>
{projects.map(project => (
<div key={project.id} className={styles.project}>
<h2>{project.name}</h2>
<span className={styles.project_status}>{project.status}</span>
<p className={styles.project_description}>{project.description}</p>
{project.tasks.length >0 && (
<div className={styles.tasks}>
{project.tasks.map(task => (
<div className={styles.task_card} key={task.id}>
<h4>{task.title}</h4>
<p>{task.description}</p>
</div>
))}
</div>
)}
</div>
))}
</div>
)
}
function Product({ name, brand, price, imageUrl }) {
const [isLiked, setIsLiked] = React.useState(false)
const toggleLike = () => {
setIsLiked(!isLiked)
}
function handleAddClick() {
console.log('Working!')
}
return (
<div className={styles.product}>
<img src={imageUrl} alt='' />
<div className={styles.content}>
<div className={styles.title}>
<h4>{name}</h4>
<div className={styles.actions}>
<button
className={styles.likeButton}
onClick={toggleLike}
aria-label={isLiked ? 'Убрать лайк' : 'Добавить лайк'}
>
<svg
width='18'
height='18'
viewBox='0 0 24 24'
fill={isLiked ? 'red' : 'none'}
stroke={isLiked ? 'red' : 'currentColor'}
strokeWidth='1.5'
>
<path d='M12 21.35L10.55 20.03C5.4 15.36 2 12.28 2 8.5C2 5.42 4.42 3 7.5 3C9.24 3 10.91 3.81 12 5.09C13.09 3.81 14.76 3 16.5 3C19.58 3 22 5.42 22 8.5C22 12.28 18.6 15.36 13.45 20.04L12 21.35Z' />
</svg>
</button>
<button onClick={handleAddClick}>+</button>
</div>
</div>
<p className={styles.description}>{brand}</p>
<p className={styles.price}>${price}</p>
</div>
</div>
)
}
function App() {
const [products, setProducts] = React.useState([])
const getProducts = async () => {
const response = await fetch('http://localhost:8000/products')
const data = await response.json()
setProducts(data)
}
React.useEffect(() => {
getProducts()
}, [])
return (
<>
<div className={styles.container}>
<Header />
</div>
<div className={styles.container}>
{products.length > 0 ? (
<ul className={styles.list}>
{products.map(product => (
<li key={product.id}>
<Product {...product} />
</li>
))}
</ul>
) : (
<h3>Список товаров пуст</h3>
)
}
</div>
</>
)
}
function App2() {
const [projects, setProjects] = React.useState([])
const getProjects = async () => {
const response = await fetch('http://localhost:8000/projects')
const data = await response.json()
setProjects(data)
}
React.useEffect(() => {
getProjects()
}, [])
return (
<>
<div className={styles.container}>
<Header />
</div>
<div className={styles.container}>
<ProjectDashboard projects={projects} />
</div>
</>
)
}
export default App2
+150
View File
@@ -0,0 +1,150 @@
@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;
nav {
display: flex;
justify-content: space-around;
flex-direction: row;
align-items: center;
}
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;
.article {
text-align: center;
background-color: lightgray;
}
.error {
text-align: center;
background-color: lightcoral;
}
}
.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;
}
.actions {
display: flex;
align-items: center;
gap: 5px;
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

+5
View File
@@ -0,0 +1,5 @@
$white-color: white;
$black-color: black;
$primary-color: #3258e3;
$seconday-color: #4432e3;
+9
View File
@@ -0,0 +1,9 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import App from './App.jsx'
createRoot(document.getElementById('root')).render(
<StrictMode>
<App />
</StrictMode>
)
+7
View File
@@ -0,0 +1,7 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
})