-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loader component #108
base: frontend
Are you sure you want to change the base?
Loader component #108
Changes from all commits
60e7974
ee63c42
d418baf
ded7fb7
cfc19ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { React } from 'react' | ||
import PropTypes from 'prop-types' | ||
|
||
import styles from './Loader.module.scss' | ||
import classNames from 'classnames' | ||
|
||
export function Loader({ className, variant }) { | ||
return ( | ||
<div className={classNames(className, styles.loader, styles[variant])}> | ||
<span></span> | ||
<span></span> | ||
<span></span> | ||
<span></span> | ||
<span></span> | ||
</div> | ||
) | ||
} | ||
|
||
const loaderPropTypes = { | ||
variant: PropTypes.oneOf(['primary', 'secondary']), | ||
className: PropTypes.string | ||
} | ||
|
||
Loader.propTypes = loaderPropTypes |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
@import '../../assets/styles/abstracts/variables'; | ||
|
||
$colors-primary: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aren't these colors in variables file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is array of colors definition. In file |
||
$primary-p100, | ||
$primary-p300, | ||
$primary-p500, | ||
$primary-p700, | ||
$primary-p900; | ||
|
||
$colors-secondary: | ||
$alternative-a100, | ||
$alternative-a300, | ||
$alternative-a500, | ||
$alternative-a700, | ||
$alternative-a900; | ||
|
||
$delays: 0.1s, 0.25s, 0.4s, 0.6s, 0.8s; | ||
|
||
@mixin loader-dots-coloring($colors, $delays) { | ||
@for $i from 1 through 5 { | ||
span:nth-child(#{$i}) { | ||
background-color: nth($colors, $i); | ||
animation-delay: nth($delays, $i); | ||
} | ||
} | ||
} | ||
|
||
@mixin loading-jumping-dots-height-Y($up, $down){ | ||
@keyframes loading { | ||
0% { | ||
transform: translateY(0); | ||
} | ||
25% { | ||
transform: translateY($up); | ||
} | ||
50% { | ||
transform: translateY($down); | ||
} | ||
100% { | ||
transform: translateY(0); | ||
} | ||
} | ||
} | ||
|
||
.loader { | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
display: flex; | ||
align-items: center; | ||
|
||
span { | ||
height: 25px; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. convert to rem or add TODO comment to dont forget to refactor in the future ;) |
||
width: 25px; | ||
margin-right: 10px; | ||
border-radius: 50%; | ||
animation: loading 1.1s linear infinite; | ||
} | ||
|
||
@include loading-jumping-dots-height-Y(5px, -40px); | ||
|
||
&.primary { | ||
@include loader-dots-coloring($colors-primary, $delays); | ||
} | ||
&.secondary { | ||
@include loader-dots-coloring($colors-secondary, $delays); | ||
} | ||
|
||
@media only screen and (min-width: 900px) { | ||
span { | ||
height: 35px; | ||
width: 35px; | ||
margin-right: 15px; | ||
} | ||
@include loading-jumping-dots-height-Y(10px, -60px) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from 'react' | ||
import { Loader } from './Loader.jsx' | ||
|
||
export default { | ||
component: Loader, | ||
|
||
parameters: { | ||
componentSubtitle: 'A Loader component based on css transform and animation-delay.' | ||
}, | ||
|
||
title: 'Components/Loader', | ||
argTypes: { | ||
variant: { | ||
options: ['primary', 'secondary'], | ||
control: { type: 'radio' }, | ||
type: { required: true }, | ||
table: { | ||
category: 'props', | ||
type: { summary: 'string', detail: 'variant' }, | ||
defaultValue: { summary: 'primary' } | ||
} | ||
} | ||
} | ||
} | ||
|
||
const Template = (args) => <Loader {...args} /> | ||
|
||
export const Default = Template.bind({}) | ||
Default.storyName = 'Loader' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace with @use