aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/molecules/card/card-footer.tsx
blob: 56a65136c24e9a76479cb7d1f888f11f57b877e7 (plain)
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
import {
  forwardRef,
  type ForwardRefRenderFunction,
  type ReactNode,
} from 'react';
import { Footer, type FooterProps } from '../../atoms';
import { useCardFooterMeta } from './card-provider';
import styles from './card.module.scss';

export type CardFooterProps = Omit<FooterProps, 'children'> & {
  /**
   * The card footer contents.
   */
  children?: ReactNode;
};

const CardFooterWithRef: ForwardRefRenderFunction<
  HTMLElement,
  CardFooterProps
> = ({ children, className = '', ...props }, ref) => {
  const footerClass = `${styles.footer} ${className}`;
  const meta = useCardFooterMeta();

  return (
    <Footer {...props} className={footerClass} ref={ref}>
      {children}
      {meta}
    </Footer>
  );
};

export const CardFooter = forwardRef(CardFooterWithRef);