You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.9 KiB

import classNames from 'classnames';
import * as React from 'react';
import { useBootstrapPrefix } from './ThemeProvider';
import createWithBsPrefix from './createWithBsPrefix';
import divWithClassName from './divWithClassName';
import CardImg from './CardImg';
import CardHeader from './CardHeader';
import { jsx as _jsx } from "react/jsx-runtime";
const DivStyledAsH5 = divWithClassName('h5');
const DivStyledAsH6 = divWithClassName('h6');
const CardBody = createWithBsPrefix('card-body');
const CardTitle = createWithBsPrefix('card-title', {
Component: DivStyledAsH5
});
const CardSubtitle = createWithBsPrefix('card-subtitle', {
Component: DivStyledAsH6
});
const CardLink = createWithBsPrefix('card-link', {
Component: 'a'
});
const CardText = createWithBsPrefix('card-text', {
Component: 'p'
});
const CardFooter = createWithBsPrefix('card-footer');
const CardImgOverlay = createWithBsPrefix('card-img-overlay');
const defaultProps = {
body: false
};
const Card = /*#__PURE__*/React.forwardRef(({
bsPrefix,
className,
bg,
text,
border,
body,
children,
// Need to define the default "as" during prop destructuring to be compatible with styled-components github.com/react-bootstrap/react-bootstrap/issues/3595
as: Component = 'div',
...props
}, ref) => {
const prefix = useBootstrapPrefix(bsPrefix, 'card');
return /*#__PURE__*/_jsx(Component, {
ref: ref,
...props,
className: classNames(className, prefix, bg && `bg-${bg}`, text && `text-${text}`, border && `border-${border}`),
children: body ? /*#__PURE__*/_jsx(CardBody, {
children: children
}) : children
});
});
Card.displayName = 'Card';
Card.defaultProps = defaultProps;
export default Object.assign(Card, {
Img: CardImg,
Title: CardTitle,
Subtitle: CardSubtitle,
Body: CardBody,
Link: CardLink,
Text: CardText,
Header: CardHeader,
Footer: CardFooter,
ImgOverlay: CardImgOverlay
});