Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: open brandUrl in new window #6106

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -8388,6 +8388,7 @@ exports[`Storyshots UI|Sidebar/Sidebar loading 1`] = `
<a
class="emotion-1"
href="./"
target=""
>
<svg
class="emotion-0"
Expand Down Expand Up @@ -9813,6 +9814,7 @@ exports[`Storyshots UI|Sidebar/Sidebar simple 1`] = `
<a
class="emotion-1"
href="./"
target=""
>
<svg
class="emotion-0"
Expand Down Expand Up @@ -10393,6 +10395,7 @@ exports[`Storyshots UI|Sidebar/SidebarHeading customBrandImage 1`] = `
<a
class="emotion-1"
href="https://example.com"
target="_blank"
>
<img
alt="My Title"
Expand Down Expand Up @@ -10693,6 +10696,7 @@ exports[`Storyshots UI|Sidebar/SidebarHeading linkAndText 1`] = `
<a
class="emotion-0"
href="https://example.com"
target="_blank"
>
My title
</a>
Expand Down Expand Up @@ -11300,6 +11304,7 @@ exports[`Storyshots UI|Sidebar/SidebarHeading menuHighlighted 1`] = `
<a
class="emotion-1"
href="./"
target=""
>
<svg
class="emotion-0"
Expand Down Expand Up @@ -11930,6 +11935,7 @@ exports[`Storyshots UI|Sidebar/SidebarHeading standard 1`] = `
<a
class="emotion-1"
href="./"
target=""
>
<svg
class="emotion-0"
Expand Down
11 changes: 8 additions & 3 deletions lib/ui/src/components/sidebar/SidebarHeading.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,13 @@ const Head = styled.div({
});

const Brand = withTheme(({ theme: { brand: { title = 'Storybook', url = './', image } } }) => {
const targetValue = url === './' ? '' : '_blank';
if (image === undefined && url === null) {
return <Logo alt={title} />;
}
if (image === undefined && url) {
return (
<LogoLink href={url}>
<LogoLink href={url} target={targetValue}>
<Logo alt={title} />
</LogoLink>
);
Expand All @@ -79,14 +80,18 @@ const Brand = withTheme(({ theme: { brand: { title = 'Storybook', url = './', im
return title;
}
if (image === null && url) {
return <LogoLink href={url}>{title}</LogoLink>;
return (
<LogoLink href={url} target={targetValue}>
{title}
</LogoLink>
);
}
if (image && url === null) {
return <Img src={image} alt={title} />;
}
if (image && url) {
return (
<LogoLink href={url}>
<LogoLink href={url} target={targetValue}>
<Img src={image} alt={title} />
</LogoLink>
);
Expand Down