Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/nasty-seals-carry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@primer/styled-react': patch
'@primer/react': patch
---

Fix typing issues in PageHeader exports.
2 changes: 1 addition & 1 deletion packages/react/src/PageHeader/PageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ const ContextAreaActions: React.FC<React.PropsWithChildren<ChildrenPropTypes>> =
)
}

type TitleAreaProps = {
export type TitleAreaProps = {
variant?: 'subtitle' | 'medium' | 'large' | ResponsiveValue<'subtitle' | 'medium' | 'large'>
} & ChildrenPropTypes
// PageHeader.TitleArea: The main title area of the page. Visible on all viewports.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ exports[`@primer/react > should not update exports without a semver change 1`] =
"type OverlayProps",
"PageHeader",
"type PageHeaderActionsProps",
"type PageHeaderChildrenPropTypes",
"type PageHeaderProps",
"type PageHeaderTitleAreaProps",
"type PageHeaderTitleProps",
"PageLayout",
"type PageLayoutContentProps",
Expand Down
2 changes: 2 additions & 0 deletions packages/react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ export type {
PageHeaderProps,
TitleProps as PageHeaderTitleProps,
ActionsProps as PageHeaderActionsProps,
TitleAreaProps as PageHeaderTitleAreaProps,
ChildrenPropTypes as PageHeaderChildrenPropTypes,
} from './PageHeader'

export {default as sx, merge} from './sx'
Expand Down
24 changes: 23 additions & 1 deletion packages/styled-react/src/components/PageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import {
type PageHeaderProps as PrimerPageHeaderProps,
type PageHeaderTitleProps as PrimerPageHeaderTitleProps,
type PageHeaderActionsProps as PrimerPageHeaderActionsProps,
type PageHeaderTitleAreaProps as PrimerPageHeaderTitleAreaProps,
} from '@primer/react'
import styled from 'styled-components'
import {sx, type SxProp} from '../sx'
import type {ForwardRefComponent} from '../polymorphic'
import {Box} from './Box'
import type {PropsWithChildren} from 'react'

type PageHeaderProps = PrimerPageHeaderProps & SxProp

Expand Down Expand Up @@ -35,7 +37,7 @@ function PageHeaderActions({sx, ...rest}: PageHeaderActionsProps) {
return <Box {...rest} as={PrimerPageHeader.Actions} style={style} sx={sx} />
}

type PageHeaderTitleProps = PrimerPageHeaderTitleProps & SxProp
type PageHeaderTitleProps = PropsWithChildren<PrimerPageHeaderTitleProps> & SxProp

type CSSCustomProperties = {
[key: `--${string}`]: string | number
Expand Down Expand Up @@ -63,9 +65,29 @@ function PageHeaderTitle({sx, ...rest}: PageHeaderTitleProps) {
return <Box {...rest} as={PrimerPageHeader.Title} style={style} sx={sx} />
}

type PageHeaderTitleAreaProps = PropsWithChildren<PrimerPageHeaderTitleAreaProps> & SxProp

const PageHeaderTitleArea: ForwardRefComponent<'div', PageHeaderTitleAreaProps> = styled(
PrimerPageHeader.TitleArea,
).withConfig<PageHeaderTitleAreaProps>({
shouldForwardProp: prop => prop !== 'sx',
})`
${sx}
`

const PageHeader = Object.assign(PageHeaderImpl, {
Actions: PageHeaderActions,
Title: PageHeaderTitle,
TitleArea: PageHeaderTitleArea,
ContextArea: PrimerPageHeader.ContextArea,
ContextAreaActions: PrimerPageHeader.ContextAreaActions,
TrailingVisual: PrimerPageHeader.TrailingVisual,
Description: PrimerPageHeader.Description,
ContextBar: PrimerPageHeader.ContextBar,
LeadingAction: PrimerPageHeader.LeadingAction,
Breadcrumbs: PrimerPageHeader.Breadcrumbs,
LeadingVisual: PrimerPageHeader.LeadingVisual,
TrailingAction: PrimerPageHeader.TrailingAction,
})

export {PageHeader}
Expand Down
Loading