Skip to content
Open
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
5 changes: 5 additions & 0 deletions .changeset/proud-bobcats-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ag.ds-next/react': minor
---

header: Make heading optional and conditionally render.
2 changes: 1 addition & 1 deletion packages/react/src/header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type HeaderProps = {
/** When using two logos, position the horizontal dividing line 'between' the logos or 'after' them. */
dividerPosition?: 'after' | 'between';
/** The heading should be set to the website or service title. */
heading: string;
heading?: string;
/** The href to link to, for example "/". */
href?: string;
/** The logo to display. */
Expand Down
66 changes: 36 additions & 30 deletions packages/react/src/header/HeaderBrand.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,36 +112,42 @@ export function HeaderBrand({
<DividingLine dividerPosition={dividerPosition} />
)}

<Stack
as={Link}
color="text"
css={{
textDecoration: 'none',
':hover': packs.underline,
}}
focusRingFor="keyboard"
href={href}
justifyContent="center"
>
<Flex alignItems="flex-start" gap={0.5}>
<Text
fontSize={headingSizeMap[size]}
fontWeight="bold"
lineHeight="default"
maxWidth={tokens.maxWidth.bodyText}
>
{heading}
</Text>

{badgeLabel && <HeaderBadge>{badgeLabel}</HeaderBadge>}
</Flex>

{subline && (
<Text color="muted" fontSize={subHeadingSizeMap[size]}>
{subline}
</Text>
)}
</Stack>
{(heading || badgeLabel || subline) && (
<Stack
as={Link}
color="text"
css={{
textDecoration: 'none',
':hover': packs.underline,
}}
focusRingFor="keyboard"
href={href}
justifyContent="center"
>
{(heading || badgeLabel) && (
<Flex alignItems="flex-start" gap={0.5}>
{heading && (
<Text
fontSize={headingSizeMap[size]}
fontWeight="bold"
lineHeight="default"
maxWidth={tokens.maxWidth.bodyText}
>
{heading}
</Text>
)}

{badgeLabel && <HeaderBadge>{badgeLabel}</HeaderBadge>}
</Flex>
)}

{subline && (
<Text color="muted" fontSize={subHeadingSizeMap[size]}>
{subline}
</Text>
)}
</Stack>
)}
</Flex>
</Flex>
) : (
Expand Down
7 changes: 3 additions & 4 deletions packages/react/src/header/docs/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,16 @@ The `size` prop can be used to control the vertical height of the Header. Use th

## Co-branding

The header component can be used with no logo, one logo, or two logos when the [Australian Government Brand Guidelines](https://www.pmc.gov.au/publications/australian-government-branding-guildelines) for Program or International branding are met. Each logo can be a link when an `href` and `secondHref` are defined.
The header component can be used with no logo, one logo, or two logos when the [Australian Government Brand Guidelines](https://www.pmc.gov.au/resources/australian-government-branding-guidelines) for Program or International branding are met. Each logo can be a link when an `href` and `secondHref` are defined.

_Note: The first logo’s `href` will be assigned to the `heading` and `subline` text as well._
_Note: If provided, the first logo’s `href` will be assigned to the `heading` and `subline` text as well._

```jsx live
<Box palette="dark">
<Header
heading="Co-branding header"
subline="Co-branding subline"
logo={<Logo />}
background="bodyAlt"
dividerPosition="between"
size="sm"
href="#first-href"
secondLogo={
Expand Down
Loading