From c04e0f0c2a98915ae107313edadd88494e628912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D1=81=D0=B5=D0=BD=D0=B8=D1=8F?= <31247233+kseniya57@users.noreply.github.com> Date: Thu, 22 Feb 2024 22:11:43 +0300 Subject: [PATCH] feat(logo): add target property (#203) Co-authored-by: kseniyakuzina --- src/components/Logo/Logo.tsx | 7 +++++-- src/components/MobileLogo/MobileLogo.tsx | 4 +++- src/components/types.ts | 3 ++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/Logo/Logo.tsx b/src/components/Logo/Logo.tsx index 84b4e09..56d2122 100644 --- a/src/components/Logo/Logo.tsx +++ b/src/components/Logo/Logo.tsx @@ -18,6 +18,7 @@ export const Logo: React.FC = ({ iconSize = 24, textSize = 15, href, + target = '_self', wrapper, onClick, }) => { @@ -43,7 +44,8 @@ export const Logo: React.FC = ({ className={b('btn-logo')} component={hasWrapper ? 'span' : undefined} onClick={onClick} - target="_self" + target={target} + rel={target === '_self' ? undefined : 'noreferrer'} href={href} > {buttonIcon} @@ -73,7 +75,8 @@ export const Logo: React.FC = ({ ) : ( diff --git a/src/components/MobileLogo/MobileLogo.tsx b/src/components/MobileLogo/MobileLogo.tsx index 7bab9ef..3229af4 100644 --- a/src/components/MobileLogo/MobileLogo.tsx +++ b/src/components/MobileLogo/MobileLogo.tsx @@ -22,6 +22,7 @@ export const MobileLogo: React.FC = ({ iconSize = 32, textSize = 20, href = '/', + target = '_self', wrapper, onClick, }) => { @@ -31,7 +32,8 @@ export const MobileLogo: React.FC = ({ const linkProps = hasClickHandler ? {} : { - target: '_self', + target, + ref: target === '_self' ? undefined : 'noreferrer', href, }; diff --git a/src/components/types.ts b/src/components/types.ts index 7c7b24e..e4e2f6f 100644 --- a/src/components/types.ts +++ b/src/components/types.ts @@ -1,4 +1,4 @@ -import React from 'react'; +import React, {HTMLAttributeAnchorTarget} from 'react'; import {AlertProps, IconProps} from '@gravity-ui/uikit'; @@ -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) => void; }