import { forwardRef } from "react"; import classNames from "classnames"; import { RenderBaseProps } from "../../../types"; import { useContextProps } from "@hooks/useContextProps"; import { useRenderProps } from "@hooks/useRenderProps"; import { LayoutProps } from "@styles/layout"; import { FlexStyleProps } from "@styles/flex"; import { IconButton, IconButtonProps } from "@components/Buttons/IconButton"; import { useTranslations } from "@hooks/useTranslations"; import { Flex, FlexProps } from "@components/Layout/Flex"; import { Heading, HeadingProps } from "@components/Typography/Heading"; import { NavbarContext } from "./Navbar.context"; import { NavbarWrapper } from "./Navbar.styles"; export interface NavbarProps extends RenderBaseProps, LayoutProps, FlexStyleProps {} const NavbarRoot = forwardRef(function Navbar( props, ref ) { [props, ref] = useContextProps(NavbarContext, props, ref); const { className, style, children, ...rest } = props; const renderProps = useRenderProps({ componentClassName: "aje-navbar", className, style, children, }); return ( {renderProps.children} ); }); NavbarRoot.displayName = "Navbar"; export const Navbar = NavbarRoot as typeof NavbarRoot & { BackButton: typeof NavbarBackButton; Section: typeof NavbarSection; Title: typeof NavbarTitle; Subtitle: typeof NavbarSubtitle; }; interface NavbarBackButtonProps extends Omit { icon?: IconButtonProps["icon"]; } const NavbarBackButton = forwardRef( function NavbarBackButton(props, ref) { const t = useTranslations(); const { "aria-label": ariaLabel = t("back"), icon = "arrow_back", className, ...rest } = props; return ( ); } ); NavbarBackButton.displayName = "Navbar.BackButton"; Navbar.BackButton = NavbarBackButton; interface NavbarSectionProps extends FlexProps { side?: "left" | "right" | "center"; } const NavbarSection = forwardRef( function NavbarSection(props, ref) { const { children, side = "left", className, ...rest } = props; return ( {children} ); } ); NavbarSection.displayName = "Navbar.Section"; Navbar.Section = NavbarSection; interface NavbarTitleProps extends HeadingProps {} const NavbarTitle = forwardRef( function NavbarTitle(props, ref) { const { className, as = "h1", $weight = "regular", ...rest } = props; return ( ); } ); NavbarTitle.displayName = "Navbar.Title"; Navbar.Title = NavbarTitle; interface NavbarSubtitleProps extends HeadingProps {} const NavbarSubtitle = forwardRef( function NavbarSubtitle(props, ref) { const { className, as = "h2", $weight = "light", $color = "text-clr-alt", $size = "2", ...rest } = props; return ( ); } ); NavbarSubtitle.displayName = "Navbar.Subtitle"; Navbar.Subtitle = NavbarSubtitle;