-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCardContainer.tsx
More file actions
27 lines (25 loc) · 1020 Bytes
/
CardContainer.tsx
File metadata and controls
27 lines (25 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/** @jsxImportSource @emotion/react */
import { jsx } from '@emotion/react';
import { useContext } from 'react';
import { createClassVariant } from '@jdesignlab/theme';
import { DEFAULT_BORDER_COLOR } from '../constants';
import { CardContext } from '../context';
import * as Style from '../styles';
import { CardProps, CardStyle } from '../types';
export const CardContainer = (props: Omit<CardProps, CardStyle>) => {
const { children, as = 'div', role = 'article', className = '', ...restProps } = props;
const { size, variant, color, justify, align, direction } = useContext(CardContext).styleProps;
const cardBaseStyle = Style.createCardVariant(size, variant, color, DEFAULT_BORDER_COLOR);
const flexStyle = Style.createFlexStyle(justify, align, direction);
return jsx(
as,
{
css: [...cardBaseStyle, flexStyle],
role,
className: `${createClassVariant('card', 'article')} ${className}`,
...restProps
},
children
);
};
CardContainer.displayName = 'CardContainer';