Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c168c96820 | |||
| b70fa47bbc | |||
| bd35029fc1 | |||
| 92dc5df96b | |||
| 3d34262203 | |||
| 1bc2e883a1 | |||
| 8a8a17f44d | |||
| 8f46470a26 |
Generated
+1256
-65
File diff suppressed because it is too large
Load Diff
+4
-2
@@ -10,9 +10,9 @@
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"info": "^1.0.0",
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0",
|
||||
"react-intl": "^10.1.13"
|
||||
"react-dom": "^19.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.25.0",
|
||||
@@ -23,6 +23,8 @@
|
||||
"eslint-plugin-react-hooks": "^5.2.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.19",
|
||||
"globals": "^16.0.0",
|
||||
"sass": "^1.99.0",
|
||||
"sass-embedded": "^1.99.0",
|
||||
"vite": "^6.3.5"
|
||||
}
|
||||
}
|
||||
|
||||
+21
-22
@@ -1,30 +1,29 @@
|
||||
import { IntlProvider,
|
||||
FormattedMessage,
|
||||
FormattedNumber,
|
||||
FormattedDate,
|
||||
FormattedTime,
|
||||
FormattedDateTimeRange } from 'react-intl'
|
||||
import messageRu from './translations/ru.json'
|
||||
import messageEn from './translations/en.json'
|
||||
import styles from './styles/App.module.scss'
|
||||
import React, { useState, useCallback } from 'react'
|
||||
|
||||
function CounterButton({label, onClick}) {
|
||||
return (
|
||||
<button onClick={onClick} className={styles.counter_button}>{label}</button>
|
||||
)
|
||||
}
|
||||
function CounterDisplay({value}) {
|
||||
return (<div className={styles.counter_display}>
|
||||
Значение счетчика: <b>{value}</b>
|
||||
</div>)
|
||||
}
|
||||
|
||||
function App() {
|
||||
const locale = 'ru';
|
||||
const messages = messageEn;
|
||||
const [counter,setCounter] = useState(0);
|
||||
|
||||
const increment = () => setCounter(prev => prev + 1);
|
||||
const decrement = () => setCounter(prev => prev - 1);
|
||||
|
||||
return (
|
||||
<>
|
||||
<IntlProvider locale={locale} messages={messages}>
|
||||
<h1><FormattedMessage id='app.welcome' /></h1>
|
||||
<h2><FormattedMessage id='app.userGreeting' values={{ name: <u>Alex</u> }} /></h2>
|
||||
<p><FormattedMessage id='app.notifications' values= {{count: 25}} /></p>
|
||||
<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>
|
||||
<p><FormattedDateTimeRange from={new Date(2026,6,1,10,0)} to={new Date(2026,6,10,9,0)} /></p>
|
||||
</IntlProvider>
|
||||
<h2>Практика по созданию счетчика с колбэками</h2>
|
||||
<CounterButton label="Увеличить" onClick={increment} />
|
||||
<CounterButton label="уменьшить" onClick={decrement} />
|
||||
<CounterDisplay value={counter} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +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(
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
.container {
|
||||
display:flex;
|
||||
flex-direction: row;
|
||||
border: 1px solid black;
|
||||
border-radius: 5px;
|
||||
margin-bottom: 10px;
|
||||
p {
|
||||
padding: 5px 10px;
|
||||
}
|
||||
}
|
||||
.counter {
|
||||
&_display{
|
||||
border: 1px solid black;
|
||||
border-width: 3px;
|
||||
border-radius: 10px;
|
||||
padding: 10px;
|
||||
width: 300px;
|
||||
}
|
||||
&_button{
|
||||
padding: 10px;
|
||||
}
|
||||
}
|
||||
@@ -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