-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
Copy pathFigure.tsx
31 lines (27 loc) · 926 Bytes
/
Figure.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
import * as React from 'react';
import classNames from 'classnames';
import FigureImage from './FigureImage';
import FigureCaption from './FigureCaption';
import { useBootstrapPrefix } from './ThemeProvider';
import type { BsPrefixProps, BsPrefixRefForwardingComponent } from './helpers';
export interface FigureProps
extends BsPrefixProps,
React.AnchorHTMLAttributes<HTMLElement> {}
const Figure: BsPrefixRefForwardingComponent<'figure', FigureProps> =
React.forwardRef<HTMLElement, FigureProps>(
({ className, bsPrefix, as: Component = 'figure', ...props }, ref) => {
bsPrefix = useBootstrapPrefix(bsPrefix, 'figure');
return (
<Component
ref={ref}
className={classNames(className, bsPrefix)}
{...props}
/>
);
},
);
Figure.displayName = 'Figure';
export default Object.assign(Figure, {
Image: FigureImage,
Caption: FigureCaption,
});