diff --git a/code/ui/components/src/components/ActionBar/ActionBar.tsx b/code/ui/components/src/components/ActionBar/ActionBar.tsx index 6295bf99349a..1668a030e300 100644 --- a/code/ui/components/src/components/ActionBar/ActionBar.tsx +++ b/code/ui/components/src/components/ActionBar/ActionBar.tsx @@ -1,4 +1,4 @@ -import type { FC, MouseEvent, ReactElement } from 'react'; +import type { MouseEvent, ReactElement } from 'react'; import React from 'react'; import { styled } from '@storybook/theming'; @@ -66,7 +66,7 @@ export interface ActionBarProps { actionItems: ActionItem[]; } -export const ActionBar: FC = ({ actionItems, ...props }) => ( +export const ActionBar = ({ actionItems, ...props }: ActionBarProps) => ( {actionItems.map(({ title, className, onClick, disabled }, index: number) => ( diff --git a/code/ui/components/src/components/Badge/Badge.tsx b/code/ui/components/src/components/Badge/Badge.tsx index bcb4d3b01b50..f9d1c9b91ebb 100644 --- a/code/ui/components/src/components/Badge/Badge.tsx +++ b/code/ui/components/src/components/Badge/Badge.tsx @@ -1,4 +1,3 @@ -import type { FC, PropsWithChildren } from 'react'; import React from 'react'; import { styled } from '@storybook/theming'; import { transparentize } from 'polished'; @@ -80,10 +79,11 @@ const BadgeWrapper = styled.div( } ); -export interface BadgeProps extends PropsWithChildren { +export interface BadgeProps { status: 'positive' | 'negative' | 'neutral' | 'warning' | 'critical'; + children?: React.ReactNode; } -export const Badge: FC = ({ ...props }) => { +export const Badge = ({ ...props }: BadgeProps) => { return ; }; diff --git a/code/ui/components/src/components/ErrorFormatter/ErrorFormatter.tsx b/code/ui/components/src/components/ErrorFormatter/ErrorFormatter.tsx index 6d02a63aba20..1ca2cb381ff7 100644 --- a/code/ui/components/src/components/ErrorFormatter/ErrorFormatter.tsx +++ b/code/ui/components/src/components/ErrorFormatter/ErrorFormatter.tsx @@ -1,5 +1,5 @@ import { global } from '@storybook/global'; -import type { FC } from 'react'; + import React, { Fragment } from 'react'; import { styled } from '@storybook/theming'; @@ -20,7 +20,12 @@ const firstLineRegex = /(Error): (.*)\n/; const linesRegexChromium = /at (?:(.*) )?\(?(.+)\)?/; const linesRegexFirefox = /([^@]+)?(?:\/<)?@(.+)?/; const linesRegexSafari = /([^@]+)?@(.+)?/; -export const ErrorFormatter: FC<{ error: Error }> = ({ error }) => { + +export interface ErrorFormatterProps { + error: Error; +} + +export const ErrorFormatter = ({ error }: ErrorFormatterProps) => { if (!error) { return This error has no stack or message; } diff --git a/code/ui/components/src/components/Loader/Loader.tsx b/code/ui/components/src/components/Loader/Loader.tsx index c4f89c572a5d..c4fc4eb68e86 100644 --- a/code/ui/components/src/components/Loader/Loader.tsx +++ b/code/ui/components/src/components/Loader/Loader.tsx @@ -1,5 +1,4 @@ import { transparentize } from 'polished'; -import type { ComponentProps, FC } from 'react'; import React from 'react'; import { styled, keyframes } from '@storybook/theming'; import { Icons } from '../icon/icon'; @@ -98,18 +97,13 @@ interface Progress { }; } -interface LoaderProps { +interface LoaderProps extends React.HTMLAttributes { progress?: Progress; error?: Error; size?: number; } -export const Loader: FC> = ({ - progress, - error, - size, - ...props -}) => { +export const Loader = ({ progress, error, size, ...props }: LoaderProps) => { if (error) { return ( diff --git a/code/ui/components/src/components/ScrollArea/ScrollArea.tsx b/code/ui/components/src/components/ScrollArea/ScrollArea.tsx index b06fff3f5ec4..f3f965af8783 100644 --- a/code/ui/components/src/components/ScrollArea/ScrollArea.tsx +++ b/code/ui/components/src/components/ScrollArea/ScrollArea.tsx @@ -1,4 +1,3 @@ -import type { FC } from 'react'; import React from 'react'; import { styled } from '@storybook/theming'; import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area'; @@ -76,14 +75,14 @@ const ScrollAreaThumb = styled(ScrollAreaPrimitive.Thumb)(({ theme }) => ({ }, })); -export const ScrollArea: FC = ({ +export const ScrollArea = ({ children, horizontal = false, vertical = false, offset = 2, scrollbarSize = 6, className, -}) => ( +}: ScrollAreaProps) => ( {children} {horizontal && ( diff --git a/code/ui/components/src/components/bar/bar.tsx b/code/ui/components/src/components/bar/bar.tsx index bdbb60757f38..27c595c65a8a 100644 --- a/code/ui/components/src/components/bar/bar.tsx +++ b/code/ui/components/src/components/bar/bar.tsx @@ -1,7 +1,8 @@ -import type { ComponentProps, FC } from 'react'; +import type { ComponentProps } from 'react'; import React, { Children } from 'react'; import { styled } from '@storybook/theming'; +import type { ScrollAreaProps } from '../ScrollArea/ScrollArea'; import { ScrollArea } from '../ScrollArea/ScrollArea'; export interface SideProps { @@ -39,11 +40,11 @@ export const Side = styled.div( ); Side.displayName = 'Side'; -const UnstyledBar: FC & { scrollable?: boolean }> = ({ - children, - className, - scrollable, -}) => +interface UnstyledBarProps extends ScrollAreaProps { + scrollable?: boolean; +} + +const UnstyledBar = ({ children, className, scrollable }: UnstyledBarProps) => scrollable ? ( {children} @@ -51,7 +52,11 @@ const UnstyledBar: FC & { scrollable?: boolean ) : (
{children}
); -export const Bar = styled(UnstyledBar)<{ border?: boolean; scrollable?: boolean }>( + +export interface BarProps extends UnstyledBarProps { + border?: boolean; +} +export const Bar = styled(UnstyledBar)( ({ theme, scrollable = true }) => ({ color: theme.barTextColor, width: '100%', @@ -70,7 +75,10 @@ export const Bar = styled(UnstyledBar)<{ border?: boolean; scrollable?: boolean ); Bar.displayName = 'Bar'; -const BarInner = styled.div<{ bgColor: string }>(({ bgColor }) => ({ +interface BarInnerProps { + bgColor?: string; +} +const BarInner = styled.div(({ bgColor }) => ({ display: 'flex', justifyContent: 'space-between', position: 'relative', @@ -85,7 +93,7 @@ export interface FlexBarProps extends ComponentProps { backgroundColor?: string; } -export const FlexBar: FC = ({ children, backgroundColor, ...rest }) => { +export const FlexBar = ({ children, backgroundColor, ...rest }: FlexBarProps) => { const [left, right] = Children.toArray(children); return ( diff --git a/code/ui/components/src/components/bar/button.tsx b/code/ui/components/src/components/bar/button.tsx index 0c45c0ba3fa6..68ce83036b59 100644 --- a/code/ui/components/src/components/bar/button.tsx +++ b/code/ui/components/src/components/bar/button.tsx @@ -2,7 +2,6 @@ import type { AnchorHTMLAttributes, ButtonHTMLAttributes, DetailedHTMLProps, - FC, ForwardedRef, ForwardRefExoticComponent, ReactElement, @@ -147,7 +146,7 @@ const IconButtonSkeletonWrapper = styled.div(() => ({ * @deprecated * This component will be removed in Storybook 9.0 * */ -export const IconButtonSkeleton: FC = () => ( +export const IconButtonSkeleton = () => ( diff --git a/code/ui/components/src/components/bar/separator.tsx b/code/ui/components/src/components/bar/separator.tsx index d0606458d042..316c432022c8 100644 --- a/code/ui/components/src/components/bar/separator.tsx +++ b/code/ui/components/src/components/bar/separator.tsx @@ -1,6 +1,10 @@ import React, { Fragment } from 'react'; import { styled } from '@storybook/theming'; +export interface SeparatorProps { + force?: boolean; +} + export const Separator = styled.span( ({ theme }) => ({ width: 1, @@ -35,6 +39,3 @@ export const interleaveSeparators = (list: any[]) => ), null ); -export interface SeparatorProps { - force?: boolean; -} diff --git a/code/ui/components/src/components/brand/StorybookIcon.tsx b/code/ui/components/src/components/brand/StorybookIcon.tsx index 5b756ea3afc6..b880d5bcefc7 100644 --- a/code/ui/components/src/components/brand/StorybookIcon.tsx +++ b/code/ui/components/src/components/brand/StorybookIcon.tsx @@ -1,7 +1,6 @@ -import type { FC } from 'react'; import React from 'react'; -export const StorybookIcon: FC = ({ ...props }) => ( +export const StorybookIcon = (props: React.SVGAttributes) => ( Storybook icon diff --git a/code/ui/components/src/components/brand/StorybookLogo.tsx b/code/ui/components/src/components/brand/StorybookLogo.tsx index b94c9e37f144..aafcc0aa1149 100644 --- a/code/ui/components/src/components/brand/StorybookLogo.tsx +++ b/code/ui/components/src/components/brand/StorybookLogo.tsx @@ -1,9 +1,10 @@ -import type { FC } from 'react'; import React from 'react'; -export const StorybookLogo: FC<{ +type StorybookLogoProps = { alt: string; -}> = ({ alt, ...props }) => ( +} & React.SVGAttributes; + +export const StorybookLogo = ({ alt, ...props }: StorybookLogoProps) => ( {alt ? {alt} : null} diff --git a/code/ui/components/src/components/form/field/field.tsx b/code/ui/components/src/components/form/field/field.tsx index 6452a31e3444..19b21ae8d2f7 100644 --- a/code/ui/components/src/components/form/field/field.tsx +++ b/code/ui/components/src/components/form/field/field.tsx @@ -1,4 +1,4 @@ -import type { FC, ReactNode } from 'react'; +import type { ReactNode } from 'react'; import React from 'react'; import { styled } from '@storybook/theming'; @@ -28,7 +28,7 @@ export interface FieldProps { label?: ReactNode; } -export const Field: FC = ({ label, children, ...props }) => ( +export const Field = ({ label, children, ...props }: FieldProps) => ( {label ? (