Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 88a8a47cc5 | |||
| 6272da5e32 | |||
| e23d112551 | |||
| 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: #ecfeff;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
|||||||
Generated
+14
-44
@@ -8,10 +8,8 @@
|
|||||||
"name": "store-client",
|
"name": "store-client",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"immer": "^11.1.8",
|
|
||||||
"react": "^19.1.0",
|
"react": "^19.1.0",
|
||||||
"react-dom": "^19.1.0",
|
"react-dom": "^19.1.0"
|
||||||
"zustand": "^5.0.14"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.25.0",
|
"@eslint/js": "^9.25.0",
|
||||||
@@ -22,6 +20,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",
|
||||||
|
"react-icons": "^5.6.0",
|
||||||
"vite": "^6.3.5"
|
"vite": "^6.3.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1369,7 +1368,7 @@
|
|||||||
"version": "19.1.6",
|
"version": "19.1.6",
|
||||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.1.6.tgz",
|
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.1.6.tgz",
|
||||||
"integrity": "sha512-JeG0rEWak0N6Itr6QUx+X60uQmN+5t3j9r/OVDtWzFXKaj6kD1BwJzOksD0FF6iWxZlbE1kB0q9vtnU2ekqa1Q==",
|
"integrity": "sha512-JeG0rEWak0N6Itr6QUx+X60uQmN+5t3j9r/OVDtWzFXKaj6kD1BwJzOksD0FF6iWxZlbE1kB0q9vtnU2ekqa1Q==",
|
||||||
"devOptional": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"csstype": "^3.0.2"
|
"csstype": "^3.0.2"
|
||||||
@@ -1621,7 +1620,7 @@
|
|||||||
"version": "3.1.3",
|
"version": "3.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz",
|
||||||
"integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==",
|
"integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==",
|
||||||
"devOptional": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/debug": {
|
"node_modules/debug": {
|
||||||
@@ -2056,16 +2055,6 @@
|
|||||||
"node": ">= 4"
|
"node": ">= 4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/immer": {
|
|
||||||
"version": "11.1.8",
|
|
||||||
"resolved": "https://registry.npmjs.org/immer/-/immer-11.1.8.tgz",
|
|
||||||
"integrity": "sha512-/tbkHMW7y10Lx6i1crLjD4/OhNkRG+Fo7byZHtah0547nIeXYcpIXaUh0IAQY6gO5459qpGGYapcEOHtFXkIuA==",
|
|
||||||
"license": "MIT",
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/immer"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/import-fresh": {
|
"node_modules/import-fresh": {
|
||||||
"version": "3.3.1",
|
"version": "3.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz",
|
||||||
@@ -2473,6 +2462,16 @@
|
|||||||
"react": "^19.1.0"
|
"react": "^19.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/react-icons": {
|
||||||
|
"version": "5.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-icons/-/react-icons-5.6.0.tgz",
|
||||||
|
"integrity": "sha512-RH93p5ki6LfOiIt0UtDyNg/cee+HLVR6cHHtW3wALfo+eOHTp8RnU2kRkI6E+H19zMIs03DyxUG/GfZMOGvmiA==",
|
||||||
|
"dev": true,
|
||||||
|
"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",
|
||||||
@@ -2806,35 +2805,6 @@
|
|||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/sponsors/sindresorhus"
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"node_modules/zustand": {
|
|
||||||
"version": "5.0.14",
|
|
||||||
"resolved": "https://registry.npmjs.org/zustand/-/zustand-5.0.14.tgz",
|
|
||||||
"integrity": "sha512-/8tAspM5LMPr28b3fwLYrtdj77ECpfZviaP75CMTnwO8ISyaE4GDIG/9rDDYq/cH9D2Xw2A2RXglLInmVBQB/g==",
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=12.20.0"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"@types/react": ">=18.0.0",
|
|
||||||
"immer": ">=9.0.6",
|
|
||||||
"react": ">=18.0.0",
|
|
||||||
"use-sync-external-store": ">=1.2.0"
|
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"@types/react": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"immer": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"react": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"use-sync-external-store": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-3
@@ -10,10 +10,8 @@
|
|||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"immer": "^11.1.8",
|
|
||||||
"react": "^19.1.0",
|
"react": "^19.1.0",
|
||||||
"react-dom": "^19.1.0",
|
"react-dom": "^19.1.0"
|
||||||
"zustand": "^5.0.14"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.25.0",
|
"@eslint/js": "^9.25.0",
|
||||||
@@ -24,6 +22,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",
|
||||||
|
"react-icons": "^5.6.0",
|
||||||
"vite": "^6.3.5"
|
"vite": "^6.3.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+65
-3
@@ -1,10 +1,72 @@
|
|||||||
import Quiz from './components/Quiz'
|
import styles from './App.module.css'
|
||||||
|
import SneakersImage from './assets/images/sneakers-image.jpg'
|
||||||
|
import { FaRegUser } from 'react-icons/fa'
|
||||||
|
|
||||||
|
function handleClick(i) {
|
||||||
|
console.log(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
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() {
|
||||||
|
const handlerMouseEnter = event => {
|
||||||
|
const img = event.target;
|
||||||
|
img.style.border = '5px solid yellow';
|
||||||
|
}
|
||||||
|
const handlerMouseOut = event => {
|
||||||
|
const img = event.target;
|
||||||
|
img.style.border = '';
|
||||||
|
console.log(event);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div className={styles.product}>
|
||||||
|
<img src={SneakersImage} alt='' onMouseEnter={handlerMouseEnter} onMouseOut={handlerMouseOut} />
|
||||||
|
<div className={styles.content}>
|
||||||
|
<div className={styles.title}>
|
||||||
|
<h4>Sneakers Red & White 2025</h4>
|
||||||
|
<button onClick={() => handleClick(0)} onMouseEnter={handlerMouseEnter} onMouseOut={handlerMouseOut}>+</button>
|
||||||
|
</div>
|
||||||
|
<p className={styles.description}>NIKE</p>
|
||||||
|
<p className={styles.price}>$38.00</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<h1>Практика по созданию списка задач</h1>
|
<div className={styles.container}>
|
||||||
<Quiz />
|
<Header />
|
||||||
|
<ul className={styles.list}>
|
||||||
|
<li>
|
||||||
|
<Product />
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<Product />
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<Product />
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,123 @@
|
|||||||
|
@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;
|
||||||
|
|
||||||
|
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;
|
||||||
|
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 {
|
||||||
|
background-color: black;
|
||||||
|
color: white;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 50%;
|
||||||
|
outline: 0;
|
||||||
|
|
||||||
|
font-size: 20px;
|
||||||
|
padding: 5px 10px;
|
||||||
|
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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,31 +0,0 @@
|
|||||||
import { useState } from 'react'
|
|
||||||
|
|
||||||
const Question = ({question, onSubmit}) => {
|
|
||||||
const [selectedOption,setSelectedOption] = useState('')
|
|
||||||
const handleSubmit = () => {
|
|
||||||
console.log(selectedOption);
|
|
||||||
if (selectedOption) onSubmit(selectedOption);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<h2>Вопрос {question.id}: {question.text}</h2>
|
|
||||||
<div>
|
|
||||||
{question.options.map((option, index)=>(
|
|
||||||
<label key={index}>
|
|
||||||
<input
|
|
||||||
type="radio"
|
|
||||||
name={`question-${question.id}`}
|
|
||||||
value={option}
|
|
||||||
checked={selectedOption === option}
|
|
||||||
onChange={() => setSelectedOption(option)} />
|
|
||||||
{option}
|
|
||||||
</label>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
<button onClick={handleSubmit} >Следующий вопрос</button>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Question
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
import useQuizStore from './store/useQuizStore'
|
|
||||||
import Question from './Question'
|
|
||||||
import Result from './Result'
|
|
||||||
|
|
||||||
const Quiz = () => {
|
|
||||||
const {
|
|
||||||
questions,
|
|
||||||
currentQuestion,
|
|
||||||
userAswers,
|
|
||||||
isFinished,
|
|
||||||
submitAnswer,
|
|
||||||
goToNextQuestion,
|
|
||||||
restartQuiz,
|
|
||||||
} = useQuizStore();
|
|
||||||
|
|
||||||
const handleAnswerSubmit = (anwser) => {
|
|
||||||
console.log('Yes')
|
|
||||||
submitAnswer(answer)
|
|
||||||
if (currentQuestion < questions.length - 1 ) {
|
|
||||||
goToNextQuestion()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(isFinished) {
|
|
||||||
return (<Result />)
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<div className="quiz">
|
|
||||||
<Question
|
|
||||||
question={questions[currentQuestion]}
|
|
||||||
onSubmit={handleAnswerSubmit} />
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Quiz
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
const Result = ({questions, userAswers, onRestart}) => {
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<h2>Результат</h2>
|
|
||||||
<button onClick={onRestart}>Начать заново</button>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
export default Result
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
import { create } from 'zustand'
|
|
||||||
|
|
||||||
const useQuizStore = create(set => ({
|
|
||||||
questions: [
|
|
||||||
{
|
|
||||||
id:1,
|
|
||||||
text: 'Сколько будет 2+2?',
|
|
||||||
options: ['3','4','2'],
|
|
||||||
correctAnswer: '4',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id:2,
|
|
||||||
text: 'Столица России?',
|
|
||||||
options: ['Москва','Париж','Лондон'],
|
|
||||||
correctAnswer: 'Москва',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
currentQuestion: 0,
|
|
||||||
userAnswer:[],
|
|
||||||
isFinished: false,
|
|
||||||
goToNextQuestion: () => set(state => ({
|
|
||||||
currentQuestion: state.currentQuestion + 1,
|
|
||||||
})),
|
|
||||||
submitAnswer: answer => set(state => {
|
|
||||||
const updatedAnswer = [...state.userAnswer, answer];
|
|
||||||
const isFinished = (state.currentQuestion >= state.questions.length - 1);
|
|
||||||
return {userAnswer: updatedAnswer, isFinished};
|
|
||||||
}),/*
|
|
||||||
restartQuiz: () => set({
|
|
||||||
currentQuestion: 0,
|
|
||||||
userAnswer: [],
|
|
||||||
isFinished: false
|
|
||||||
}), */
|
|
||||||
}))
|
|
||||||
|
|
||||||
export default useQuizStore
|
|
||||||
+2
-1
@@ -1,8 +1,9 @@
|
|||||||
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(
|
||||||
|
<StrictMode>
|
||||||
<App />
|
<App />
|
||||||
|
</StrictMode>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user