-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/category on main page #180
Conversation
|
||
const findNumbersToShow = useCallback(() => { | ||
if (isMobileScreen) { | ||
setNumberToShow(6); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Можно return вместе с сеттером написать:
setNumberToShow(6); | |
return setNumberToShow(6); |
}; | ||
|
||
useEffect(() => { | ||
api.categoriesList().then((categories) => setCategories(categories)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Можно сократить:
api.categoriesList().then((categories) => setCategories(categories)); | |
api.categoriesList().then(setCategories); |
return ( | ||
<> | ||
<div className={styles.link}> | ||
<TitleArrowLink title="Каталог" link="/catalog/" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Чтобы не плодить обертки у компонента "TitleArrowLink" можно добавить props classnames и получить что-то вроде этого:
<TitleArrowLink title="Каталог" link="/catalog/" /> | |
<TitleArrowLink title="Каталог" link="/catalog/" classnames={styles.link} /> |
В компоненте "TitleArrowLink" нужно будет доработать логику маленько:
<TitleArrowLink title="Каталог" link="/catalog/" /> | |
const TitleArrowLink: React.FC<TitleArrowLinkProps> = ({ title, link, type, classnames }) => { | |
return ( | |
<Link to={link} className={cn(styles.link, classnames)}> | |
<p | |
className={clsx( | |
styles.link__title, | |
type === 'catalogPage' && styles.link__title_type_smallFont | |
)} | |
> | |
{title} | |
</p> | |
<ArrowIcon | |
className={clsx( | |
styles.link__arrow, | |
type === 'catalogPage' && styles.link__arrow_type_small | |
)} | |
/> | |
</Link> | |
); | |
}; |
<p className={styles.catalogPromo__text} onClick={handleCategoryToggle}> | ||
{numberToShow < 12 ? 'Развернуть' : 'Свернуть'} | ||
</p> | ||
<span |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не верный элемент, нужно заменить на button. С клавиатуры не возможно будет сфокусироваться на этом элементе, почитай про доступность (https://developer.mozilla.org/ru/docs/Learn/Accessibility/HTML)
#179
change old catalog component on main page to new one