Skip to content

fix: logo prop refactor to component based#85

Open
ZehranurC wants to merge 2 commits into
mainfrom
feature/navbar_accept_external_component_logo
Open

fix: logo prop refactor to component based#85
ZehranurC wants to merge 2 commits into
mainfrom
feature/navbar_accept_external_component_logo

Conversation

@ZehranurC

@ZehranurC ZehranurC commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Description

NavBar logo prop refactored to accept React components instead of image paths.

Changes:

  • Removed imgPath: string prop
  • Added image: ReactElement for flexible component rendering
  • Supports <img>, <Image>, <NextImage>, and other custom components

Type of Change

  • 🆕 New Component
  • ✨ Feature / Enhancement
  • 🐛 Bug Fix
  • 💥 Breaking Change
  • 📦 Build / Dependency / Docs Update
  • 🧹 Code Refactoring

Checklist

  • Self-reviewed, no leftover logs or debug code
  • Uses design tokens — no hardcoded style values
  • Accessible (keyboard nav, ARIA, contrast)
  • Tests added/updated and passing
  • Storybook story added/updated

How to Test

<NavBar logo={{ image: <img src="logo.png" alt="Logo" />, href: "/" }} />

Comment on lines +184 to +194
it("should render a custom component as the logo", () => {
const CustomLogo = ({ title }: { title: string }) => (
<svg role="img" aria-label={title}>
<title>{title}</title>
</svg>
);
const { getByRole } = render(<NavBar logo={{ image: <CustomLogo title="Custom logo" /> }} />);

expect(getByRole("img", { name: "Custom logo" })).toBeInTheDocument();
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I understand that there is no alt message support if user provided none. At least we could define default value for alt prop to show some value if there is a problem while rendering custom image or logo.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the new commit, we've moved to a flexible approach: logoSlot: ReactElement
This allows users to pass any component (img, Image, SVG, etc.)
with full control over attributes like alt etc.

This resolves the concern about alt text support.

@aktasmehmet aktasmehmet requested a review from a team June 16, 2026 06:09
Comment on lines -4 to 6
imgPath: string;
alt?: string;
image: ReactElement;
href?: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this change got me stop reviewing any further. This is an additional feature and we dont need to drop supporting previous props. If you do this way, the apps using this props will collapse.

So, I would keep the current props as it is and still render an , put an additional logoSlot: ReactElement prop to the Navbar itself. if logo is given, it should render that. If only logoSlot is given, then render that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants