-
Notifications
You must be signed in to change notification settings - Fork 112
/
index.tsx
51 lines (46 loc) · 1.5 KB
/
index.tsx
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import * as React from 'react';
import PropTypes from 'prop-types';
import {Box, safelySpreadBoxProps} from '@twilio-paste/box';
import type {BoxProps} from '@twilio-paste/box';
import type {PaddingProps} from '@twilio-paste/style-props';
import {isPaddingTokenProp} from '@twilio-paste/style-props';
import type {HTMLPasteProps} from '@twilio-paste/types';
/** element identifier from BoxProps for customization */
export interface CardProps extends HTMLPasteProps<'article'>, PaddingProps, Pick<BoxProps, 'element' | 'variant'> {}
const Card = React.forwardRef<HTMLElement, CardProps>(
(
{children, element = 'CARD', padding = 'space100', paddingBottom, paddingLeft, paddingRight, paddingTop, ...props},
ref
) => {
return (
<Box
{...safelySpreadBoxProps(props)}
ref={ref}
as="article"
borderWidth="borderWidth10"
borderColor="colorBorderWeaker"
borderStyle="solid"
borderRadius="borderRadius30"
element={element}
padding={padding}
paddingBottom={paddingBottom}
paddingLeft={paddingLeft}
paddingRight={paddingRight}
paddingTop={paddingTop}
backgroundColor="colorBackgroundBody"
>
{children}
</Box>
);
}
);
Card.propTypes = {
element: PropTypes.string,
padding: isPaddingTokenProp,
paddingTop: isPaddingTokenProp,
paddingRight: isPaddingTokenProp,
paddingBottom: isPaddingTokenProp,
paddingLeft: isPaddingTokenProp,
};
Card.displayName = 'Card';
export {Card};