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
5 changes: 5 additions & 0 deletions .changeset/fix-pageheader-wrapped-logo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cloudoperators/juno-ui-components": patch
---

Fix `PageHeader` logo size constraints not applying to nested logo elements. The logo container now uses the universal-descendant variant so a wrapped logo (e.g. an `<a>` containing an `<svg>`) is sized correctly within the fixed-height header.
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ const logoAndTitleContainerStyles = `

const logoContainerStyles = `
jn:max-w-xs
jn:*:w-min
jn:*:max-w-xs
jn:*:h-7
jn:*:object-contain
jn:**:w-min
jn:**:max-w-xs
jn:**:h-7
jn:**:object-contain
Comment thread
edda marked this conversation as resolved.
`

const applicationNameStyles = `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,28 @@ export const WithCustomLogoPNGPortrait: Story = {
),
},
}

export const WithWrappedLogo: Story = {
parameters: {
docs: {
description: {
story:
"A 'wrapped' logo is a logo element nested inside a parent (e.g. an `<a>` link, or any other container) rather than passed directly. The size constraints applied by `PageHeader` propagate to descendants, so the inner logo is sized correctly within the fixed-height header regardless of how deeply it is nested.",
},
},
},
args: {
logo: (
<a href="https://example.com" aria-label="Go to homepage">
<CustomLogoLandscape alt="" />
</a>
),
applicationName: "My Awesome App",
children: (
<>
<span>Jane Doe</span>
<Button size="small">Log Out</Button>
</>
),
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,22 @@ describe("PageHeader", () => {
expect(screen.getByRole("img")).toHaveClass("juno-test-logo")
})

test("renders a wrapped logo (e.g. nested inside a link) and applies size constraints to all descendants", () => {
render(
<PageHeader
logo={
<a href="https://example.com" aria-label="Go to homepage">
<CustomLogoComponent />
</a>
}
/>
)
expect(screen.getByRole("link", { name: "Go to homepage" })).toBeInTheDocument()
expect(screen.getByTestId("custom-logo")).toBeInTheDocument()
const logoContainer = document.querySelector(".juno-pageheader-logo-container")
expect(logoContainer).toHaveClass("jn:**:h-7", "jn:**:max-w-xs", "jn:**:object-contain", "jn:**:w-min")
})

test("renders a custom className", () => {
render(<PageHeader className="my-custom-classname" />)
expect(screen.getByRole("banner")).toBeInTheDocument()
Expand Down
Loading