-
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: skeleton component \ article state styles
- Loading branch information
Showing
11 changed files
with
216 additions
and
8 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
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
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,5 @@ | ||
import { StateSchema } from 'app/providers/StoreProvider'; | ||
|
||
export const getArticlesDetailsData = (state: StateSchema) => state.articleDetails?.data; | ||
export const getArticlesDetailsIsLoading = (state: StateSchema) => state.articleDetails?.isLoading; | ||
export const getArticlesDetailsIsError = (state: StateSchema) => state.articleDetails?.error; |
31 changes: 31 additions & 0 deletions
31
src/entities/Article/ui/ArticleDetails/ArticleDetails.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,34 @@ | ||
.ArticleDetails { | ||
min-height: 100%; | ||
} | ||
|
||
.avatar { | ||
margin: 0 auto; | ||
} | ||
|
||
.title { | ||
margin-top: 20px; | ||
} | ||
|
||
.skeleton { | ||
margin-top: 15px; | ||
} | ||
|
||
.articleInfo { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.icon { | ||
margin-right: 8px; | ||
} | ||
|
||
.avatarWrapper { | ||
display: flex; | ||
width: 100%; | ||
justify-content: center; | ||
} | ||
|
||
.block { | ||
margin-top: 16px; | ||
} |
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
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,29 @@ | ||
.Skeleton { | ||
width: 100%; | ||
height: 50px; | ||
position: relative; | ||
box-shadow: 0 2px 10px 0 var(--skeleton-shadow); | ||
overflow: hidden; | ||
|
||
&::before { | ||
content: ""; | ||
display: block; | ||
position: absolute; | ||
left: -150px; | ||
top: 0; | ||
height: 100%; | ||
width: 80%; | ||
background: linear-gradient(to right, transparent 0%, var(--skeleton-color) 50%, transparent 100%); | ||
animation: load 1s cubic-bezier(0.4, 0, 0.2, 1) infinite; | ||
} | ||
} | ||
|
||
@keyframes load { | ||
from { | ||
left: -150px; | ||
} | ||
|
||
to { | ||
left: 100%; | ||
} | ||
} |
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,41 @@ | ||
import React from 'react'; | ||
import { ComponentMeta, ComponentStory } from '@storybook/react'; | ||
|
||
import { ThemeDecorator } from 'shared/config/storybook/ThemeDecorator/ThemeDecorator'; | ||
import { Theme } from 'app/providers/ThemeProvider'; | ||
import { Skeleton } from './Skeleton'; | ||
|
||
export default { | ||
title: 'shared/Skeleton', | ||
component: Skeleton, | ||
argTypes: { | ||
backgroundColor: { control: 'color' }, | ||
}, | ||
} as ComponentMeta<typeof Skeleton>; | ||
|
||
const Template: ComponentStory<typeof Skeleton> = (args) => <Skeleton {...args} />; | ||
|
||
export const Normal = Template.bind({}); | ||
Normal.args = { | ||
width: '100%', | ||
height: 200, | ||
}; | ||
export const Circle = Template.bind({}); | ||
Circle.args = { | ||
border: '50%', | ||
width: 100, | ||
height: 100, | ||
}; | ||
export const NormalDark = Template.bind({}); | ||
NormalDark.args = { | ||
width: '100%', | ||
height: 200, | ||
}; | ||
NormalDark.decorators = [ThemeDecorator((Theme.DARK))]; | ||
export const CircleDark = Template.bind({}); | ||
CircleDark.args = { | ||
border: '50%', | ||
width: 100, | ||
height: 100, | ||
}; | ||
CircleDark.decorators = [ThemeDecorator((Theme.DARK))]; |
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,35 @@ | ||
import { classNames } from 'shared/lib/classNames/classNames'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { CSSProperties, memo } from 'react'; | ||
import cls from './Skeleton.module.scss'; | ||
|
||
interface SkeletonProps { | ||
className?: string; | ||
height?: string | number; | ||
width?: string | number; | ||
border?: string; | ||
} | ||
|
||
export const Skeleton = memo((props: SkeletonProps) => { | ||
const { | ||
border, | ||
height, | ||
width, | ||
className, | ||
} = props; | ||
|
||
const styles: CSSProperties = { | ||
width, | ||
height, | ||
borderRadius: border, | ||
|
||
}; | ||
|
||
const { t } = useTranslation(); | ||
return ( | ||
<div | ||
style={styles} | ||
className={classNames(cls.Skeleton, {}, [className])} | ||
/> | ||
); | ||
}); |