import * as React from "react";
import { Dialog as DialogPrimitive } from "radix-ui";
import { theme, styled } from "../theme";

import type * as WPDS from "../theme";

const NAME = "DialogTitle";

const StyledTitle = styled(DialogPrimitive.Title, {
  color: theme.colors.primary,
  fontFamily: theme.fonts.meta,
  fontSize: theme.fontSizes["125"],
  fontWeight: theme.fontWeights.bold,
  marginBlockStart: 0,
  marginBlockEnd: theme.space["150"],
});

export type DialogTitleProps = {
  /** Any React node may be used as a child */
  children?: React.ReactNode;
  /** Override CSS */
  css?: WPDS.CSS;
} & DialogPrimitive.DialogTitleProps;

export const DialogTitle = React.forwardRef<
  HTMLHeadingElement,
  DialogTitleProps
>(({ children, ...props }: DialogTitleProps, ref) => {
  return (
    <StyledTitle {...props} ref={ref}>
      {children}
    </StyledTitle>
  );
});

DialogTitle.displayName = NAME;
