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
+828
-58
File diff suppressed because it is too large
Load Diff
+2
-1
@@ -12,7 +12,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"react": "^19.1.0",
|
"react": "^19.1.0",
|
||||||
"react-dom": "^19.1.0",
|
"react-dom": "^19.1.0",
|
||||||
"react-intl": "^10.1.13"
|
"react-icons": "^5.5.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.25.0",
|
"@eslint/js": "^9.25.0",
|
||||||
@@ -23,6 +23,7 @@
|
|||||||
"eslint-plugin-react-hooks": "^5.2.0",
|
"eslint-plugin-react-hooks": "^5.2.0",
|
||||||
"eslint-plugin-react-refresh": "^0.4.19",
|
"eslint-plugin-react-refresh": "^0.4.19",
|
||||||
"globals": "^16.0.0",
|
"globals": "^16.0.0",
|
||||||
|
"sass-embedded": "^1.99.0",
|
||||||
"vite": "^6.3.5"
|
"vite": "^6.3.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+96
-23
@@ -1,30 +1,103 @@
|
|||||||
import { IntlProvider,
|
import styles from './App.module.scss'
|
||||||
FormattedMessage,
|
import SneakersImage from './assets/images/sneakers-image.jpg'
|
||||||
FormattedNumber,
|
import { FaRegUser } from 'react-icons/fa'
|
||||||
FormattedDate,
|
import { FaHeart } from "react-icons/fa";
|
||||||
FormattedTime,
|
import { BsCheckSquare } from "react-icons/bs";
|
||||||
FormattedDateTimeRange } from 'react-intl'
|
import { useState } from 'react'
|
||||||
import messageRu from './translations/ru.json'
|
|
||||||
import messageEn from './translations/en.json'
|
|
||||||
|
|
||||||
function App() {
|
function Header() {
|
||||||
const locale = 'ru';
|
const handleChange = event => {
|
||||||
const messages = messageEn;
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
<IntlProvider locale={locale} messages={messages}>
|
<BsCheckSquare
|
||||||
<h1><FormattedMessage id='app.welcome' /></h1>
|
onClick={toggleLike}
|
||||||
<h2><FormattedMessage id='app.userGreeting' values={{ name: <u>Alex</u> }} /></h2>
|
fill={isLiked==true ? 'red' : 'grey'}
|
||||||
<p><FormattedMessage id='app.notifications' values= {{count: 25}} /></p>
|
size={44}
|
||||||
<p><FormattedMessage id='app.lastLogin' values={{ date: new Date(), time: new Date()}} /></p>
|
/>
|
||||||
<p><FormattedNumber value={ 999.99 } style='currency' currency='RUB' /></p>
|
</>
|
||||||
<p><FormattedNumber value={0.56} style='percent' /></p>
|
)
|
||||||
<p><FormattedNumber value={1234.567} minimumFractionDigits={2} maximumFractionDigits={2} /></p>
|
}
|
||||||
<p><FormattedDate value={new Date()} weekday='long' /></p>
|
|
||||||
<p><FormattedTime value={new Date()} hour='2-digit' minute='2-digit' second='2-digit' /></p>
|
return (
|
||||||
<p><FormattedDateTimeRange from={new Date(2026,6,1,10,0)} to={new Date(2026,6,10,9,0)} /></p>
|
<div className={styles.product}>
|
||||||
</IntlProvider>
|
<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 (
|
||||||
|
<>
|
||||||
|
<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>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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(
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"app.welcome": "welcome to React application",
|
|
||||||
"app.userGreeting": "Hello, {name}",
|
|
||||||
"app.notifications": "You have {count, plural, one {# a notification} few {# are notifications} many {# уведомлений} other {# уведомления}}",
|
|
||||||
"app.lastLogin": "Last login was {date,date,long} in {time,time,short}"
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"app.welcome": "добро пожаловать в приложение React",
|
|
||||||
"app.userGreeting": "Здравствуйте, {name}",
|
|
||||||
"app.notifications": "У вас {count, plural, one {# уведомление} few {# уведомления} many {# уведомлений} other {# уведомления}}",
|
|
||||||
"app.lastLogin": "Последний вход был {date,date,long} в {time,time,short}"
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user