-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add loading state in button and tabs
- Loading branch information
1 parent
503f0d8
commit 38e331e
Showing
15 changed files
with
254 additions
and
6 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,40 @@ | ||
import React from 'react'; | ||
import { Stories } from '@storybook/addon-docs'; | ||
import { ComponentStory, ComponentMeta } from '@storybook/react'; | ||
import { Loader, LoaderSize } from './'; | ||
|
||
export default { | ||
title: 'Loader', | ||
parameters: { | ||
docs: { | ||
page: (): JSX.Element => ( | ||
<main> | ||
<article> | ||
<section> | ||
<h1>Loader</h1> | ||
</section> | ||
<section> | ||
<Stories includePrimary title="" /> | ||
</section> | ||
</article> | ||
</main> | ||
), | ||
}, | ||
}, | ||
argTypes: { | ||
size: { | ||
options: [LoaderSize.Large, LoaderSize.Medium, LoaderSize.Small], | ||
control: { type: 'select' }, | ||
}, | ||
}, | ||
} as ComponentMeta<typeof Loader>; | ||
|
||
const Loader_Story: ComponentStory<typeof Loader> = (args) => ( | ||
<Loader {...args} /> | ||
); | ||
|
||
export const Default = Loader_Story.bind({}); | ||
|
||
Default.args = { | ||
classNames: 'my-loader-class', | ||
}; |
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,27 @@ | ||
import React, { FC } from 'react'; | ||
import { LoaderProps, LoaderSize } from './Loader.types'; | ||
import { Stack } from '../Stack'; | ||
import { mergeClasses } from '../../shared/utilities'; | ||
|
||
import styles from './loader.module.scss'; | ||
|
||
export const Loader: FC<LoaderProps> = ({ | ||
size = LoaderSize.Small, | ||
...rest | ||
}) => { | ||
const dotClasses = mergeClasses([ | ||
styles.dot, | ||
{ | ||
[styles.small]: size === LoaderSize.Small, | ||
[styles.medium]: size === LoaderSize.Medium, | ||
[styles.large]: size === LoaderSize.Large, | ||
}, | ||
]); | ||
return ( | ||
<Stack {...rest}> | ||
<div className={dotClasses} /> | ||
<div className={dotClasses} /> | ||
<div className={dotClasses} /> | ||
</Stack> | ||
); | ||
}; |
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,11 @@ | ||
import { OcBaseProps } from '../OcBase'; | ||
|
||
export enum LoaderSize { | ||
Large = 'large', | ||
Medium = 'medium', | ||
Small = 'small', | ||
} | ||
|
||
export interface LoaderProps extends OcBaseProps<HTMLDivElement> { | ||
size?: LoaderSize; | ||
} |
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,2 @@ | ||
export * from './Loader'; | ||
export * from './Loader.types'; |
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,107 @@ | ||
.dot { | ||
--translate: -2px; | ||
background: var(--primary-color); | ||
border-radius: 50%; | ||
margin-right: $space-xxs; | ||
|
||
&.small { | ||
width: 4px; | ||
height: 4px; | ||
} | ||
|
||
&.medium { | ||
--translate: -3px; | ||
width: 6px; | ||
height: 6px; | ||
} | ||
|
||
&.large { | ||
--translate: -4px; | ||
width: 8px; | ||
height: 8px; | ||
} | ||
|
||
&:nth-child(1) { | ||
animation: 2s linear infinite both firstBall; | ||
} | ||
|
||
&:nth-child(2) { | ||
animation: 2s linear infinite both secondBall; | ||
} | ||
|
||
&:nth-child(3) { | ||
animation: 2s linear infinite both thirdBall; | ||
} | ||
} | ||
|
||
@keyframes firstBall { | ||
0% { | ||
transform: translateY(0); | ||
} | ||
50% { | ||
transform: translateY(0); | ||
} | ||
60% { | ||
transform: translateY(var(--translate)); | ||
} | ||
70% { | ||
transform: translateY(0); | ||
} | ||
80% { | ||
transform: translateY(0); | ||
} | ||
90% { | ||
transform: translateY(0); | ||
} | ||
100% { | ||
transform: translateY(0); | ||
} | ||
} | ||
|
||
@keyframes secondBall { | ||
0% { | ||
transform: translateY(0); | ||
} | ||
50% { | ||
transform: translateY(0); | ||
} | ||
60% { | ||
transform: translateY(0); | ||
} | ||
70% { | ||
transform: translateY(var(--translate)); | ||
} | ||
80% { | ||
transform: translateY(0); | ||
} | ||
90% { | ||
transform: translateY(0); | ||
} | ||
100% { | ||
transform: translateY(0); | ||
} | ||
} | ||
|
||
@keyframes thirdBall { | ||
0% { | ||
transform: translateY(0); | ||
} | ||
50% { | ||
transform: translateY(0); | ||
} | ||
60% { | ||
transform: translateY(0); | ||
} | ||
70% { | ||
transform: translateY(0); | ||
} | ||
80% { | ||
transform: translateY(var(--translate)); | ||
} | ||
90% { | ||
transform: translateY(0); | ||
} | ||
100% { | ||
transform: translateY(0); | ||
} | ||
} |
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
Oops, something went wrong.