mirror of
https://github.com/IgnatZakalinsky/home-works.git
synced 2026-01-30 20:42:04 +00:00
hw3 + hw4
This commit is contained in:
@@ -1,61 +1,80 @@
|
||||
.greetingForm {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
padding: 31px 0 0 70px;
|
||||
height: 336px;
|
||||
}
|
||||
|
||||
.inputAndButtonContainer {
|
||||
display: flex;
|
||||
gap: 24px;
|
||||
margin-bottom: 22px;
|
||||
}
|
||||
|
||||
.error {
|
||||
position: absolute;
|
||||
color: red;
|
||||
margin-left: 10px;
|
||||
margin-top: -14px;
|
||||
margin-left: 14px;
|
||||
margin-top: -28px;
|
||||
}
|
||||
|
||||
.input {
|
||||
margin: 10px;
|
||||
|
||||
background: #003300;
|
||||
color: #99ff99;
|
||||
border: 1px solid #d1d1d1;
|
||||
border-radius: 5px;
|
||||
width: 370px;
|
||||
font-family: 'Montserrat', sans-serif;
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
font-size: 16px;
|
||||
line-height: 20px;
|
||||
padding: 8px 0 8px 12px;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.input:focus {
|
||||
outline: none;
|
||||
border: #99ff99 solid 2px;
|
||||
border: 1px solid #06c;
|
||||
}
|
||||
|
||||
.errorInput {
|
||||
margin: 10px;
|
||||
|
||||
background: #003300;
|
||||
color: #99ff99;
|
||||
|
||||
border: 2px solid red;
|
||||
outline: none;
|
||||
border: 1px solid red;
|
||||
}
|
||||
|
||||
.button {
|
||||
margin: 10px;
|
||||
width: 60px;
|
||||
|
||||
background: #003300;
|
||||
color: #99ff99;
|
||||
margin-left: 12px;
|
||||
background: #06c;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 15px;
|
||||
outline: none;
|
||||
padding: 8px 24px;
|
||||
font-family: 'Montserrat', sans-serif;
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
line-height: 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.button:focus {
|
||||
outline: #99ff99 solid 1px;
|
||||
|
||||
}
|
||||
|
||||
.button:active {
|
||||
background: #99ff99;
|
||||
|
||||
}
|
||||
|
||||
.button:disabled {
|
||||
color: #005500;
|
||||
opacity: 0.6;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.count {
|
||||
margin: 10px;
|
||||
font-family: 'Montserrat', sans-serif;
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
line-height: 17px;
|
||||
margin-bottom: 9px;
|
||||
}
|
||||
|
||||
.greeting {
|
||||
margin-left: 10px;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, {ChangeEvent, KeyboardEvent} from 'react'
|
||||
import React, { ChangeEvent, KeyboardEvent } from 'react'
|
||||
import s from './Greeting.module.css'
|
||||
|
||||
type GreetingPropsType = {
|
||||
@@ -16,24 +16,28 @@ type GreetingPropsType = {
|
||||
const Greeting: React.FC<GreetingPropsType> = (
|
||||
{name, setNameCallback, addUser, onEnter, error, totalUsers, lastUser, onBlur} // деструктуризация пропсов
|
||||
) => {
|
||||
const inputClass = error ? s.errorInput : s.input // need to fix with (?:)
|
||||
const inputClass = error ? `${s.input} ${s.errorInput}` : s.input // need to fix with (?:)
|
||||
|
||||
return (
|
||||
<div id={'hw3-form'} className={s.greetingForm}>
|
||||
<div>
|
||||
<input
|
||||
id={'hw3-input'}
|
||||
value={name}
|
||||
onChange={setNameCallback}
|
||||
className={inputClass}
|
||||
onKeyDown={onEnter}
|
||||
onBlur={onBlur}
|
||||
/>
|
||||
<div id={'hw3-error'} className={s.error}>{error}</div>
|
||||
<div id={'hw3-users-total'} className={s.count}>{totalUsers}</div>
|
||||
<div className={s.inputAndButtonContainer}>
|
||||
<div>
|
||||
<input
|
||||
id={'hw3-input'}
|
||||
value={name}
|
||||
onChange={setNameCallback}
|
||||
className={inputClass}
|
||||
onKeyDown={onEnter}
|
||||
onBlur={onBlur}
|
||||
/>
|
||||
<div id={'hw3-error'} className={s.error}>{error}</div>
|
||||
</div>
|
||||
|
||||
<button id={'hw3-button'} onClick={addUser} className={s.button} disabled={!name}>add</button>
|
||||
|
||||
</div>
|
||||
|
||||
<button id={'hw3-button'} onClick={addUser} className={s.button} disabled={!name}>add</button>
|
||||
<div id={'hw3-users-total'} className={s.count}>{totalUsers}</div>
|
||||
{lastUser && (
|
||||
<div className={s.greeting}>
|
||||
hello{' '}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, {ChangeEvent, KeyboardEvent, useState} from 'react'
|
||||
import React, { ChangeEvent, KeyboardEvent, useState } from 'react'
|
||||
import Greeting from './Greeting'
|
||||
import {UserType} from './HW3'
|
||||
import { UserType } from './HW3'
|
||||
|
||||
type GreetingContainerPropsType = {
|
||||
users: UserType[] // need to fix any
|
||||
@@ -28,7 +28,7 @@ const GreetingContainer: React.FC<GreetingContainerPropsType> = ({users, addUser
|
||||
const trimmedName = name.trim()
|
||||
|
||||
if (!trimmedName) {
|
||||
setError('name is require!')
|
||||
setError('name is required!')
|
||||
}
|
||||
setName(trimmedName) // need to fix
|
||||
}
|
||||
@@ -39,7 +39,7 @@ const GreetingContainer: React.FC<GreetingContainerPropsType> = ({users, addUser
|
||||
|
||||
if (!trimmedName) {
|
||||
setName('')
|
||||
setError('name is require!')
|
||||
setError('name is required!')
|
||||
} else {
|
||||
addUserCallback(trimmedName)
|
||||
setName('')
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, {useState} from 'react'
|
||||
import {v1} from 'uuid'
|
||||
import React, { useState } from 'react'
|
||||
import { v1 } from 'uuid'
|
||||
import s from './Greeting.module.css'
|
||||
import s2 from '../../s1-main/App.module.css'
|
||||
import GreetingContainer from './GreetingContainer'
|
||||
@@ -23,16 +23,17 @@ const HW3 = () => {
|
||||
|
||||
return (
|
||||
<div id={'hw3'} className={s2.hw}>
|
||||
<hr/>
|
||||
{/*<hr/>*/}
|
||||
{/*можно убрать этот тег*/}
|
||||
|
||||
<div className={s2.hwTitle}>homeworks 3</div>
|
||||
<div className={s2.hwTitle}>Homework #3</div>
|
||||
|
||||
{/*для автоматической проверки дз (не менять)*/}
|
||||
<GreetingContainer users={users} addUserCallback={addUserCallback}/>
|
||||
|
||||
|
||||
<hr/>
|
||||
{/*можно убрать этот тег*/}
|
||||
<GreetingContainer users={users} addUserCallback={addUserCallback}/>
|
||||
<hr/>
|
||||
{/*можно убрать этот тег*/}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user