-
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.
- Loading branch information
Showing
5 changed files
with
81 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { StitchesProps } from '@stitches/react'; | ||
import React from 'react'; | ||
import { styled, css } from '../stitches.config'; | ||
import { createVariant } from '../theme/variants'; | ||
|
||
const rotate = css.keyframes({ | ||
'100%': { | ||
transform: 'rotate(360deg)', | ||
}, | ||
}); | ||
|
||
const dash = css.keyframes({ | ||
'0%': { | ||
strokeDasharray: '1, 150', | ||
strokeDashoffset: '0', | ||
}, | ||
'50%': { | ||
strokeDasharray: '90, 150', | ||
strokeDashoffset: '-35', | ||
}, | ||
'100%': { | ||
strokeDasharray: '90, 150', | ||
strokeDashoffset: '-124', | ||
}, | ||
}); | ||
|
||
const Main = styled('svg', { | ||
animation: `${rotate} 2s linear infinite`, | ||
variants: { | ||
size: createVariant({ | ||
sm: { | ||
size: '$5', | ||
}, | ||
md: { | ||
size: '$8', | ||
}, | ||
lg: { | ||
size: '$16', | ||
}, | ||
xl: { | ||
size: '$24', | ||
}, | ||
}), | ||
}, | ||
}); | ||
|
||
const Circle = styled('circle', { | ||
stroke: 'currentColor', | ||
strokeLinecap: 'round', | ||
animation: `${dash} 1.5s ease-in-out infinite`, | ||
}); | ||
|
||
const Spinner: React.FC<Omit<StitchesProps<typeof Main>, 'as'>> = ({ size = 'md', ...props }) => { | ||
return ( | ||
<Main size={size} {...props} viewBox="0 0 50 50" role="progressbar" aria-valuemin={0} aria-valuemax={100}> | ||
<Circle cx="25" cy="25" r="20" fill="none" strokeWidth="4" /> | ||
</Main> | ||
); | ||
}; | ||
|
||
export default Spinner; |
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 @@ | ||
export { default } from './Spinner'; |
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,16 @@ | ||
--- | ||
name: Spinner | ||
--- | ||
|
||
import { Playground } from 'dokz'; | ||
import { Flex, Spinner } from '@fxtrot/ui'; | ||
|
||
# Spinner | ||
|
||
<Playground> | ||
<Flex space="lg" flow="row" cross="center" css={{ bc: '$gray050', p: '$8' }}> | ||
<Spinner size="sm" /> | ||
<Spinner size="md" /> | ||
<Spinner size="lg" /> | ||
</Flex> | ||
</Playground> |
b0137ef
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.
Successfully deployed to the following URLs: