UNPKG

1.92 kBJavaScriptView Raw
1import classNames from 'classnames';
2import * as React from 'react';
3import { useBootstrapPrefix } from './ThemeProvider';
4import createWithBsPrefix from './createWithBsPrefix';
5import divWithClassName from './divWithClassName';
6import CardImg from './CardImg';
7import CardHeader from './CardHeader';
8import { jsx as _jsx } from "react/jsx-runtime";
9const DivStyledAsH5 = divWithClassName('h5');
10const DivStyledAsH6 = divWithClassName('h6');
11const CardBody = createWithBsPrefix('card-body');
12const CardTitle = createWithBsPrefix('card-title', {
13 Component: DivStyledAsH5
14});
15const CardSubtitle = createWithBsPrefix('card-subtitle', {
16 Component: DivStyledAsH6
17});
18const CardLink = createWithBsPrefix('card-link', {
19 Component: 'a'
20});
21const CardText = createWithBsPrefix('card-text', {
22 Component: 'p'
23});
24const CardFooter = createWithBsPrefix('card-footer');
25const CardImgOverlay = createWithBsPrefix('card-img-overlay');
26const defaultProps = {
27 body: false
28};
29const Card = /*#__PURE__*/React.forwardRef(({
30 bsPrefix,
31 className,
32 bg,
33 text,
34 border,
35 body,
36 children,
37 // Need to define the default "as" during prop destructuring to be compatible with styled-components github.com/react-bootstrap/react-bootstrap/issues/3595
38 as: Component = 'div',
39 ...props
40}, ref) => {
41 const prefix = useBootstrapPrefix(bsPrefix, 'card');
42 return /*#__PURE__*/_jsx(Component, {
43 ref: ref,
44 ...props,
45 className: classNames(className, prefix, bg && `bg-${bg}`, text && `text-${text}`, border && `border-${border}`),
46 children: body ? /*#__PURE__*/_jsx(CardBody, {
47 children: children
48 }) : children
49 });
50});
51Card.displayName = 'Card';
52Card.defaultProps = defaultProps;
53export default Object.assign(Card, {
54 Img: CardImg,
55 Title: CardTitle,
56 Subtitle: CardSubtitle,
57 Body: CardBody,
58 Link: CardLink,
59 Text: CardText,
60 Header: CardHeader,
61 Footer: CardFooter,
62 ImgOverlay: CardImgOverlay
63});
\No newline at end of file