From bc9d89f092230e64eb53c9331ba1cd4ed8ed3ac9 Mon Sep 17 00:00:00 2001 From: Kate Travers <8152930+ktravers@users.noreply.github.com> Date: Wed, 12 Jun 2024 02:12:33 +0000 Subject: [PATCH 1/3] add classname prop to root and all child components --- packages/react/src/PageHeader/PageHeader.tsx | 84 +++++++++++++++++--- 1 file changed, 73 insertions(+), 11 deletions(-) diff --git a/packages/react/src/PageHeader/PageHeader.tsx b/packages/react/src/PageHeader/PageHeader.tsx index 85a9220eb9a..604182572bf 100644 --- a/packages/react/src/PageHeader/PageHeader.tsx +++ b/packages/react/src/PageHeader/PageHeader.tsx @@ -42,6 +42,7 @@ const LARGE_TITLE_HEIGHT = '3rem' // Types that are shared between PageHeader children components export type ChildrenPropTypes = { + className?: string hidden?: boolean | ResponsiveValue } & SxProp @@ -64,10 +65,11 @@ const hiddenOnNarrow = { export type PageHeaderProps = { 'aria-label'?: React.AriaAttributes['aria-label'] as?: React.ElementType | 'header' | 'div' + className?: string } & SxProp const Root = React.forwardRef>( - ({children, sx = {}, as = 'div'}, forwardedRef) => { + ({children, className, sx = {}, as = 'div'}, forwardedRef) => { const rootStyles = { display: 'grid', // We have max 5 columns. @@ -156,7 +158,13 @@ const Root = React.forwardRef(rootStyles, sx)} data-size-variant={titleVariant}> + (rootStyles, sx)} + data-size-variant={titleVariant} + > {children} ) @@ -169,6 +177,7 @@ const Root = React.forwardRef> = ({ children, + className, hidden = hiddenOnRegularAndWide, sx = {}, }) => { @@ -186,7 +195,11 @@ const ContextArea: React.FC> = ({ }), } - return (contentNavStyles, sx)}>{children} + return ( + (contentNavStyles, sx)}> + {children} + + ) } type LinkProps = Pick< React.AnchorHTMLAttributes & BaseLinkProps, @@ -198,7 +211,7 @@ export type ParentLinkProps = React.PropsWithChildren( - ({children, sx = {}, href, 'aria-label': ariaLabel, as = 'a', hidden = hiddenOnRegularAndWide}, ref) => { + ({children, className, sx = {}, href, 'aria-label': ariaLabel, as = 'a', hidden = hiddenOnRegularAndWide}, ref) => { return ( <> ( as={as} aria-label={ariaLabel} muted + className={className} sx={merge( { display: 'flex', @@ -234,11 +248,13 @@ const ParentLink = React.forwardRef( const ContextBar: React.FC> = ({ children, + className, sx = {}, hidden = hiddenOnRegularAndWide, }) => { return ( ( { display: 'flex', @@ -259,11 +275,13 @@ const ContextBar: React.FC> = ({ // --------------------------------------------------------------------- const ContextAreaActions: React.FC> = ({ children, + className, sx = {}, hidden = hiddenOnRegularAndWide, }) => { return ( ( { display: 'flex', @@ -293,7 +311,7 @@ type TitleAreaProps = { // --------------------------------------------------------------------- const TitleArea = React.forwardRef>( - ({children, sx = {}, hidden = false, variant = 'medium'}, forwardedRef) => { + ({children, className, sx = {}, hidden = false, variant = 'medium'}, forwardedRef) => { const titleAreaRef = useProvidedRefOrCreate(forwardedRef as React.RefObject) const currentVariant = useResponsiveValue(variant, 'medium') const [fontSize, setFontSize] = useState(null) @@ -317,6 +335,7 @@ const TitleArea = React.forwardRef