Skip to content

Commit

Permalink
feat: remove old design for articles
Browse files Browse the repository at this point in the history
  • Loading branch information
TomatoVan committed Apr 23, 2024
1 parent 808b8d4 commit 1753c48
Show file tree
Hide file tree
Showing 9 changed files with 941 additions and 1,112 deletions.
3 changes: 0 additions & 3 deletions extractedTranslations/en/Sort by.json

This file was deleted.

56 changes: 28 additions & 28 deletions extractedTranslations/en/profile.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
{
"": "",
"Age": "",
"Avatar": "",
"City": "",
"Edit": "",
"Error": "",
"Error with getting profile data": "",
"Error with profile ": "",
"Incorrect age": "",
"Incorrect country": "",
"Incorrect user data": "",
"Lastname": "",
"Name": "",
"No data": "",
"Profile": "",
"Server error": "",
"Try to reload page": "",
"Username": "",
"Username>": "",
"Your age": "",
"Your avatar": "",
"Your city": "",
"Your lastname": "",
"Your name": "",
"Your surname": "",
"Your username": "",
"Попробуйте обновить страницу": "",
"Произошла ошибка при загрузке профиля": ""
"": "",
"Age": "",
"Avatar": "",
"City": "",
"Edit": "",
"Error": "",
"Error with getting profile data": "",
"Error with profile ": "",
"Incorrect age": "",
"Incorrect country": "",
"Incorrect user data": "",
"Lastname": "",
"Name": "",
"No data": "",
"Profile": "",
"Server error": "",
"Try to reload page": "",
"Username": "",
"Username>": "",
"Your age": "",
"Your avatar": "",
"Your city": "",
"Your lastname": "",
"Your name": "",
"Your surname": "",
"Your username": "",
"Попробуйте обновить страницу": "",
"Произошла ошибка при загрузке профиля": ""
}
3 changes: 0 additions & 3 deletions extractedTranslations/en/Сортировать по.json

This file was deleted.

1,760 changes: 855 additions & 905 deletions json-server/db.json

Large diffs are not rendered by default.

28 changes: 7 additions & 21 deletions src/features/ArticleTypeTabs/ui/ArticleTypeTabs.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { useTranslation } from 'react-i18next';
import { memo, useCallback, useMemo } from 'react';
import { classNames } from '@/shared/lib/classNames/classNames';
import { TabItem, Tabs as TabsDeprecated } from '@/shared/ui/deprecated/Tabs';
import { TabItem } from '@/shared/ui/deprecated/Tabs';
import { ArticleType } from '@/entities/Article';
import { ToggleFeatures } from '@/shared/lib/features';
import { Tabs } from '@/shared/ui/redesigned/Tabs';

interface ArticleTypeTabsProps {
Expand Down Expand Up @@ -46,25 +45,12 @@ export const ArticleTypeTabs = memo((props: ArticleTypeTabsProps) => {
);

return (
<ToggleFeatures
feature="isAppRedesigned"
on={
<Tabs
direction="column"
tabs={typeTabs}
value={value}
onTabClick={onTabClick}
className={classNames('', {}, [className])}
/>
}
off={
<TabsDeprecated
tabs={typeTabs}
value={value}
onTabClick={onTabClick}
className={classNames('', {}, [className])}
/>
}
<Tabs
direction="column"
tabs={typeTabs}
value={value}
onTabClick={onTabClick}
className={classNames('', {}, [className])}
/>
);
});
90 changes: 21 additions & 69 deletions src/features/ArticleViewSelector/ui/ArticleViewSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
import { memo } from 'react';
import { classNames } from '@/shared/lib/classNames/classNames';
import ListIconDeprecated from '@/shared/assets/icons/list-24-24.svg';
import TiledIconDeprecated from '@/shared/assets/icons/tiled-24-24.svg';

import ListIcon from '@/shared/assets/icons/burger.svg';
import TiledIcon from '@/shared/assets/icons/tile.svg';

import { Icon as IconDeprecated } from '@/shared/ui/deprecated/Icon';
import {
Button as ButtonDeprecated,
ButtonTheme,
} from '@/shared/ui/deprecated/Button';
import cls from './ArticleViewSelector.module.scss';
import { ArticleView } from '@/entities/Article';
import { ToggleFeatures, toggleFeatures } from '@/shared/lib/features';
import { Icon } from '@/shared/ui/redesigned/Icon';
import { Card } from '@/shared/ui/redesigned/Card';
import { HStack } from '@/shared/ui/redesigned/Stack';
Expand All @@ -27,19 +18,11 @@ interface ArticleViewSelectorProps {
const viewTypes = [
{
view: ArticleView.SMALL,
icon: toggleFeatures({
name: 'isAppRedesigned',
on: () => TiledIcon,
off: () => TiledIconDeprecated,
}),
icon: TiledIcon,
},
{
view: ArticleView.BIG,
icon: toggleFeatures({
name: 'isAppRedesigned',
on: () => ListIcon,
off: () => ListIconDeprecated,
}),
icon: ListIcon,
},
];

Expand All @@ -51,55 +34,24 @@ export const ArticleViewSelector = memo((props: ArticleViewSelectorProps) => {
};

return (
<ToggleFeatures
feature="isAppRedesigned"
on={
<Card
className={classNames(
cls.ArticleViewSelectorRedesigned,
{},
[className],
)}
border="round"
>
<HStack gap="8">
{viewTypes.map((viewType) => (
<Icon
clickable
onClick={() => onClick(viewType.view)}
Svg={viewType.icon}
className={classNames('', {
[cls.notSelected]: viewType.view !== view,
})}
/>
))}
</HStack>
</Card>
}
off={
<div
className={classNames(cls.ArticleViewSelector, {}, [
className,
])}
>
{viewTypes.map((viewType) => (
<ButtonDeprecated
key={viewType.view}
theme={ButtonTheme.CLEAR}
onClick={() => onClick(viewType.view)}
>
<IconDeprecated
width={24}
height={24}
Svg={viewType.icon}
className={classNames('', {
[cls.notSelected]: viewType.view !== view,
})}
/>
</ButtonDeprecated>
))}
</div>
}
/>
<Card
className={classNames(cls.ArticleViewSelectorRedesigned, {}, [
className,
])}
border="round"
>
<HStack gap="8">
{viewTypes.map((viewType) => (
<Icon
clickable
onClick={() => onClick(viewType.view)}
Svg={viewType.icon}
className={classNames('', {
[cls.notSelected]: viewType.view !== view,
})}
/>
))}
</HStack>
</Card>
);
});
69 changes: 20 additions & 49 deletions src/features/ArtilcleSortSelector/ui/ArticleSortSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { useTranslation } from 'react-i18next';
import { memo, useMemo } from 'react';
import { classNames } from '@/shared/lib/classNames/classNames';
import { Select, SelectOption } from '@/shared/ui/deprecated/Select';
import { SelectOption } from '@/shared/ui/deprecated/Select';
import { SortOrder } from '@/shared/types/sort';
import cls from './ArticleSortSelector.module.scss';
import { ArticleSortField } from '@/entities/Article';
import { ToggleFeatures } from '@/shared/lib/features';
import { ListBox } from '@/shared/ui/redesigned/Popups';
import { VStack } from '@/shared/ui/redesigned/Stack';
import { Text } from '@/shared/ui/redesigned/Text';
Expand Down Expand Up @@ -55,52 +54,24 @@ export const ArticleSortSelector = memo((props: ArticleSortSelectorProps) => {
);

return (
<ToggleFeatures
feature="isAppRedesigned"
on={
<div
className={classNames(
cls.ArticleSortSelectorRedesigned,
{},
[className],
)}
>
<VStack gap="8">
<Text text={t('Sort by:')} />
<ListBox
items={sortFieldOptions}
value={sort}
onChange={onChangeSort}
/>
<ListBox
items={orderOptions}
value={order}
onChange={onChangeOrder}
/>
</VStack>
</div>
}
off={
<div
className={classNames(cls.ArticleSortSelector, {}, [
className,
])}
>
<Select<ArticleSortField>
options={sortFieldOptions}
label={t('Sort by')}
value={sort}
onChange={onChangeSort}
/>
<Select
options={orderOptions}
label={t('by')}
value={order}
onChange={onChangeOrder}
className={cls.order}
/>
</div>
}
/>
<div
className={classNames(cls.ArticleSortSelectorRedesigned, {}, [
className,
])}
>
<VStack gap="8">
<Text text={t('Sort by:')} />
<ListBox
items={sortFieldOptions}
value={sort}
onChange={onChangeSort}
/>
<ListBox
items={orderOptions}
value={order}
onChange={onChangeOrder}
/>
</VStack>
</div>
);
});
34 changes: 7 additions & 27 deletions src/pages/ArticlesPage/ui/ArticlesPage/ArticlesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ import {
import { useInitialEffect } from '@/shared/lib/hook/useInitialEffect/useInitialEffect';
import { useAppDispatch } from '@/shared/lib/hook/useAppDispatch/useAppDispatch';
import { ArticleInfiniteList } from '../../ui/ArticleInfiniteList/ArticleInfiniteList';
import { ArticlesPageFilters } from '../../ui/ArticlesPageFilters/ArticlesPageFilters';
import { fetchNextArticlePage } from '../../model/services/fetchNextArticlePage/fetchNextArticlePage';
import { initArticlesPage } from '../../model/services/initArticlesPage/initArticlesPage';
import { articlesPageReducer } from '../../model/slices/articlesPageSlice';
import { Page } from '@/widgets/Page';
import { ArticlePageGreeting } from '@/features/articlePageGreeting';
import { ToggleFeatures } from '@/shared/lib/features';
import { StickyContentLayout } from '@/shared/layouts/StickyContentLayout';
import cls from './ArticlesPage.module.scss';
import { ViewSelectorContainer } from '../ViewSelectorContainer/ViewSelectorContainer';
Expand Down Expand Up @@ -42,35 +40,17 @@ const ArticlesPage = ({ className }: ArticlesPageProps) => {
});

const content = (
<ToggleFeatures
feature="isAppRedesigned"
on={
<StickyContentLayout
left={<ViewSelectorContainer />}
right={<FiltersContainer />}
content={
<Page
data-testid="ArticlesPage"
onScrollEnd={onLoadNextPart}
className={classNames(
cls.ArticlesPageRedesigned,
{},
[className],
)}
>
<ArticleInfiniteList />
<ArticlePageGreeting />
</Page>
}
/>
}
off={
<StickyContentLayout
left={<ViewSelectorContainer />}
right={<FiltersContainer />}
content={
<Page
data-testid="ArticlesPage"
onScrollEnd={onLoadNextPart}
className={classNames('', {}, [className])}
className={classNames(cls.ArticlesPageRedesigned, {}, [
className,
])}
>
<ArticlesPageFilters />
<ArticleInfiniteList />
<ArticlePageGreeting />
</Page>
Expand Down
10 changes: 3 additions & 7 deletions src/widgets/Page/ui/Page/Page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { memo, MutableRefObject, ReactNode, useRef, UIEvent } from 'react';
import { memo, MutableRefObject, ReactNode, UIEvent, useRef } from 'react';
import { useLocation } from 'react-router-dom';
import { useSelector } from 'react-redux';
import { classNames } from '@/shared/lib/classNames/classNames';
Expand All @@ -13,7 +13,6 @@ import { StateSchema } from '@/app/providers/StoreProvider';
import { useThrottle } from '@/shared/lib/hook/useThrottle/useThrottle';
import cls from './Page.module.scss';
import { TestProps } from '@/shared/types/testProps';
import { toggleFeatures } from '@/shared/lib/features';

interface PageProps extends TestProps {
className?: string;
Expand All @@ -34,13 +33,10 @@ export const Page = memo((props: PageProps) => {
getScrollRestorationByPath(state, pathname),
);

// wrapperRef undefined because scroll on window element (undefined for default settings)
useInfiniteScroll({
triggerRef,
wrapperRef: toggleFeatures({
name: 'isAppRedesigned',
on: () => undefined,
off: () => wrapperRef,
}),
wrapperRef: undefined,
callback: onScrollEnd,
});

Expand Down

0 comments on commit 1753c48

Please sign in to comment.