Skip to content

Commit

Permalink
feat: add articles \ articles details page
Browse files Browse the repository at this point in the history
  • Loading branch information
TomatoVan committed Dec 19, 2023
1 parent f9b1a58 commit f885103
Show file tree
Hide file tree
Showing 18 changed files with 133 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/build/buildWebpackConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function buildWebpackConfig(options: BuildOptions): webpack.Configuration
filename: '[name].[contenthash].js',
path: paths.build,
clean: true,
publicPath: '/',
},
plugins: buildPlugins(options),
module: {
Expand Down
5 changes: 5 additions & 0 deletions extractedTranslations/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
"Profile": "",
"Save": "",
"Server error": "",
"articles": "",
"articles page": "",
"articles_details": "",
"articles_details page": "",
"articles_detals": "",
"auth_form": "",
"auth_password": "",
"auth_username": "",
Expand Down
5 changes: 5 additions & 0 deletions src/pages/ArticlesDetailsPage/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { ArticlesDetailsPageAsync } from './ui/ArticlesDetailsPage.async';

export {
ArticlesDetailsPageAsync as ArticlesDetailsPage,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { lazy } from 'react';

export const ArticlesDetailsPageAsync = lazy(() => new Promise((resolve) => {
// @ts-ignore
// ТАК В РЕАЛЬНЫХ ПРОЕКТАХ НЕ ДЕЛАТЬ!!!!! ДЕЛАЕМ ДЛЯ КУРСА!
setTimeout(() => resolve(import('./ArticlesDetailsPage')), 1500);
}));
16 changes: 16 additions & 0 deletions src/pages/ArticlesDetailsPage/ui/ArticlesDetailsPage.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import { ComponentStory, ComponentMeta } from '@storybook/react';
import { ArticlesDetailsPage } from 'pages/ArticlesDetailsPage';

export default {
title: 'shared/ArticlesDetailsPage',
component: ArticlesDetailsPage,
argTypes: {
backgroundColor: { control: 'color' },
},
} as ComponentMeta<typeof ArticlesDetailsPage>;

const Template: ComponentStory<typeof ArticlesDetailsPage> = (args) => <ArticlesDetailsPage {...args} />;

export const Normal = Template.bind({});
Normal.args = {};
8 changes: 8 additions & 0 deletions src/pages/ArticlesDetailsPage/ui/ArticlesDetailsPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { useTranslation } from 'react-i18next';
import { memo } from 'react';

const ArticlesDetailsPage = (props: any) => {
const { t } = useTranslation();
return <div>{t('articles_details page')}</div>;
};
export default memo(ArticlesDetailsPage);
5 changes: 5 additions & 0 deletions src/pages/ArticlesPage/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { ArticlesPageAsync } from './ui/ArticlesPage.async';

export {
ArticlesPageAsync as ArticlesPage,
};
7 changes: 7 additions & 0 deletions src/pages/ArticlesPage/ui/ArticlesPage.async.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { lazy } from 'react';

export const ArticlesPageAsync = lazy(() => new Promise((resolve) => {
// @ts-ignore
// ТАК В РЕАЛЬНЫХ ПРОЕКТАХ НЕ ДЕЛАТЬ!!!!! ДЕЛАЕМ ДЛЯ КУРСА!
setTimeout(() => resolve(import('./ArticlesPage')), 1500);
}));
16 changes: 16 additions & 0 deletions src/pages/ArticlesPage/ui/ArticlesPage.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import { ComponentStory, ComponentMeta } from '@storybook/react';
import { ArticlesPage } from 'pages/ArticlesPage';

export default {
title: 'shared/ArticlesPage',
component: ArticlesPage,
argTypes: {
backgroundColor: { control: 'color' },
},
} as ComponentMeta<typeof ArticlesPage>;

const Template: ComponentStory<typeof ArticlesPage> = (args) => <ArticlesPage {...args} />;

export const Normal = Template.bind({});
Normal.args = {};
9 changes: 9 additions & 0 deletions src/pages/ArticlesPage/ui/ArticlesPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { useTranslation } from 'react-i18next';
import { memo } from 'react';

const ArticlesPage = (props: any) => {
const { t } = useTranslation();
return <div>{t('articles page')}</div>;
};

export default memo(ArticlesPage);
3 changes: 3 additions & 0 deletions src/shared/assets/icons/article-20-20.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions src/shared/assets/icons/calendar-20-20.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/shared/assets/icons/copy-20-20.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/shared/assets/icons/done-20-20.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/shared/assets/icons/eye-20-20.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions src/shared/config/routeConfig/routeConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { MainPage } from 'pages/MainPage';
import { AboutPage } from 'pages/AboutPage';
import { NotFoundPage } from 'pages/NotFoundPage';
import { ProfilePage } from 'pages/ProfilePage';
import { ArticlesPage } from 'pages/ArticlesPage';
import { ArticlesDetailsPage } from 'pages/ArticlesDetailsPage';

export type AppRoutesProps = RouteProps & {
authOnly?: boolean;
Expand All @@ -12,13 +14,17 @@ export enum AppRoutes {
MAIN = 'main',
ABOUT = 'about',
PROFILE = 'profile',
ARTICLES = 'articles',
ARTICLE_DETAILS = 'article_details',
NOT_FOUND = 'not_found',
}

export const RoutePath: Record<AppRoutes, string> = {
[AppRoutes.MAIN]: '/',
[AppRoutes.ABOUT]: '/about',
[AppRoutes.PROFILE]: '/profile',
[AppRoutes.ARTICLES]: '/articles',
[AppRoutes.ARTICLE_DETAILS]: '/articles/', // + :id
[AppRoutes.NOT_FOUND]: '*',
};

Expand All @@ -36,6 +42,16 @@ export const routeConfig: Record<AppRoutes, AppRoutesProps> = {
element: <ProfilePage />,
authOnly: true,
},
[AppRoutes.ARTICLES]: {
path: RoutePath.articles,
element: <ArticlesPage />,
authOnly: true,
},
[AppRoutes.ARTICLE_DETAILS]: {
path: `${RoutePath.article_details}:id`,
element: <ArticlesDetailsPage />,
authOnly: true,
},
[AppRoutes.NOT_FOUND]: {
path: RoutePath.not_found,
element: <NotFoundPage />,
Expand Down
7 changes: 7 additions & 0 deletions src/widgets/Sidebar/model/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { RoutePath } from 'shared/config/routeConfig/routeConfig';
import AboutIcon from 'shared/assets/icons/about-20-20.svg';
import MainIcon from 'shared/assets/icons/main-20-20.svg';
import ProfileIcon from 'shared/assets/icons/profile-20-20.svg';
import ArticleIcon from 'shared/assets/icons/article-20-20.svg';

export interface SidebarItemType {
path: string;
Expand All @@ -28,4 +29,10 @@ export const SidebarItemsList: SidebarItemType[] = [
text: 'Профиль',
authOnly: true,
},
{
path: RoutePath.articles,
Icon: ArticleIcon,
text: 'Статьи',
authOnly: true,
},
];
1 change: 1 addition & 0 deletions src/widgets/Sidebar/ui/SidebarItem/SidebarItem.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
margin-left: 10px;
display: flex;
align-items: center;
margin-top: 5px;
}

.link {
Expand Down

0 comments on commit f885103

Please sign in to comment.