-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add articles blocks, code shared comp
- Loading branch information
Showing
26 changed files
with
363 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,7 @@ | |
// skeleton | ||
--skeleton-color: #1515ad; | ||
--skeleton-shadow: #2b2be8; | ||
|
||
// code | ||
--code-bg: #1212a1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,7 @@ | |
// skeleton | ||
--skeleton-color: #fff; | ||
--skeleton-shadow: rgba(0 0 0 / 20%); | ||
|
||
// code | ||
--code-bg: #fff; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export { ArticleDetails } from './ui/ArticleDetails/ArticleDetails'; | ||
|
||
export { articleDetailsActions, articleDetailsReducer } from './model/slice/articleDetailsSlice'; | ||
export type { Article } from './model/types/article'; | ||
export type { ArticleDetailsSchema } from './model/types/articleDetailsSchema'; |
49 changes: 49 additions & 0 deletions
49
src/entities/Article/model/selectors/articleDetails.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { StateSchema } from 'app/providers/StoreProvider'; | ||
import { | ||
getArticlesDetailsData, | ||
getArticlesDetailsIsError, | ||
getArticlesDetailsIsLoading, | ||
} from './articleDetails'; | ||
|
||
describe('articleDetails.test', () => { | ||
test('should return data', () => { | ||
const data = { | ||
id: '1', | ||
title: 'subtitle', | ||
}; | ||
const state: DeepPartial<StateSchema> = { | ||
articleDetails: { | ||
data, | ||
}, | ||
}; | ||
expect(getArticlesDetailsData(state as StateSchema)).toEqual(data); | ||
}); | ||
test('should work with empty state data', () => { | ||
const state: DeepPartial<StateSchema> = {}; | ||
expect(getArticlesDetailsData(state as StateSchema)).toEqual(undefined); | ||
}); | ||
test('should return error', () => { | ||
const state: DeepPartial<StateSchema> = { | ||
articleDetails: { | ||
error: 'error', | ||
}, | ||
}; | ||
expect(getArticlesDetailsIsError(state as StateSchema)).toEqual('error'); | ||
}); | ||
test('should work with empty state error', () => { | ||
const state: DeepPartial<StateSchema> = {}; | ||
expect(getArticlesDetailsIsError(state as StateSchema)).toEqual(undefined); | ||
}); | ||
test('should return isLoading', () => { | ||
const state: DeepPartial<StateSchema> = { | ||
articleDetails: { | ||
isLoading: true, | ||
}, | ||
}; | ||
expect(getArticlesDetailsIsLoading(state as StateSchema)).toEqual(true); | ||
}); | ||
test('should work with empty state isLoading', () => { | ||
const state: DeepPartial<StateSchema> = {}; | ||
expect(getArticlesDetailsIsLoading(state as StateSchema)).toEqual(false); | ||
}); | ||
}); |
19 changes: 19 additions & 0 deletions
19
src/entities/Article/ui/ArticleCodeBlockComponent/ArticleCodeBlockComponent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { classNames } from 'shared/lib/classNames/classNames'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { memo } from 'react'; | ||
import { Code } from 'shared/ui/Code/Code'; | ||
import { ArticleCodeBlock } from '../../model/types/article'; | ||
|
||
interface ArticleCodeBlockComponentProps { | ||
className?: string; | ||
block?: ArticleCodeBlock; | ||
} | ||
|
||
export const ArticleCodeBlockComponent = memo(({ className, block }: ArticleCodeBlockComponentProps) => { | ||
const { t } = useTranslation(); | ||
return ( | ||
<div className={classNames('', {}, [className])}> | ||
{block?.code && <Code text={block?.code} />} | ||
</div> | ||
); | ||
}); |
3 changes: 0 additions & 3 deletions
3
src/entities/Article/ui/ArticleCodeBlockComponent/ArticleImageBlockComponent.module.scss
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
src/entities/Article/ui/ArticleCodeBlockComponent/ArticleImageBlockComponent.stories.tsx
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
src/entities/Article/ui/ArticleCodeBlockComponent/ArticleImageBlockComponent.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/entities/Article/ui/ArticleImageBlockComponent/ArticleImageBlockComponent.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
.ArticleImageBlockComponent { | ||
|
||
max-width: 100%; | ||
} |
17 changes: 0 additions & 17 deletions
17
src/entities/Article/ui/ArticleImageBlockComponent/ArticleImageBlockComponent.stories.tsx
This file was deleted.
Oops, something went wrong.
21 changes: 13 additions & 8 deletions
21
src/entities/Article/ui/ArticleImageBlockComponent/ArticleImageBlockComponent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
import { classNames } from 'shared/lib/classNames/classNames'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { memo } from 'react'; | ||
import { ArticleImageBlock } from 'entities/Article/model/types/article'; | ||
import { Text, TextAlign } from 'shared/ui/Text/Text'; | ||
import cls from './ArticleImageBlockComponent.module.scss'; | ||
|
||
interface ArticleImageBlockComponentProps { | ||
className?: string; | ||
className?: string; | ||
block?: ArticleImageBlock; | ||
} | ||
|
||
export const ArticleImageBlockComponent = ({ className }: ArticleImageBlockComponentProps) => { | ||
const { t } = useTranslation(); | ||
return ( | ||
<div className={classNames(cls.ArticleImageBlockComponent, {}, [className])} /> | ||
); | ||
}; | ||
export const ArticleImageBlockComponent = memo(({ className, block }: ArticleImageBlockComponentProps) => ( | ||
<div className={classNames(cls.ArticleImageBlockComponent, {}, [className])}> | ||
<img alt={block?.title} src={block?.src} className={cls.img} /> | ||
{block?.title && ( | ||
<Text title={block?.title} className={cls.title} align={TextAlign.CENTER} /> | ||
)} | ||
</div> | ||
)); |
6 changes: 5 additions & 1 deletion
6
src/entities/Article/ui/ArticleTextBlockComponent/ArticleTextBlockComponent.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
.ArticleTextBlockComponent { | ||
.title { | ||
margin-bottom: 16px; | ||
} | ||
|
||
.text { | ||
margin-top: 8px; | ||
} |
17 changes: 0 additions & 17 deletions
17
src/entities/Article/ui/ArticleTextBlockComponent/ArticleTextBlockComponent.stories.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.