Skip to content

Commit

Permalink
feat(logo): add target property (#203)
Browse files Browse the repository at this point in the history
Co-authored-by: kseniyakuzina <[email protected]>
  • Loading branch information
kseniya57 and kseniyakuzina authored Feb 22, 2024
1 parent d5e422e commit c04e0f0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/components/Logo/Logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const Logo: React.FC<LogoProps> = ({
iconSize = 24,
textSize = 15,
href,
target = '_self',
wrapper,
onClick,
}) => {
Expand All @@ -43,7 +44,8 @@ export const Logo: React.FC<LogoProps> = ({
className={b('btn-logo')}
component={hasWrapper ? 'span' : undefined}
onClick={onClick}
target="_self"
target={target}
rel={target === '_self' ? undefined : 'noreferrer'}
href={href}
>
{buttonIcon}
Expand Down Expand Up @@ -73,7 +75,8 @@ export const Logo: React.FC<LogoProps> = ({
) : (
<a
href={href ?? '/'}
target="_self"
target={target}
rel={target === '_self' ? undefined : 'noreferrer'}
className={b('logo-link')}
onClick={onClick}
>
Expand Down
4 changes: 3 additions & 1 deletion src/components/MobileLogo/MobileLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const MobileLogo: React.FC<MobileLogoProps> = ({
iconSize = 32,
textSize = 20,
href = '/',
target = '_self',
wrapper,
onClick,
}) => {
Expand All @@ -31,7 +32,8 @@ export const MobileLogo: React.FC<MobileLogoProps> = ({
const linkProps = hasClickHandler
? {}
: {
target: '_self',
target,
ref: target === '_self' ? undefined : 'noreferrer',
href,
};

Expand Down
3 changes: 2 additions & 1 deletion src/components/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, {HTMLAttributeAnchorTarget} from 'react';

import {AlertProps, IconProps} from '@gravity-ui/uikit';

Expand Down Expand Up @@ -65,6 +65,7 @@ export interface LogoProps {
iconSize?: number;
textSize?: number;
href?: string;
target?: HTMLAttributeAnchorTarget;
wrapper?: (node: React.ReactNode, compact: boolean) => React.ReactNode;
onClick?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
}
Expand Down

0 comments on commit c04e0f0

Please sign in to comment.