Skip to content

Commit

Permalink
Issue #15 feat : Card Component 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
alstn113 committed Sep 25, 2022
1 parent 0bdb9bc commit 14c08de
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 0 deletions.
52 changes: 52 additions & 0 deletions packages/components/Card/Card.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import styled from '@emotion/styled';
import { ComponentStory, ComponentMeta } from '@storybook/react';
import { Spacer } from '../../layouts/Spacer';
import { Card, Props } from './Card';
import React from 'react';

export default {
title: 'Components/Card',
component: Card,
} as ComponentMeta<typeof Card>;

const Template: ComponentStory<typeof Card> = (args: Props) => {
return (
<FlexColumn>
<Card {...args} />
<Spacer />
<Card variant="bordered">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Minima officia
eius velit excepturi distinctio, blanditiis sunt, quod architecto
voluptate perspiciatis ea corporis voluptatum, reprehenderit vero harum
ratione animi hic cum.
</Card>
<Spacer />
<Card variant="flat">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Minima officia
eius velit excepturi distinctio, blanditiis sunt, quod architecto
voluptate perspiciatis ea corporis voluptatum, reprehenderit vero harum
ratione animi hic cum.
</Card>
<Spacer />
<Card variant="shadow">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Minima officia
eius velit excepturi distinctio, blanditiis sunt, quod architecto
voluptate perspiciatis ea corporis voluptatum, reprehenderit vero harum
ratione animi hic cum.
</Card>
</FlexColumn>
);
};

const FlexColumn = styled.div`
display: flex;
flex-direction: column;
align-items: flex-start;
width: 250px;
`;

export const Default = Template.bind({});

Default.args = {
children: 'A Basic Card',
};
37 changes: 37 additions & 0 deletions packages/components/Card/Card.styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import styled from '@emotion/styled';
import { css } from '@emotion/react';
import { CardVariantType } from './Card';

export const StyledCard = styled.div<{
variant: CardVariantType;
isPressable: boolean;
}>`
padding: 20px 12px;
border-radius: 14px;
color: #000;
width: 100%;
height: auto;
display: flex;
flex-direction: column;
justify-content: center;
${({ variant }) =>
variant === 'shadow' &&
css`
box-shadow: 0 12px 20px 6px rgba(0, 0, 0, 0.1);
`};
${({ variant }) =>
variant === 'bordered' &&
css`
border: 1px solid #dfe3e6;
`};
${({ variant }) =>
variant === 'flat' &&
css`
background-color: #dfe3e6;
`};
${({ isPressable }) =>
isPressable &&
css`
cursor: pointer;
`}
`;
22 changes: 22 additions & 0 deletions packages/components/Card/Card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as S from './Card.styles';
import React from 'react';

export type CardVariantType = 'shadow' | 'flat' | 'bordered';

export interface Props {
children: React.ReactNode;
variant?: CardVariantType;
isPressable?: boolean;
}

export const Card = ({
children,
variant = 'shadow',
isPressable = false,
}: Props) => {
return (
<S.StyledCard variant={variant} isPressable={isPressable}>
{children}
</S.StyledCard>
);
};
1 change: 1 addition & 0 deletions packages/components/Card/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Card } from './Card';

0 comments on commit 14c08de

Please sign in to comment.