diff --git a/src/s2-homeworks/hw04/common/c2-SuperButton/SuperButton.module.css b/src/s2-homeworks/hw04/common/c2-SuperButton/SuperButton.module.css index 7113dcd..b11b31d 100644 --- a/src/s2-homeworks/hw04/common/c2-SuperButton/SuperButton.module.css +++ b/src/s2-homeworks/hw04/common/c2-SuperButton/SuperButton.module.css @@ -19,7 +19,7 @@ overflow: hidden; cursor: pointer; border-radius: 3px; - border: none; + border: 1px solid #0066CC; color: white; padding: 5px 24px; font-family: 'Montserrat', sans-serif; diff --git a/src/s2-homeworks/hw08/HW8.module.css b/src/s2-homeworks/hw08/HW8.module.css index 6b10cf2..ce36473 100644 --- a/src/s2-homeworks/hw08/HW8.module.css +++ b/src/s2-homeworks/hw08/HW8.module.css @@ -1,7 +1,44 @@ .item { - display: flex; - justify-content: space-between; - width: 200px; - - margin-left: 10px; + height: 48px; + border-bottom: 1px solid #E5E5E5;; } + +.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; +} \ No newline at end of file diff --git a/src/s2-homeworks/hw08/HW8.tsx b/src/s2-homeworks/hw08/HW8.tsx index 062e384..4fe190e 100644 --- a/src/s2-homeworks/hw08/HW8.tsx +++ b/src/s2-homeworks/hw08/HW8.tsx @@ -1,5 +1,5 @@ -import React, { useState } from 'react' -import { homeWorkReducer } from './bll/homeWorkReducer' +import React, {useState} from 'react' +import {homeWorkReducer} from './bll/homeWorkReducer' import s from './HW8.module.css' import s2 from '../../s1-main/App.module.css' import SuperButton from '../hw04/common/c2-SuperButton/SuperButton' @@ -14,49 +14,80 @@ export type UserType = { const initialPeople: UserType[] = [ // студенты могут поменять имя/возраст/количество объектов, _id должны быть целочисленные - { _id: 0, name: 'Кот', age: 3 }, - { _id: 1, name: 'Александр', age: 66 }, - { _id: 2, name: 'Коля', age: 16 }, - { _id: 3, name: 'Виктор', age: 44 }, - { _id: 4, name: 'Дмитрий', age: 40 }, - { _id: 5, name: 'Ирина', age: 55 }, + {_id: 0, name: 'Кот', age: 3}, + {_id: 1, name: 'Александр', age: 66}, + {_id: 2, name: 'Коля', age: 16}, + {_id: 3, name: 'Виктор', age: 44}, + {_id: 4, name: 'Дмитрий', age: 40}, + {_id: 5, name: 'Ирина', age: 55}, ] const HW8 = () => { const [people, setPeople] = useState(initialPeople) // need to fix any - + const [currentSort, setCurrentSort] = useState('') // need to fix any - const finalPeople = people.map((u: UserType) => ) + const finalPeople = people.map((u: UserType) => ) - const sortUp = () => + const sortUp = () => { setPeople( - homeWorkReducer(initialPeople, { type: 'sort', payload: 'up' }) + homeWorkReducer(initialPeople, {type: 'sort', payload: 'up'}) ) // в алфавитном порядке a.name > b.name - const sortDown = () => + setCurrentSort('up') + } + + const sortDown = () => { setPeople( - homeWorkReducer(initialPeople, { type: 'sort', payload: 'down' }) - ) // в обратном порядке a.name < b.name - const check18 = () => + homeWorkReducer(initialPeople, {type: 'sort', payload: 'down'}) + ) // в обратном порядке a.name < b.name} + setCurrentSort('down') + } + const check18 = () => { setPeople( - homeWorkReducer(initialPeople, { type: 'check', payload: 18 }) + homeWorkReducer(initialPeople, {type: 'check', payload: 18}) ) // совершеннолетние + setCurrentSort('18') + } return ( -
-
homeworks 8
+
+
Homework #8
+
+
+
+ + Sort up + + + Sort down + + + Check 18+ + +
-
{finalPeople}
-
- - sort up - - - sort down - - - check 18 - + + + + + + + + {finalPeople} +
NameAge
+
) diff --git a/src/s2-homeworks/hw08/User.tsx b/src/s2-homeworks/hw08/User.tsx index b3202d5..acda042 100644 --- a/src/s2-homeworks/hw08/User.tsx +++ b/src/s2-homeworks/hw08/User.tsx @@ -9,10 +9,12 @@ type UserPropsType = { const User: React.FC = ({ u }) => { return ( -
- {u.name} - {u.age} -
+ + + {u.name} + + {u.age} + ) }