mirror of
https://github.com/IgnatZakalinsky/home-works.git
synced 2025-12-18 20:39:24 +00:00
hw8 styles
This commit is contained in:
@@ -19,7 +19,7 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
border: none;
|
border: 1px solid #0066CC;
|
||||||
color: white;
|
color: white;
|
||||||
padding: 5px 24px;
|
padding: 5px 24px;
|
||||||
font-family: 'Montserrat', sans-serif;
|
font-family: 'Montserrat', sans-serif;
|
||||||
|
|||||||
@@ -1,7 +1,44 @@
|
|||||||
.item {
|
.item {
|
||||||
display: flex;
|
height: 48px;
|
||||||
justify-content: space-between;
|
border-bottom: 1px solid #E5E5E5;;
|
||||||
width: 200px;
|
}
|
||||||
|
|
||||||
margin-left: 10px;
|
.item:last-of-type {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.users {
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
|
||||||
|
.buttonsContainer {
|
||||||
|
display: flex;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-end;
|
||||||
|
width: max-content;
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.thead {
|
||||||
|
padding-left: 17px;
|
||||||
|
background-color: #E5E5E5;
|
||||||
|
border: none;
|
||||||
|
height: 36px;
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nameCol {
|
||||||
|
width: 297px;
|
||||||
|
padding-left: 17px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ageCol {
|
||||||
|
width: 284px;
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, { useState } from 'react'
|
import React, {useState} from 'react'
|
||||||
import { homeWorkReducer } from './bll/homeWorkReducer'
|
import {homeWorkReducer} from './bll/homeWorkReducer'
|
||||||
import s from './HW8.module.css'
|
import s from './HW8.module.css'
|
||||||
import s2 from '../../s1-main/App.module.css'
|
import s2 from '../../s1-main/App.module.css'
|
||||||
import SuperButton from '../hw04/common/c2-SuperButton/SuperButton'
|
import SuperButton from '../hw04/common/c2-SuperButton/SuperButton'
|
||||||
@@ -14,49 +14,80 @@ export type UserType = {
|
|||||||
|
|
||||||
const initialPeople: UserType[] = [
|
const initialPeople: UserType[] = [
|
||||||
// студенты могут поменять имя/возраст/количество объектов, _id должны быть целочисленные
|
// студенты могут поменять имя/возраст/количество объектов, _id должны быть целочисленные
|
||||||
{ _id: 0, name: 'Кот', age: 3 },
|
{_id: 0, name: 'Кот', age: 3},
|
||||||
{ _id: 1, name: 'Александр', age: 66 },
|
{_id: 1, name: 'Александр', age: 66},
|
||||||
{ _id: 2, name: 'Коля', age: 16 },
|
{_id: 2, name: 'Коля', age: 16},
|
||||||
{ _id: 3, name: 'Виктор', age: 44 },
|
{_id: 3, name: 'Виктор', age: 44},
|
||||||
{ _id: 4, name: 'Дмитрий', age: 40 },
|
{_id: 4, name: 'Дмитрий', age: 40},
|
||||||
{ _id: 5, name: 'Ирина', age: 55 },
|
{_id: 5, name: 'Ирина', age: 55},
|
||||||
]
|
]
|
||||||
|
|
||||||
const HW8 = () => {
|
const HW8 = () => {
|
||||||
const [people, setPeople] = useState<UserType[]>(initialPeople) // need to fix any
|
const [people, setPeople] = useState<UserType[]>(initialPeople) // need to fix any
|
||||||
|
const [currentSort, setCurrentSort] = useState('')
|
||||||
// need to fix any
|
// need to fix any
|
||||||
const finalPeople = people.map((u: UserType) => <User key={u._id} u={u} />)
|
const finalPeople = people.map((u: UserType) => <User key={u._id} u={u}/>)
|
||||||
|
|
||||||
const sortUp = () =>
|
const sortUp = () => {
|
||||||
setPeople(
|
setPeople(
|
||||||
homeWorkReducer(initialPeople, { type: 'sort', payload: 'up' })
|
homeWorkReducer(initialPeople, {type: 'sort', payload: 'up'})
|
||||||
) // в алфавитном порядке a.name > b.name
|
) // в алфавитном порядке a.name > b.name
|
||||||
const sortDown = () =>
|
setCurrentSort('up')
|
||||||
|
}
|
||||||
|
|
||||||
|
const sortDown = () => {
|
||||||
setPeople(
|
setPeople(
|
||||||
homeWorkReducer(initialPeople, { type: 'sort', payload: 'down' })
|
homeWorkReducer(initialPeople, {type: 'sort', payload: 'down'})
|
||||||
) // в обратном порядке a.name < b.name
|
) // в обратном порядке a.name < b.name}
|
||||||
const check18 = () =>
|
setCurrentSort('down')
|
||||||
|
}
|
||||||
|
const check18 = () => {
|
||||||
setPeople(
|
setPeople(
|
||||||
homeWorkReducer(initialPeople, { type: 'check', payload: 18 })
|
homeWorkReducer(initialPeople, {type: 'check', payload: 18})
|
||||||
) // совершеннолетние
|
) // совершеннолетние
|
||||||
|
setCurrentSort('18')
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div id={'hw3'} className={s2.hw}>
|
<div id={'hw3'}>
|
||||||
<div className={s2.hwTitle}>homeworks 8</div>
|
<div className={s2.hwTitle}>Homework #8</div>
|
||||||
|
<div className={s2.hw}>
|
||||||
|
<div className={s.container}>
|
||||||
|
<div className={s.buttonsContainer}>
|
||||||
|
<SuperButton
|
||||||
|
id={'hw8-button-up'}
|
||||||
|
onClick={sortUp}
|
||||||
|
xType={currentSort === 'up' ? '' : 'secondary'}
|
||||||
|
>
|
||||||
|
Sort up
|
||||||
|
</SuperButton>
|
||||||
|
<SuperButton
|
||||||
|
id={'hw8-button-down'}
|
||||||
|
onClick={sortDown}
|
||||||
|
xType={currentSort === 'down' ? '' : 'secondary'}
|
||||||
|
>
|
||||||
|
Sort down
|
||||||
|
</SuperButton>
|
||||||
|
<SuperButton
|
||||||
|
id={'hw8-button-18'}
|
||||||
|
onClick={check18}
|
||||||
|
xType={currentSort === '18' ? '' : 'secondary'}
|
||||||
|
>
|
||||||
|
Check 18+
|
||||||
|
</SuperButton>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id={'hw8-users'}>{finalPeople}</div>
|
|
||||||
|
|
||||||
<div>
|
<table id={'hw8-users'} className={s.users}>
|
||||||
<SuperButton id={'hw8-button-up'} onClick={sortUp}>
|
<thead className={s.thead}>
|
||||||
sort up
|
<tr>
|
||||||
</SuperButton>
|
<td className={s.nameCol}>Name</td>
|
||||||
<SuperButton id={'hw8-button-down'} onClick={sortDown}>
|
<td className={s.ageCol}>Age</td>
|
||||||
sort down
|
</tr>
|
||||||
</SuperButton>
|
</thead>
|
||||||
<SuperButton id={'hw8-button-18'} onClick={check18}>
|
<tbody>{finalPeople}</tbody>
|
||||||
check 18
|
</table>
|
||||||
</SuperButton>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -9,10 +9,12 @@ type UserPropsType = {
|
|||||||
|
|
||||||
const User: React.FC<UserPropsType> = ({ u }) => {
|
const User: React.FC<UserPropsType> = ({ u }) => {
|
||||||
return (
|
return (
|
||||||
<div id={'hw8-user-' + u._id + '-' + u.age} className={s.item}>
|
<tr id={'hw8-user-' + u._id + '-' + u.age} className={s.item}>
|
||||||
<span id={'hw8-user-name-' + u._id}>{u.name}</span>
|
<td id={'hw8-user-name-' + u._id} className={s.nameCol}>
|
||||||
<span id={'hw8-user-age-' + u._id}>{u.age}</span>
|
{u.name}
|
||||||
</div>
|
</td>
|
||||||
|
<td id={'hw8-user-age-' + u._id}>{u.age}</td>
|
||||||
|
</tr>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user