From c3c503a49ace1d9eec692cf06c73b84a4c019b57 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Thu, 25 Jan 2024 11:08:05 +0100 Subject: [PATCH] fix types, simplify Link --- code/ui/components/src/components/icon/icon.tsx | 2 +- .../src/components/typography/elements/Link.tsx | 15 ++++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/code/ui/components/src/components/icon/icon.tsx b/code/ui/components/src/components/icon/icon.tsx index 270431624e99..b0164ef2a276 100644 --- a/code/ui/components/src/components/icon/icon.tsx +++ b/code/ui/components/src/components/icon/icon.tsx @@ -6,7 +6,7 @@ import { styled } from '@storybook/theming'; import { deprecate, logger } from '@storybook/client-logger'; export type IconType = keyof typeof icons; -type NewIconTypes = typeof icons[IconType]; +type NewIconTypes = (typeof icons)[IconType]; const NEW_ICON_MAP = StorybookIcons as Record React.ReactNode>; diff --git a/code/ui/components/src/components/typography/elements/Link.tsx b/code/ui/components/src/components/typography/elements/Link.tsx index ace6beec1971..dbb48f48a149 100644 --- a/code/ui/components/src/components/typography/elements/Link.tsx +++ b/code/ui/components/src/components/typography/elements/Link.tsx @@ -1,18 +1,11 @@ import React from 'react'; -export interface LinkProps extends React.AnchorHTMLAttributes { - children: React.ReactNode; -} - -export const Link = ({ href: input, children, ...props }: LinkProps) => { +export const Link = ({ href: input, ...props }: React.AnchorHTMLAttributes) => { const isStorybookPath = /^\//.test(input); - const isAnchorUrl = /^#.*/.test(input); const href = isStorybookPath ? `./?path=${input}` : input; + + const isAnchorUrl = /^#.*/.test(input); const target = isAnchorUrl ? '_self' : '_top'; - return ( - - {children} - - ); + return ; };