Skip to content

Commit

Permalink
fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
veronikaa-kuznetsova committed Jun 25, 2024
1 parent ba94201 commit 1c46618
Show file tree
Hide file tree
Showing 21 changed files with 94 additions and 98 deletions.
22 changes: 11 additions & 11 deletions src/app/providers/ThemeProvider/lib/useTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ export function useTheme(): UseThemeResult {
const toggleTheme = () => {
let newTheme: Theme;
switch (theme) {
case Theme.DARK:
newTheme = Theme.LIGHT;
break;
case Theme.LIGHT:
newTheme = Theme.PURPLE;
break;
case Theme.PURPLE:
newTheme = Theme.DARK;
break;
default:
newTheme = Theme.LIGHT;
case Theme.DARK:
newTheme = Theme.LIGHT;
break;
case Theme.LIGHT:
newTheme = Theme.PURPLE;
break;
case Theme.PURPLE:
newTheme = Theme.DARK;
break;
default:
newTheme = Theme.LIGHT;
}
setTheme?.(newTheme);
document.body.className = newTheme;
Expand Down
1 change: 0 additions & 1 deletion src/app/styles/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ body {
border-radius: 20px; /* закругления плашки */
border: 2px solid var(--primary-color); /* padding вокруг плашки */
}

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.avatar {
margin: 0 auto;
}

2 changes: 1 addition & 1 deletion src/entities/Article/ui/ArticleDetails/ArticleDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Avatar } from 'shared/ui/Avatar/Avatar';
import EyeIcon from 'shared/assets/icon/eye-20-20.svg';
import CalendarIcon from 'shared/assets/icon/calendar-20-20.svg';
import { Icon } from 'shared/ui/Icon/Icon';
import { HStack, VStack } from 'shared/ui/Stack';
import { ArticleCodeBlockComponent } from '../ArticleCodeBlockComponent/ArticleCodeBlockComponent';
import { ArticleImageBlockComponent } from '../ArticleImageBlockComponent/ArticleImageBlockComponent';
import { ArticleTextBlockComponent } from '../ArticleTextBlockComponent/ArticleTextBlockComponent';
Expand All @@ -22,7 +23,6 @@ import {
getArticleDetailsIsLoading,
} from '../../model/selectors/articleDetails';
import { ArticleBlock, ArticleBlockType } from '../../model/types/article';
import {HStack, VStack} from "shared/ui/Stack";

interface ArticleDetailsProps {
className?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/entities/Comment/ui/CommentCard/CommentCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { Text } from 'shared/ui/Text/Text';
import { Skeleton } from 'shared/ui/Skeleton/Skeleton';
import { AppLink } from 'shared/ui/AppLink/AppLink';
import { RoutePath } from 'shared/config/routeConfig/routeConfig';
import { VStack } from 'shared/ui/Stack';
import { Comment } from '../../model/types/comment';
import cls from './CommentCard.module.scss';
import {VStack} from "shared/ui/Stack";

interface CommentCardProps {
className?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/entities/Comment/ui/CommentList/CommentList.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { Text } from 'shared/ui/Text/Text';
import { VStack } from 'shared/ui/Stack';
import { Comment } from '../../model/types/comment';
import { CommentCard } from '../CommentCard/CommentCard';
import {VStack} from "shared/ui/Stack";

interface CommentListProps {
comments?: Comment[];
Expand Down
5 changes: 3 additions & 2 deletions src/entities/Country/ui/CountrySelect/CountrySelect.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useTranslation } from 'react-i18next';
import {memo, useCallback} from 'react';
import { memo, useCallback } from 'react';
import { ListBox } from 'shared/ui/ListBox/ListBox';
import { Country } from '../../model/types/country';
import {ListBox} from "shared/ui/ListBox/ListBox";

interface CountrySelectProps {
className?: string;
Expand All @@ -20,6 +20,7 @@ const options = [

export const CountrySelect = memo((props: CountrySelectProps) => {
const {
className,
value,
onChange,
readonly,
Expand Down
2 changes: 1 addition & 1 deletion src/entities/Currency/ui/CurrencySelect/CurrencySelect.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useTranslation } from 'react-i18next';
import { memo, useCallback } from 'react';
import { ListBox } from 'shared/ui/ListBox/ListBox';
import { Currency } from '../../model/types/currency';
import { ListBox } from "shared/ui/ListBox/ListBox";

interface CurrencySelectProps {
className?: string;
Expand Down
107 changes: 54 additions & 53 deletions src/entities/Profile/ui/ProfileCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { Currency } from 'entities/Currency/model/types/currency';
import { CurrencySelect } from 'entities/Currency';
import { Country } from 'entities/Country/model/types/country';
import { CountrySelect } from 'entities/Country';
import { HStack, VStack } from 'shared/ui/Stack';
import cls from './ProfileCard.module.scss';
import { Profile } from '../model/types/profile';
import {HStack, VStack} from "shared/ui/Stack";

interface ProfileCardProps {
className?: string;
Expand Down Expand Up @@ -54,7 +54,8 @@ export const ProfileCard = (props: ProfileCardProps) => {
<HStack
max
justify="center"
className={classNames(cls.ProfileCard, { [cls.loading]: true }, [className])}>
className={classNames(cls.ProfileCard, { [cls.loading]: true }, [className])}
>
<Loader />
</HStack>
);
Expand All @@ -79,57 +80,57 @@ export const ProfileCard = (props: ProfileCardProps) => {

return (
<VStack max gap="8" className={classNames(cls.ProfileCard, mods, [className])}>
{data?.avatar && (
<HStack max justify="center">
<Avatar src={data?.avatar} alt="" />
</HStack>
)}
<Input
value={data?.first}
placeholder={t('first_name')}
onChange={onChangeFirstName}
readonly={readonly}
/>
<Input
value={data?.lastname}
placeholder={t('last_name')}
onChange={onChangeLastName}
readonly={readonly}
/>
<Input
value={data?.age}
placeholder={t('age')}
onChange={onChangeAge}
readonly={readonly}
/>
<CurrencySelect
value={data?.currency}
onChange={onChangeCurrency}
readonly={readonly}
/>
<CountrySelect
value={data?.country}
onChange={onChangeCountry}
readonly={readonly}
/>
<Input
value={data?.city}
placeholder={t('city')}
onChange={onChangeCity}
readonly={readonly}
/>
<Input
value={data?.username}
placeholder={t('username')}
onChange={onChangeUsername}
readonly={readonly}
/>
<Input
value={data?.avatar}
placeholder={t('avatar')}
onChange={onChangeAvatar}
readonly={readonly}
/>
{data?.avatar && (
<HStack max justify="center">
<Avatar src={data?.avatar} alt="" />
</HStack>
)}
<Input
value={data?.first}
placeholder={t('first_name')}
onChange={onChangeFirstName}
readonly={readonly}
/>
<Input
value={data?.lastname}
placeholder={t('last_name')}
onChange={onChangeLastName}
readonly={readonly}
/>
<Input
value={data?.age}
placeholder={t('age')}
onChange={onChangeAge}
readonly={readonly}
/>
<CurrencySelect
value={data?.currency}
onChange={onChangeCurrency}
readonly={readonly}
/>
<CountrySelect
value={data?.country}
onChange={onChangeCountry}
readonly={readonly}
/>
<Input
value={data?.city}
placeholder={t('city')}
onChange={onChangeCity}
readonly={readonly}
/>
<Input
value={data?.username}
placeholder={t('username')}
onChange={onChangeUsername}
readonly={readonly}
/>
<Input
value={data?.avatar}
placeholder={t('avatar')}
onChange={onChangeAvatar}
readonly={readonly}
/>
</VStack>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { Button, ButtonTheme } from 'shared/ui/Button/Button';
import { useSelector } from 'react-redux';
import { useAppDispatch } from 'shared/lib/hooks/useAppDispatch/useAppDispatch';
import { DynamicModuleLoader, ReducersList } from 'shared/lib/components/DynamicModuleLoader/DynamicModuleLoader';
import { HStack } from 'shared/ui/Stack';
import { addCommentFormActions, addCommentFormReducer } from '../../model/slices/addCommentFormSlice';
import { getAddCommentFormError, getAddCommentFormText } from '../../model/selectors/addCommentFormSelectors';
import cls from './AddCommentForm.module.scss';
import {HStack} from "shared/ui/Stack";

export interface AddCommentFormProps {
className?: string;
Expand Down Expand Up @@ -41,7 +41,8 @@ const AddCommentForm = memo((props: AddCommentFormProps) => {
<HStack
max
justify="between"
className={classNames(cls.AddCommentForm, {}, [className])}>
className={classNames(cls.AddCommentForm, {}, [className])}
>
<Input
className={cls.input}
value={text}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/AboutPage/ui/AboutPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useTranslation } from 'react-i18next';
import {Page} from "widgets/Page/Page";
import { Page } from 'widgets/Page/Page';

const AboutPage = () => {
const { t } = useTranslation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useInitialEffect } from 'shared/lib/hooks/useInitialEffect/useInitialEf
import { useAppDispatch } from 'shared/lib/hooks/useAppDispatch/useAppDispatch';
import { AddCommentForm } from 'features/addCommentForm';
import { Page } from 'widgets/Page/Page';
import { VStack } from 'shared/ui/Stack';
import { articleDetailsPageReducer } from '../../model/slices';
import { getArticleRecommendations } from '../../model/slices/articleDetailsPageRecommendationsSlice';
import { getArticleRecommendationsIsLoading } from '../../model/selectors/recommendations';
Expand All @@ -23,7 +24,6 @@ import { addCommentForArticle } from '../../model/services/addCommentForArticle/
import { getArticleCommentsIsLoading } from '../../model/selectors/comments';
import cls from './ArticleDetailsPage.module.scss';
import { ArticleDetailsPageHeader } from '../ArticleDetailsPageHeader/ArticleDetailsPageHeader';
import {VStack} from "shared/ui/Stack";

interface ArticleDetailsPageProps {
className?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { RoutePath } from 'shared/config/routeConfig/routeConfig';
import { Button, ButtonTheme } from 'shared/ui/Button/Button';
import { useSelector } from 'react-redux';
import { getArticleDetailsData } from 'entities/Article/model/selectors/articleDetails';
import { HStack } from 'shared/ui/Stack';
import { getCanEditArticle } from '../../model/selectors/article';
import {HStack} from "shared/ui/Stack";

interface ArticleDetailsPageHeaderProps {
className?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/MainPage/ui/MainPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useTranslation } from 'react-i18next';
import {Page} from "widgets/Page/Page";
import { Page } from 'widgets/Page/Page';

const MainPage = () => {
const { t } = useTranslation();
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ProfilePage/ui/ProfilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import { useTranslation } from 'react-i18next';
import { useInitialEffect } from 'shared/lib/hooks/useInitialEffect/useInitialEffect';
import { useParams } from 'react-router-dom';
import { Page } from 'widgets/Page/Page';
import { VStack } from 'shared/ui/Stack';
import { ProfilePageHeader } from './ProfilePageHeader/ProfilePageHeader';
import {VStack} from "shared/ui/Stack";

const reducers: ReducersList = {
profile: profileReducer,
Expand Down
1 change: 0 additions & 1 deletion src/shared/ui/ListBox/ListBox.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,3 @@
right: 0;
bottom: 100%;
}

11 changes: 10 additions & 1 deletion src/shared/ui/ListBox/ListBox.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@ export default {
backgroundColor: { control: 'color' },
},
decorators: [
(Story) => <div style={{ display: "flex", justifyContent: "center", height: "100vh" }}><Story /></div>,
(Story) => (
<div style={{
display: 'flex',
justifyContent: 'center',
height: '100vh',
}}
>
<Story />
</div>
),
],
} as ComponentMeta<typeof ListBox>;

Expand Down
1 change: 0 additions & 1 deletion src/shared/ui/ListBox/ListBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,3 @@ export function ListBox(props: ListBoxProps) {
</HStack>
);
}

8 changes: 3 additions & 5 deletions src/shared/ui/Stack/HStack/HStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { Flex, FlexProps } from '../Flex/Flex';

type HStackProps = Omit<FlexProps, 'direction'>

export const HStack = (props: HStackProps) => {
return (
<Flex direction="row" {...props} />
);
};
export const HStack = (props: HStackProps) => (
<Flex direction="row" {...props} />
);
10 changes: 0 additions & 10 deletions src/shared/ui/Text/Text.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@
color: var(--secondary-color);
}

.inverted {
.title {
color: var(--inverted-primary-color);
}

.text {
color: var(--inverted-secondary-color);
}
}

.error {
.title {
color: var(--red-light);
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/Page/Page.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
.trigger {
height: 20px;
margin: 10px;
}
}

0 comments on commit 1c46618

Please sign in to comment.