diff --git a/src/s2-homeworks/hw10/HW10.tsx b/src/s2-homeworks/hw10/HW10.tsx index 1f462e0..66f01f7 100644 --- a/src/s2-homeworks/hw10/HW10.tsx +++ b/src/s2-homeworks/hw10/HW10.tsx @@ -26,7 +26,7 @@ const HW10 = () => { return (
-
homeworks 10
+
Homework #10
{/*should work (должно работать)*/}
diff --git a/src/s2-homeworks/hw11/HW11.module.css b/src/s2-homeworks/hw11/HW11.module.css new file mode 100644 index 0000000..be956c0 --- /dev/null +++ b/src/s2-homeworks/hw11/HW11.module.css @@ -0,0 +1,15 @@ +.container { + display: flex; + flex-direction: column; + gap: 40px; +} + +.wrapper { + display: flex; + align-items: center; + gap: 25px; + font-family: 'Montserrat', sans-serif; + font-weight: 600; + font-size: 16px; + line-height: 20px; +} diff --git a/src/s2-homeworks/hw11/HW11.tsx b/src/s2-homeworks/hw11/HW11.tsx index 20c7d87..e6e5f9c 100644 --- a/src/s2-homeworks/hw11/HW11.tsx +++ b/src/s2-homeworks/hw11/HW11.tsx @@ -1,9 +1,8 @@ import React, { useState } from 'react' -import SuperRange from './common/c7-SuperRange/SuperRange' -import SuperDoubleRange from './common/c8-SuperDoubleRange/SuperDoubleRange' +import s from './HW11.module.css' import s2 from '../../s1-main/App.module.css' import { restoreState } from '../hw06/localStorage/localStorage' -import { Slider } from '@mui/material' +import SuperRange from './common/c7-SuperRange/SuperRange' function HW11() { const [value1, setValue1] = useState(restoreState('hw11-value1', 0)) @@ -21,43 +20,29 @@ function HW11() { } return ( -
-
homeworks 11
+
+
Homework #11
{/*should work (должно работать)*/} -
- - {value1} - - -
- -
- - {value1} - - - - {value2} - +
+
+
+ {value1} + +
+
+ {value1} + + {value2} +
+
) diff --git a/src/s2-homeworks/hw11/common/c7-SuperRange/SuperRange.module.css b/src/s2-homeworks/hw11/common/c7-SuperRange/SuperRange.module.css deleted file mode 100644 index 2d49ab4..0000000 --- a/src/s2-homeworks/hw11/common/c7-SuperRange/SuperRange.module.css +++ /dev/null @@ -1,21 +0,0 @@ -.range { - appearance: none; - width: 160px; - - outline: none; - border-radius: 3px; - background: #99ff99; -} - -.range::-webkit-slider-thumb { - appearance: none; - position: relative; - width: 16px; - height: 16px; - top: 3px; - margin-top: -6px; - - background: red; - cursor: pointer; - z-index: 2; -} diff --git a/src/s2-homeworks/hw11/common/c7-SuperRange/SuperRange.tsx b/src/s2-homeworks/hw11/common/c7-SuperRange/SuperRange.tsx index 5103e06..66d1139 100644 --- a/src/s2-homeworks/hw11/common/c7-SuperRange/SuperRange.tsx +++ b/src/s2-homeworks/hw11/common/c7-SuperRange/SuperRange.tsx @@ -1,47 +1,41 @@ -import React, { - ChangeEvent, - DetailedHTMLProps, - InputHTMLAttributes, -} from 'react' -import s from './SuperRange.module.css' +import React from 'react' +import { Slider, SliderProps } from '@mui/material' -// тип пропсов обычного инпута -type DefaultInputPropsType = DetailedHTMLProps< - InputHTMLAttributes, - HTMLInputElement -> - -// здесь мы говорим что у нашего инпута будут такие же пропсы как у обычного инпута +// здесь мы говорим что у нашего слайдера будут такие же пропсы как у обычного mui слайдера // (чтоб не писать value: string, onChange: ...; они уже все описаны в DefaultInputPropsType) -type SuperRangePropsType = DefaultInputPropsType & { - // и + ещё пропсы которых нет в стандартном инпуте - onChangeRange?: (value: number) => void -} +type SuperRangePropsType = SliderProps const SuperRange: React.FC = ({ - type, // достаём и игнорируем чтоб нельзя было задать другой тип инпута - onChange, - onChangeRange, - className, - ...restProps // все остальные пропсы попадут в объект restProps }) => { - const onChangeCallback = (e: ChangeEvent) => { - onChange && onChange(e) // сохраняем старую функциональность - - onChangeRange && onChangeRange(+e.currentTarget.value) - } - - const finalRangeClassName = `${s.range} ${className ? className : ''}` - - // взять одинарный ползунок из материал-юай и повесить на него ид return ( <> - diff --git a/src/s2-homeworks/hw11/common/c8-SuperDoubleRange/SuperDoubleRange.tsx b/src/s2-homeworks/hw11/common/c8-SuperDoubleRange/SuperDoubleRange.tsx deleted file mode 100644 index f39d87a..0000000 --- a/src/s2-homeworks/hw11/common/c8-SuperDoubleRange/SuperDoubleRange.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import React, { DetailedHTMLProps, InputHTMLAttributes } from 'react' -import SuperRange from '../c7-SuperRange/SuperRange' - -type DefaultInputPropsType = DetailedHTMLProps< - InputHTMLAttributes, - HTMLInputElement -> - -type SuperDoubleRangePropsType = Omit & { - onChangeRange?: (value: [number, number]) => void - value?: [number, number] - // min, max, step, disable, ... -} - -const SuperDoubleRange: React.FC = ({ - onChangeRange, - value, - // min, max, step, disable, ... - ...restProps -}) => { - // сделать самому, можно подключать библиотеки - const [value1, value2] = value || [-1, -1] - - const change1 = (n: number) => { - if (n <= value2) onChangeRange?.([n, value2]) - } - const change2 = (n: number) => { - if (value1 <= n) onChangeRange?.([value1, n]) - } - - // взять двойной ползунок из материал-юай и повесить на него ид - return ( -
- - -
- ) -} - -export default SuperDoubleRange