Skip to content

Commit

Permalink
feat: Spinner 컴포넌트 구현 [woowacourse#5]
Browse files Browse the repository at this point in the history
  • Loading branch information
turtle601 committed May 17, 2023
1 parent b0c382b commit f830228
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/components/Spinner/Spinner.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import { StoryFn, Meta } from '@storybook/react';
import Spinner from '@/components/Spinner';

export default {
component: Spinner,
title: 'Spinner',
} as Meta;

const Template: StoryFn = () => <Spinner />;

export const Default = Template.bind({});
53 changes: 53 additions & 0 deletions src/components/Spinner/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React from 'react';
import styled, { css } from 'styled-components';

interface SpinnerProps {
size?: string;
color?: string;
}
const StyledDefaultLoading = styled.div<SpinnerProps>`
width: 48px;
height: 48px;
border-radius: 50%;
display: inline-block;
box-sizing: border-box;
animation: rotation 1s linear infinite;
border: 5px solid #000;
${(props) => {
return (
props.size &&
css`
width: ${props.size};
height: ${props.size};
`
);
}}
${(props) => {
return (
props.color &&
css`
border: 5px solid ${props.color}
height: ${props.size};
`
);
}}
border-bottom-color: transparent;
@keyframes rotation {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
`;

const Spinner: React.FC<SpinnerProps> = ({ ...rest }) => {
return <StyledDefaultLoading {...rest} />;
};

export default Spinner;

0 comments on commit f830228

Please sign in to comment.