diff --git a/src/shared/assets/icons/search.svg b/src/shared/assets/icons/search.svg new file mode 100644 index 00000000..f1a516c0 --- /dev/null +++ b/src/shared/assets/icons/search.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/shared/ui/redesigned/Input/ui/Input.module.scss b/src/shared/ui/redesigned/Input/ui/Input.module.scss index ee1a7fb9..40f661fc 100644 --- a/src/shared/ui/redesigned/Input/ui/Input.module.scss +++ b/src/shared/ui/redesigned/Input/ui/Input.module.scss @@ -1,53 +1,48 @@ .inputWrapper { display: flex; + align-items: center; + border-radius: 48px; + padding: 8px 16px; + border: 2px solid var(--icon-redesigned); + height: 38px; + width: 100%; +} + +.addonLeft, +.addonRight { + display: flex; +} + +.withAddonLeft { + padding-left: 8px; } -.placeholder { - margin-right: 5px; +.withAddonRight { + padding-right: 8px; +} + +.focused { + border: 2px solid var(--accent-redesigned); + + .addonLeft svg, + .addonRight svg { + color: var(--accent-redesigned); + } } .input { - background: transparent; border: none; outline: none; + background: none; width: 100%; - color: transparent; + color: var(--text-redesigned); text-shadow: 0 0 0 var(--primary-color); - &:focus { - outline: none; + &::placeholder { + color: var(--hint-redesigned); } } -.caretWrapper { - flex-grow: 1; - position: relative; -} - -.caret { - width: 9px; - height: 3px; - background: var(--primary-color); - bottom: 0; - left: 0; - position: absolute; - animation: blink 0.7s forwards infinite; -} - .readonly { opacity: 0.7; } - -@keyframes blink { - 0% { - opacity: 0; - } - - 50% { - opacity: 0.01; - } - - 100% { - opacity: 1; - } -} diff --git a/src/shared/ui/redesigned/Input/ui/Input.tsx b/src/shared/ui/redesigned/Input/ui/Input.tsx index 172aaee2..36638b34 100644 --- a/src/shared/ui/redesigned/Input/ui/Input.tsx +++ b/src/shared/ui/redesigned/Input/ui/Input.tsx @@ -1,11 +1,4 @@ -import React, { - InputHTMLAttributes, - memo, - SyntheticEvent, - useEffect, - useRef, - useState, -} from 'react'; +import { InputHTMLAttributes, memo, ReactNode, useEffect, useRef, useState } from 'react'; import { classNames, Mods } from '@/shared/lib/classNames'; @@ -22,6 +15,8 @@ interface InputProps extends HTMLInputProps { onChange?: (value: string) => void; autofocus?: boolean; readonly?: boolean; + addonLeft?: ReactNode; + addonRight?: ReactNode; } export const Input = memo((props: InputProps) => { @@ -33,15 +28,14 @@ export const Input = memo((props: InputProps) => { placeholder, autofocus, readonly, + addonLeft, + addonRight, ...otherProps } = props; const ref = useRef(null); const [isFocused, setIsFocused] = useState(false); - const [caretPosition, setCaretPosition] = useState(0); - - const isCaretVisible = isFocused && !readonly; useEffect(() => { if (autofocus) { @@ -51,8 +45,6 @@ export const Input = memo((props: InputProps) => { const changeHandler = (e: React.ChangeEvent) => { onChange?.(e.target.value); - - setCaretPosition(e.target.value.length); }; const onBlur = () => { @@ -63,36 +55,31 @@ export const Input = memo((props: InputProps) => { setIsFocused(true); }; - const onSelect = (event: SyntheticEvent) => { - setCaretPosition(event?.currentTarget?.selectionStart || 0); - }; - const mods: Mods = { [cls.readonly]: readonly, + [cls.focused]: isFocused, + [cls.withAddonLeft]: Boolean(addonLeft), + [cls.withAddonRight]: Boolean(addonRight), }; return (
- {!!placeholder &&
{`${placeholder}>`}
} - -
- - - {isCaretVisible && ( - - )} -
+ {!!addonLeft &&
{addonLeft}
} + + + + {!!addonRight &&
{addonRight}
}
); }); diff --git a/src/widgets/ArticlesFilters/ArticlesFilters.tsx b/src/widgets/ArticlesFilters/ArticlesFilters.tsx index 22e934c9..f209256d 100644 --- a/src/widgets/ArticlesFilters/ArticlesFilters.tsx +++ b/src/widgets/ArticlesFilters/ArticlesFilters.tsx @@ -9,6 +9,8 @@ import { ArticleTypeTabs } from '@/features/articleTypeTabs'; import { VStack } from '@/shared/ui/redesigned/Stack'; import { ArticleSortField, ArticleType } from '@/entities/Article'; import { SortOrder } from '@/shared/types/sort'; +import SearchIcon from '@/shared/assets/icons/search.svg'; +import { Icon } from '@/shared/ui/redesigned/Icon'; import cls from './ArticlesFilters.module.scss'; @@ -41,7 +43,12 @@ export const ArticlesFilters = memo((props: ArticlesFiltersProps) => { return ( - + } + />