Skip to content

Commit

Permalink
feat(ui/react/components): card 관련 컴포넌트들 추가 (#170)
Browse files Browse the repository at this point in the history
* feat(ui/react/components/card): Card 컴포넌트 관련 style 추가

* feat(ui/react/components/card): CardBody 컴포넌트 관련 style 추가

* feat(ui/react/components/card): CardFooter 컴포넌트 관련 style 추가

* feat(ui/react/components/card): CardHeader 컴포넌트 관련 style 추가

* feat(ui/react/components/card): Card 컴포넌트 추가

* feat(ui/react/components/card): CardHeader 컴포넌트 추가

* feat(ui/react/components/card): CardBody 컴포넌트 추가

* feat(ui/react/components/card): CardFooter 컴포넌트 추가

* feat(ui/react/components/card): card 관련 컴포넌트들을 모은 index.ts 추가

* feat(ui/react/components/index.ts): card 추가
  • Loading branch information
sukvvon authored May 3, 2024
1 parent 40f3c25 commit 50de699
Show file tree
Hide file tree
Showing 10 changed files with 180 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/ui/react/src/components/card/card-body.styles.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { style } from '@vanilla-extract/css';

export const cardBodyBase = style({
flex: '1 1 0%',
padding: 16,
});
25 changes: 25 additions & 0 deletions packages/ui/react/src/components/card/card-body.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {
type HTMLFavolinkProps,
favolink,
forwardRef,
} from '@favolink-ui/system';
import { cx } from '@favolink-ui/utils';
import * as styles from './card-body.styles.css';

export type CardBodyProps = HTMLFavolinkProps<'section'>;

export const CardBody = forwardRef<CardBodyProps, 'section'>(
function CardBody(props, ref) {
const { children, className, ...restProps } = props;

return (
<favolink.section
{...restProps}
ref={ref}
className={cx('favolink-card__body', styles.cardBodyBase, className)}
>
{children}
</favolink.section>
);
},
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { style } from '@vanilla-extract/css';
import { flexStyleVars } from '../../styles';

export const cardFooterBase = style({
padding: 16,
display: 'flex',
justifyContent: flexStyleVars.justifyContent,
});
40 changes: 40 additions & 0 deletions packages/ui/react/src/components/card/card-footer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { assignInlineVars } from '@vanilla-extract/dynamic';
import {
type HTMLFavolinkProps,
favolink,
forwardRef,
} from '@favolink-ui/system';
import { cx } from '@favolink-ui/utils';
import * as styles from './card-footer.styles.css';
import { type FlexStyleProps, flexStyleVars } from '../../styles';

type CardFooterStyleProps = Pick<FlexStyleProps, 'justifyContent'>;

export type CardFooterProps = CardFooterStyleProps &
HTMLFavolinkProps<'footer'>;

export const CardFooter = forwardRef<CardFooterProps, 'footer'>(
function CardFooter(props, ref) {
const { className, style, children, justifyContent, ...restProps } = props;

return (
<favolink.footer
{...restProps}
ref={ref}
className={cx(
'favolink-card__footer',
styles.cardFooterBase,
className,
)}
style={{
...assignInlineVars({
[flexStyleVars.justifyContent]: justifyContent,
}),
...style,
}}
>
{children}
</favolink.footer>
);
},
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { style } from '@vanilla-extract/css';

export const cardHeaderBase = style({
padding: 16,
});
29 changes: 29 additions & 0 deletions packages/ui/react/src/components/card/card-header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {
type HTMLFavolinkProps,
favolink,
forwardRef,
} from '@favolink-ui/system';
import { cx } from '@favolink-ui/utils';
import * as styles from './card-header.styles.css';

export type CardHeaderProps = HTMLFavolinkProps<'header'>;

export const CardHeader = forwardRef<CardHeaderProps, 'header'>(
function CardHeader(props, ref) {
const { children, className, ...restProps } = props;

return (
<favolink.header
{...restProps}
ref={ref}
className={cx(
'favolink-card__header',
styles.cardHeaderBase,
className,
)}
>
{children}
</favolink.header>
);
},
);
15 changes: 15 additions & 0 deletions packages/ui/react/src/components/card/card.styles.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { style } from '@vanilla-extract/css';
import { flexStyleVars } from '../../styles';

export const cardBase = style({
minWidth: 0,
maxWidth: 310,
borderRadius: 12,
position: 'relative',
display: 'flex',
justifyContent: flexStyleVars.justifyContent,
alignItems: flexStyleVars.alignItems,
flexDirection: flexStyleVars.flexDirection,
boxShadow:
'0 1px 10px 0 rgba(211, 214, 224, 0.25), 0 1px 10px 0 rgba(211, 214, 224, 0.25)',
});
46 changes: 46 additions & 0 deletions packages/ui/react/src/components/card/card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { assignInlineVars } from '@vanilla-extract/dynamic';
import {
type HTMLFavolinkProps,
extractProps,
favolink,
forwardRef,
} from '@favolink-ui/system';
import { cx } from '@favolink-ui/utils';
import * as styles from './card.styles.css';
import {
type FlexStyleProps,
flexStyleProps,
flexStyleVars,
} from '../../styles';

type CardStyleProps = Pick<
FlexStyleProps,
'alignItems' | 'flexDirection' | 'justifyContent'
>;

export type CardProps = CardStyleProps & HTMLFavolinkProps<'article'>;

export const Card = forwardRef<CardProps, 'article'>(function Card(props, ref) {
const { flexDirection = 'column', ...restProps } = props;
const { children, className, style, ..._restProps } = extractProps(
restProps,
flexStyleVars,
flexStyleProps,
);

return (
<favolink.article
{..._restProps}
ref={ref}
className={cx('favolink-card', styles.cardBase, className)}
style={{
...assignInlineVars({
[flexStyleVars.flexDirection]: flexDirection,
}),
...style,
}}
>
{children}
</favolink.article>
);
});
5 changes: 5 additions & 0 deletions packages/ui/react/src/components/card/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* eslint-disable @stylistic/padding-line-between-statements, react-refresh/only-export-components */
export { Card, type CardProps } from './card';
export { CardBody, type CardBodyProps } from './card-body';
export { CardFooter, type CardFooterProps } from './card-footer';
export { CardHeader, type CardHeaderProps } from './card-header';
1 change: 1 addition & 0 deletions packages/ui/react/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable @stylistic/padding-line-between-statements, react-refresh/only-export-components */
export * from './button';
export * from './card';
export * from './input';
export * from './layout';
export * from './link';
Expand Down

0 comments on commit 50de699

Please sign in to comment.