diff --git a/packages/core-components/api-report.md b/packages/core-components/api-report.md index 0f8ea308c6..f3652d98cf 100644 --- a/packages/core-components/api-report.md +++ b/packages/core-components/api-report.md @@ -74,12 +74,13 @@ export function Avatar(props: AvatarProps): JSX.Element; // Warning: (ae-missing-release-tag) "Breadcrumbs" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const Breadcrumbs: ({ children, ...props }: Props_24) => JSX.Element; +export function Breadcrumbs(props: Props_24): JSX.Element; +// Warning: (ae-forgotten-export) The symbol "IconComponentProps" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "BrokenImageIcon" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const BrokenImageIcon: IconComponent; +export function BrokenImageIcon(props: IconComponentProps): JSX.Element; // Warning: (ae-forgotten-export) The symbol "Props" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "ButtonType" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) @@ -91,20 +92,17 @@ export function Button(props: Props): JSX.Element; // Warning: (ae-missing-release-tag) "CardTab" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const CardTab: ({ - children, - ...props -}: PropsWithChildren) => JSX.Element; +export function CardTab(props: PropsWithChildren): JSX.Element; // Warning: (ae-missing-release-tag) "CatalogIcon" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const CatalogIcon: IconComponent; +export function CatalogIcon(props: IconComponentProps): JSX.Element; // Warning: (ae-missing-release-tag) "ChatIcon" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const ChatIcon: IconComponent; +export function ChatIcon(props: IconComponentProps): JSX.Element; // Warning: (ae-forgotten-export) The symbol "Props" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "CodeSnippet" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) @@ -116,25 +114,15 @@ export const CodeSnippet: (props: Props_2) => JSX.Element; // Warning: (ae-missing-release-tag) "Content" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const Content: ({ - className, - stretch, - noPadding, - children, - ...props -}: PropsWithChildren) => JSX.Element; +export function Content(props: PropsWithChildren): JSX.Element; // Warning: (ae-forgotten-export) The symbol "ContentHeaderProps" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "ContentHeader" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const ContentHeader: ({ - description, - title, - titleComponent: TitleComponent, - children, - textAlign, -}: PropsWithChildren) => JSX.Element; +export function ContentHeader( + props: PropsWithChildren, +): JSX.Element; // Warning: (ae-forgotten-export) The symbol "Props" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "CopyTextButton" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) @@ -162,7 +150,7 @@ export function CreateButton(props: CreateButtonProps): JSX.Element | null; // Warning: (ae-missing-release-tag) "DashboardIcon" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const DashboardIcon: IconComponent; +export function DashboardIcon(props: IconComponentProps): JSX.Element; // Warning: (ae-forgotten-export) The symbol "CustomType" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "DependencyEdge" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) @@ -229,7 +217,7 @@ export const DismissableBanner: (props: Props_4) => JSX.Element; // Warning: (ae-missing-release-tag) "DocsIcon" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const DocsIcon: IconComponent; +export function DocsIcon(props: IconComponentProps): JSX.Element; // Warning: (ae-missing-release-tag) "EdgeProperties" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -248,7 +236,7 @@ type EdgeProperties = { // Warning: (ae-missing-release-tag) "EmailIcon" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const EmailIcon: IconComponent; +export function EmailIcon(props: IconComponentProps): JSX.Element; // Warning: (ae-forgotten-export) The symbol "Props" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "EmptyState" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) @@ -274,11 +262,7 @@ export type ErrorBoundaryProps = { // Warning: (ae-missing-release-tag) "ErrorPage" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const ErrorPage: ({ - status, - statusMessage, - additionalInfo, -}: IErrorPageProps) => JSX.Element; +export function ErrorPage(props: IErrorPageProps): JSX.Element; // Warning: (ae-missing-release-tag) "ErrorPanel" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -319,7 +303,7 @@ export function GaugeCard(props: Props_13): JSX.Element; // Warning: (ae-missing-release-tag) "GitHubIcon" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const GitHubIcon: IconComponent; +export function GitHubIcon(props: IconComponentProps): JSX.Element; // Warning: (ae-missing-release-tag) "GraphEdge" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -336,22 +320,13 @@ type GraphNode = dagre_2.Node>; // Warning: (ae-missing-release-tag) "GroupIcon" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const GroupIcon: IconComponent; +export function GroupIcon(props: IconComponentProps): JSX.Element; // Warning: (ae-forgotten-export) The symbol "Props" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "Header" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const Header: ({ - children, - pageTitleOverride, - style, - subtitle, - title, - tooltip, - type, - typeLink, -}: PropsWithChildren) => JSX.Element; +export function Header(props: PropsWithChildren): JSX.Element; // Warning: (ae-forgotten-export) The symbol "Props" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "HeaderIconLinkRow" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) @@ -363,31 +338,23 @@ export function HeaderIconLinkRow(props: Props_8): JSX.Element; // Warning: (ae-missing-release-tag) "HeaderLabel" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const HeaderLabel: ({ - label, - value, - url, -}: HeaderLabelProps) => JSX.Element; +export function HeaderLabel(props: HeaderLabelProps): JSX.Element; // Warning: (ae-forgotten-export) The symbol "HeaderTabsProps" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "HeaderTabs" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const HeaderTabs: ({ - tabs, - onChange, - selectedIndex, -}: HeaderTabsProps) => JSX.Element; +export function HeaderTabs(props: HeaderTabsProps): JSX.Element; // Warning: (ae-missing-release-tag) "HelpIcon" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const HelpIcon: IconComponent; +export function HelpIcon(props: IconComponentProps): JSX.Element; // Warning: (ae-missing-release-tag) "HomepageTimer" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const HomepageTimer: () => JSX.Element | null; +export function HomepageTimer(_props: {}): JSX.Element | null; // Warning: (ae-forgotten-export) The symbol "Props" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "HorizontalScrollGrid" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) @@ -414,26 +381,7 @@ export type IconLinkVerticalProps = { // Warning: (ae-missing-release-tag) "InfoCard" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const InfoCard: ({ - title, - subheader, - divider, - deepLink, - slackChannel, - errorBoundaryProps, - variant, - children, - headerStyle, - headerProps, - action, - actionsClassName, - actions, - cardClassName, - actionsTopRight, - className, - noPadding, - titleTypographyProps, -}: Props_19) => JSX.Element; +export function InfoCard(props: Props_19): JSX.Element; // Warning: (ae-missing-release-tag) "InfoCardVariants" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -444,7 +392,7 @@ export type InfoCardVariants = 'flex' | 'fullHeight' | 'gridItem'; // Warning: (ae-missing-release-tag) "IntroCard" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const IntroCard: (props: IntroCardProps) => JSX.Element; +export function IntroCard(props: IntroCardProps): JSX.Element; // Warning: (tsdoc-malformed-html-name) Invalid HTML element: Expecting an HTML name // Warning: (tsdoc-escape-greater-than) The ">" character should be escaped using a backslash to avoid confusion with an HTML tag @@ -452,16 +400,7 @@ export const IntroCard: (props: IntroCardProps) => JSX.Element; // Warning: (ae-missing-release-tag) "ItemCard" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public @deprecated -export const ItemCard: ({ - description, - tags, - title, - type, - subtitle, - label, - onClick, - href, -}: ItemCardProps) => JSX.Element; +export function ItemCard(props: ItemCardProps): JSX.Element; // Warning: (tsdoc-escape-greater-than) The ">" character should be escaped using a backslash to avoid confusion with an HTML tag // Warning: (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag @@ -472,7 +411,7 @@ export const ItemCard: ({ // Warning: (ae-missing-release-tag) "ItemCardGrid" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public -export const ItemCardGrid: (props: ItemCardGridProps) => JSX.Element; +export function ItemCardGrid(props: ItemCardGridProps): JSX.Element; // Warning: (ae-forgotten-export) The symbol "styles" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "ItemCardGridProps" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) @@ -491,7 +430,7 @@ export type ItemCardGridProps = Partial> & { // Warning: (ae-missing-release-tag) "ItemCardHeader" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public -export const ItemCardHeader: (props: ItemCardHeaderProps) => JSX.Element; +export function ItemCardHeader(props: ItemCardHeaderProps): JSX.Element; // Warning: (ae-forgotten-export) The symbol "styles" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "ItemCardHeaderProps" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) @@ -567,20 +506,15 @@ export function OverflowTooltip(props: Props_12): JSX.Element; // Warning: (ae-missing-release-tag) "Page" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const Page: ({ - themeId, - children, -}: PropsWithChildren) => JSX.Element; +export function Page(props: PropsWithChildren): JSX.Element; // Warning: (ae-forgotten-export) The symbol "PageWithHeaderProps" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "PageWithHeader" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const PageWithHeader: ({ - themeId, - children, - ...props -}: PropsWithChildren) => JSX.Element; +export function PageWithHeader( + props: PropsWithChildren, +): JSX.Element; // Warning: (ae-missing-release-tag) "Progress" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -645,11 +579,7 @@ export function Select(props: SelectProps): JSX.Element; // Warning: (ae-missing-release-tag) "Sidebar" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const Sidebar: ({ - openDelayMs, - closeDelayMs, - children, -}: PropsWithChildren) => JSX.Element; +export function Sidebar(props: PropsWithChildren): JSX.Element; // Warning: (ae-missing-release-tag) "SIDEBAR_INTRO_LOCAL_STORAGE" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -959,7 +889,7 @@ export const SidebarDivider: React_2.ComponentType< // Warning: (ae-missing-release-tag) "SidebarIntro" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const SidebarIntro: () => JSX.Element | null; +export function SidebarIntro(_props: {}): JSX.Element | null; // Warning: (ae-forgotten-export) The symbol "SidebarItemProps" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "SidebarItem" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) @@ -972,7 +902,7 @@ export const SidebarItem: React_2.ForwardRefExoticComponent< // Warning: (ae-missing-release-tag) "SidebarPage" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const SidebarPage: (props: PropsWithChildren<{}>) => JSX.Element; +export function SidebarPage(props: PropsWithChildren<{}>): JSX.Element; // Warning: (ae-missing-release-tag) "SidebarPinStateContext" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -1260,9 +1190,7 @@ export const SidebarScrollWrapper: React_2.ComponentType< // Warning: (ae-missing-release-tag) "SidebarSearchField" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const SidebarSearchField: ( - props: SidebarSearchFieldProps, -) => JSX.Element; +export function SidebarSearchField(props: SidebarSearchFieldProps): JSX.Element; // Warning: (ae-missing-release-tag) "SidebarSpace" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -1806,7 +1734,7 @@ export const SidebarSpacer: React_2.ComponentType< // Warning: (ae-missing-release-tag) "SignInPage" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const SignInPage: (props: Props_22) => JSX.Element; +export function SignInPage(props: Props_22): JSX.Element; // Warning: (ae-missing-release-tag) "SignInProviderConfig" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -1925,15 +1853,7 @@ export type Tab = { // Warning: (ae-missing-release-tag) "TabbedCard" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const TabbedCard: ({ - slackChannel, - errorBoundaryProps, - children, - title, - deepLink, - value, - onChange, -}: PropsWithChildren) => JSX.Element; +export function TabbedCard(props: PropsWithChildren): JSX.Element; // Warning: (ae-missing-release-tag) "TabbedLayout" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // Warning: (ae-missing-release-tag) "TabbedLayout" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) @@ -2028,7 +1948,7 @@ export function useQueryParamState( // Warning: (ae-missing-release-tag) "UserIcon" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const UserIcon: IconComponent; +export function UserIcon(props: IconComponentProps): JSX.Element; // Warning: (ae-missing-release-tag) "useSupportConfig" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -2038,7 +1958,7 @@ export function useSupportConfig(): SupportConfig; // Warning: (ae-missing-release-tag) "WarningIcon" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const WarningIcon: IconComponent; +export function WarningIcon(props: IconComponentProps): JSX.Element; // Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen // Warning: (tsdoc-param-tag-with-invalid-optional-name) The @param should not include a JSDoc-style optional name; it must not be enclosed in '[ ]' brackets. diff --git a/packages/core-components/src/icons/icons.tsx b/packages/core-components/src/icons/icons.tsx index 258bc9f8e1..7a9f7f9832 100644 --- a/packages/core-components/src/icons/icons.tsx +++ b/packages/core-components/src/icons/icons.tsx @@ -15,27 +15,48 @@ */ import MuiBrokenImageIcon from '@material-ui/icons/BrokenImage'; -import React from 'react'; +import React, { ComponentProps } from 'react'; import { useApp, IconComponent } from '@backstage/core-plugin-api'; -const overridableSystemIcon = (key: string): IconComponent => { - const Component: IconComponent = props => { - const app = useApp(); - const Icon = app.getSystemIcon(key); - return Icon ? : ; - }; - return Component; -}; +type IconComponentProps = ComponentProps; + +function useSystemIcon(key: string, props: IconComponentProps) { + const app = useApp(); + const Icon = app.getSystemIcon(key); + return Icon ? : ; +} // Should match the list of overridable system icon keys in @backstage/core-app-api -export const BrokenImageIcon = overridableSystemIcon('brokenImage'); -export const CatalogIcon = overridableSystemIcon('catalog'); -export const ChatIcon = overridableSystemIcon('chat'); -export const DashboardIcon = overridableSystemIcon('dashboard'); -export const DocsIcon = overridableSystemIcon('docs'); -export const EmailIcon = overridableSystemIcon('email'); -export const GitHubIcon = overridableSystemIcon('github'); -export const GroupIcon = overridableSystemIcon('group'); -export const HelpIcon = overridableSystemIcon('help'); -export const UserIcon = overridableSystemIcon('user'); -export const WarningIcon = overridableSystemIcon('warning'); +export function BrokenImageIcon(props: IconComponentProps) { + return useSystemIcon('brokenImage', props); +} +export function CatalogIcon(props: IconComponentProps) { + return useSystemIcon('catalog', props); +} +export function ChatIcon(props: IconComponentProps) { + return useSystemIcon('chat', props); +} +export function DashboardIcon(props: IconComponentProps) { + return useSystemIcon('dashboard', props); +} +export function DocsIcon(props: IconComponentProps) { + return useSystemIcon('docs', props); +} +export function EmailIcon(props: IconComponentProps) { + return useSystemIcon('email', props); +} +export function GitHubIcon(props: IconComponentProps) { + return useSystemIcon('github', props); +} +export function GroupIcon(props: IconComponentProps) { + return useSystemIcon('group', props); +} +export function HelpIcon(props: IconComponentProps) { + return useSystemIcon('help', props); +} +export function UserIcon(props: IconComponentProps) { + return useSystemIcon('user', props); +} +export function WarningIcon(props: IconComponentProps) { + return useSystemIcon('warning', props); +} diff --git a/packages/core-components/src/layout/BottomLink/BottomLink.tsx b/packages/core-components/src/layout/BottomLink/BottomLink.tsx index 74912acf4c..6d6811cc09 100644 --- a/packages/core-components/src/layout/BottomLink/BottomLink.tsx +++ b/packages/core-components/src/layout/BottomLink/BottomLink.tsx @@ -41,7 +41,8 @@ export type BottomLinkProps = { onClick?: (event: React.MouseEvent) => void; }; -export const BottomLink = ({ link, title, onClick }: BottomLinkProps) => { +export function BottomLink(props: BottomLinkProps) { + const { link, title, onClick } = props; const classes = useStyles(); return ( @@ -59,4 +60,4 @@ export const BottomLink = ({ link, title, onClick }: BottomLinkProps) => { ); -}; +} diff --git a/packages/core-components/src/layout/Breadcrumbs/Breadcrumbs.tsx b/packages/core-components/src/layout/Breadcrumbs/Breadcrumbs.tsx index 418217f3b5..28c86d32f0 100644 --- a/packages/core-components/src/layout/Breadcrumbs/Breadcrumbs.tsx +++ b/packages/core-components/src/layout/Breadcrumbs/Breadcrumbs.tsx @@ -41,7 +41,8 @@ const StyledBox = withStyles({ }, })(Box); -export const Breadcrumbs = ({ children, ...props }: Props) => { +export function Breadcrumbs(props: Props) { + const { children, ...restProps } = props; const [anchorEl, setAnchorEl] = React.useState( null, ); @@ -65,7 +66,7 @@ export const Breadcrumbs = ({ children, ...props }: Props) => { const open = Boolean(anchorEl); return ( - + {childrenArray.length > 1 && {firstPage}} {childrenArray.length > 2 && {secondPage}} {hasHiddenBreadcrumbs && ( @@ -96,4 +97,4 @@ export const Breadcrumbs = ({ children, ...props }: Props) => { ); -}; +} diff --git a/packages/core-components/src/layout/Content/Content.tsx b/packages/core-components/src/layout/Content/Content.tsx index 323565159a..a3771dff3f 100644 --- a/packages/core-components/src/layout/Content/Content.tsx +++ b/packages/core-components/src/layout/Content/Content.tsx @@ -47,17 +47,12 @@ type Props = { className?: string; }; -export const Content = ({ - className, - stretch, - noPadding, - children, - ...props -}: PropsWithChildren) => { +export function Content(props: PropsWithChildren) { + const { className, stretch, noPadding, children, ...restProps } = props; const classes = useStyles(); return (
); -}; +} diff --git a/packages/core-components/src/layout/ContentHeader/ContentHeader.tsx b/packages/core-components/src/layout/ContentHeader/ContentHeader.tsx index 2259731148..76fec703a9 100644 --- a/packages/core-components/src/layout/ContentHeader/ContentHeader.tsx +++ b/packages/core-components/src/layout/ContentHeader/ContentHeader.tsx @@ -82,13 +82,14 @@ type ContentHeaderProps = { textAlign?: 'left' | 'right' | 'center'; }; -export const ContentHeader = ({ - description, - title, - titleComponent: TitleComponent = undefined, - children, - textAlign = 'left', -}: PropsWithChildren) => { +export function ContentHeader(props: PropsWithChildren) { + const { + description, + title, + titleComponent: TitleComponent = undefined, + children, + textAlign = 'left', + } = props; const classes = useStyles({ textAlign })(); const renderedTitle = TitleComponent ? ( @@ -112,4 +113,4 @@ export const ContentHeader = ({ ); -}; +} diff --git a/packages/core-components/src/layout/ErrorPage/ErrorPage.tsx b/packages/core-components/src/layout/ErrorPage/ErrorPage.tsx index cca88147c4..f4b2960f96 100644 --- a/packages/core-components/src/layout/ErrorPage/ErrorPage.tsx +++ b/packages/core-components/src/layout/ErrorPage/ErrorPage.tsx @@ -47,11 +47,8 @@ const useStyles = makeStyles(theme => ({ }, })); -export const ErrorPage = ({ - status, - statusMessage, - additionalInfo, -}: IErrorPageProps) => { +export function ErrorPage(props: IErrorPageProps) { + const { status, statusMessage, additionalInfo } = props; const classes = useStyles(); const navigate = useNavigate(); const support = useSupportConfig(); @@ -82,4 +79,4 @@ export const ErrorPage = ({ ); -}; +} diff --git a/packages/core-components/src/layout/Header/Header.tsx b/packages/core-components/src/layout/Header/Header.tsx index 3b2771e299..dd56505720 100644 --- a/packages/core-components/src/layout/Header/Header.tsx +++ b/packages/core-components/src/layout/Header/Header.tsx @@ -174,16 +174,17 @@ const SubtitleFragment = ({ classes, subtitle }: SubtitleFragmentProps) => { ); }; -export const Header = ({ - children, - pageTitleOverride, - style, - subtitle, - title, - tooltip, - type, - typeLink, -}: PropsWithChildren) => { +export function Header(props: PropsWithChildren) { + const { + children, + pageTitleOverride, + style, + subtitle, + title, + tooltip, + type, + typeLink, + } = props; const classes = useStyles(); const configApi = useApi(configApiRef); const appTitle = configApi.getOptionalString('app.title') || 'Backstage'; @@ -216,4 +217,4 @@ export const Header = ({ ); -}; +} diff --git a/packages/core-components/src/layout/HeaderActionMenu/HeaderActionMenu.tsx b/packages/core-components/src/layout/HeaderActionMenu/HeaderActionMenu.tsx index 06a9b2b701..5243a65498 100644 --- a/packages/core-components/src/layout/HeaderActionMenu/HeaderActionMenu.tsx +++ b/packages/core-components/src/layout/HeaderActionMenu/HeaderActionMenu.tsx @@ -66,7 +66,8 @@ export type HeaderActionMenuProps = { actionItems: ActionItemProps[]; }; -export const HeaderActionMenu = ({ actionItems }: HeaderActionMenuProps) => { +export function HeaderActionMenu(props: HeaderActionMenuProps) { + const { actionItems } = props; const [open, setOpen] = React.useState(false); const anchorElRef = React.useRef(null); @@ -103,4 +104,4 @@ export const HeaderActionMenu = ({ actionItems }: HeaderActionMenuProps) => { ); -}; +} diff --git a/packages/core-components/src/layout/HeaderLabel/HeaderLabel.tsx b/packages/core-components/src/layout/HeaderLabel/HeaderLabel.tsx index 8557ceddf7..88f6e26bf5 100644 --- a/packages/core-components/src/layout/HeaderLabel/HeaderLabel.tsx +++ b/packages/core-components/src/layout/HeaderLabel/HeaderLabel.tsx @@ -51,7 +51,8 @@ type HeaderLabelProps = { url?: string; }; -export const HeaderLabel = ({ label, value, url }: HeaderLabelProps) => { +export function HeaderLabel(props: HeaderLabelProps) { + const { label, value, url } = props; const classes = useStyles(); const content = ( { ); -}; +} diff --git a/packages/core-components/src/layout/HeaderTabs/HeaderTabs.tsx b/packages/core-components/src/layout/HeaderTabs/HeaderTabs.tsx index 20742114c9..0fe3cd967e 100644 --- a/packages/core-components/src/layout/HeaderTabs/HeaderTabs.tsx +++ b/packages/core-components/src/layout/HeaderTabs/HeaderTabs.tsx @@ -55,11 +55,8 @@ type HeaderTabsProps = { onChange?: (index: number) => void; selectedIndex?: number; }; -export const HeaderTabs = ({ - tabs, - onChange, - selectedIndex, -}: HeaderTabsProps) => { +export function HeaderTabs(props: HeaderTabsProps) { + const { tabs, onChange, selectedIndex } = props; const [selectedTab, setSelectedTab] = useState(selectedIndex ?? 0); const styles = useStyles(); @@ -101,4 +98,4 @@ export const HeaderTabs = ({ ); -}; +} diff --git a/packages/core-components/src/layout/HomepageTimer/HomepageTimer.tsx b/packages/core-components/src/layout/HomepageTimer/HomepageTimer.tsx index 04073cca48..a78f4af8ca 100644 --- a/packages/core-components/src/layout/HomepageTimer/HomepageTimer.tsx +++ b/packages/core-components/src/layout/HomepageTimer/HomepageTimer.tsx @@ -67,7 +67,7 @@ function getTimes(configApi: ConfigApi) { return clocks; } -export const HomepageTimer = () => { +export function HomepageTimer(_props: {}) { const configApi = useApi(configApiRef); const defaultTimes: TimeObj[] = []; @@ -99,4 +99,4 @@ export const HomepageTimer = () => { ); } return null; -}; +} diff --git a/packages/core-components/src/layout/InfoCard/InfoCard.tsx b/packages/core-components/src/layout/InfoCard/InfoCard.tsx index 650bf78bbd..36205b0dc0 100644 --- a/packages/core-components/src/layout/InfoCard/InfoCard.tsx +++ b/packages/core-components/src/layout/InfoCard/InfoCard.tsx @@ -128,26 +128,27 @@ type Props = { titleTypographyProps?: object; }; -export const InfoCard = ({ - title, - subheader, - divider = true, - deepLink, - slackChannel, - errorBoundaryProps, - variant, - children, - headerStyle, - headerProps, - action, - actionsClassName, - actions, - cardClassName, - actionsTopRight, - className, - noPadding, - titleTypographyProps, -}: Props): JSX.Element => { +export function InfoCard(props: Props): JSX.Element { + const { + title, + subheader, + divider = true, + deepLink, + slackChannel, + errorBoundaryProps, + variant, + children, + headerStyle, + headerProps, + action, + actionsClassName, + actions, + cardClassName, + actionsTopRight, + className, + noPadding, + titleTypographyProps, + } = props; const classes = useStyles(); /** * If variant is specified, we build up styles for that particular variant for both @@ -214,4 +215,4 @@ export const InfoCard = ({ ); -}; +} diff --git a/packages/core-components/src/layout/ItemCard/ItemCard.tsx b/packages/core-components/src/layout/ItemCard/ItemCard.tsx index b4273ee837..81a88d2c09 100644 --- a/packages/core-components/src/layout/ItemCard/ItemCard.tsx +++ b/packages/core-components/src/layout/ItemCard/ItemCard.tsx @@ -62,16 +62,9 @@ type ItemCardProps = { * @deprecated Use plain MUI and composable helpers instead. * @see https://material-ui.com/components/cards/ */ -export const ItemCard = ({ - description, - tags, - title, - type, - subtitle, - label, - onClick, - href, -}: ItemCardProps) => { +export function ItemCard(props: ItemCardProps) { + const { description, tags, title, type, subtitle, label, onClick, href } = + props; return ( @@ -101,4 +94,4 @@ export const ItemCard = ({ ); -}; +} diff --git a/packages/core-components/src/layout/ItemCard/ItemCardGrid.tsx b/packages/core-components/src/layout/ItemCard/ItemCardGrid.tsx index a5c57ba246..137c48d272 100644 --- a/packages/core-components/src/layout/ItemCard/ItemCardGrid.tsx +++ b/packages/core-components/src/layout/ItemCard/ItemCardGrid.tsx @@ -51,7 +51,7 @@ export type ItemCardGridProps = Partial> & { * This can be useful for e.g. overriding gridTemplateColumns to adapt the * minimum size of the cells to fit the content better. */ -export const ItemCardGrid = (props: ItemCardGridProps) => { +export function ItemCardGrid(props: ItemCardGridProps) { const { children, ...otherProps } = props; const classes = useStyles(otherProps); return ( @@ -59,4 +59,4 @@ export const ItemCardGrid = (props: ItemCardGridProps) => { {children} ); -}; +} diff --git a/packages/core-components/src/layout/ItemCard/ItemCardHeader.tsx b/packages/core-components/src/layout/ItemCard/ItemCardHeader.tsx index 58c7c1501d..15a1a7d78b 100644 --- a/packages/core-components/src/layout/ItemCard/ItemCardHeader.tsx +++ b/packages/core-components/src/layout/ItemCard/ItemCardHeader.tsx @@ -72,7 +72,7 @@ export type ItemCardHeaderProps = Partial> & { * * */ -export const ItemCardHeader = (props: ItemCardHeaderProps) => { +export function ItemCardHeader(props: ItemCardHeaderProps) { const { title, subtitle, children } = props; const classes = useStyles(props); return ( @@ -90,4 +90,4 @@ export const ItemCardHeader = (props: ItemCardHeaderProps) => { {children} ); -}; +} diff --git a/packages/core-components/src/layout/Page/Page.tsx b/packages/core-components/src/layout/Page/Page.tsx index f78dc038f2..b838693a3c 100644 --- a/packages/core-components/src/layout/Page/Page.tsx +++ b/packages/core-components/src/layout/Page/Page.tsx @@ -34,7 +34,8 @@ type Props = { themeId: string; }; -export const Page = ({ themeId, children }: PropsWithChildren) => { +export function Page(props: PropsWithChildren) { + const { themeId, children } = props; const classes = useStyles(); return ( ) => {
{children}
); -}; +} diff --git a/packages/core-components/src/layout/Page/PageWithHeader.tsx b/packages/core-components/src/layout/Page/PageWithHeader.tsx index 70a6c1f693..541b655dff 100644 --- a/packages/core-components/src/layout/Page/PageWithHeader.tsx +++ b/packages/core-components/src/layout/Page/PageWithHeader.tsx @@ -23,13 +23,12 @@ type PageWithHeaderProps = ComponentProps & { themeId: string; }; -export const PageWithHeader = ({ - themeId, - children, - ...props -}: PropsWithChildren) => ( - -
- {children} - -); +export function PageWithHeader(props: PropsWithChildren) { + const { themeId, children, ...restProps } = props; + return ( + +
+ {children} + + ); +} diff --git a/packages/core-components/src/layout/Sidebar/Bar.tsx b/packages/core-components/src/layout/Sidebar/Bar.tsx index f928c4b7c4..8855f01104 100644 --- a/packages/core-components/src/layout/Sidebar/Bar.tsx +++ b/packages/core-components/src/layout/Sidebar/Bar.tsx @@ -74,11 +74,12 @@ type Props = { closeDelayMs?: number; }; -export const Sidebar = ({ - openDelayMs = sidebarConfig.defaultOpenDelayMs, - closeDelayMs = sidebarConfig.defaultCloseDelayMs, - children, -}: PropsWithChildren) => { +export function Sidebar(props: PropsWithChildren) { + const { + openDelayMs = sidebarConfig.defaultOpenDelayMs, + closeDelayMs = sidebarConfig.defaultCloseDelayMs, + children, + } = props; const classes = useStyles(); const isSmallScreen = useMediaQuery(theme => theme.breakpoints.down('md'), @@ -149,4 +150,4 @@ export const Sidebar = ({ ); -}; +} diff --git a/packages/core-components/src/layout/Sidebar/Intro.tsx b/packages/core-components/src/layout/Sidebar/Intro.tsx index 14c5d9e25a..45098b49e1 100644 --- a/packages/core-components/src/layout/Sidebar/Intro.tsx +++ b/packages/core-components/src/layout/Sidebar/Intro.tsx @@ -74,7 +74,7 @@ type IntroCardProps = { onClose: () => void; }; -export const IntroCard = (props: IntroCardProps) => { +export function IntroCard(props: IntroCardProps) { const classes = useStyles(); const { text, onClose } = props; const handleClose = () => onClose(); @@ -97,7 +97,7 @@ export const IntroCard = (props: IntroCardProps) => { ); -}; +} type SidebarIntroLocalStorage = { starredItemsDismissed: boolean; @@ -127,7 +127,7 @@ Keep an eye out for the little star icon (⭐) next to the plugin name and give const recentlyViewedIntroText = 'And your recently viewed plugins will pop up here!'; -export const SidebarIntro = () => { +export function SidebarIntro(_props: {}) { const { isOpen } = useContext(SidebarContext); const defaultValue = { starredItemsDismissed: false, @@ -177,4 +177,4 @@ export const SidebarIntro = () => { )} ); -}; +} diff --git a/packages/core-components/src/layout/Sidebar/Items.tsx b/packages/core-components/src/layout/Sidebar/Items.tsx index 1068a877bd..b3acc36f98 100644 --- a/packages/core-components/src/layout/Sidebar/Items.tsx +++ b/packages/core-components/src/layout/Sidebar/Items.tsx @@ -282,7 +282,7 @@ type SidebarSearchFieldProps = { to?: string; }; -export const SidebarSearchField = (props: SidebarSearchFieldProps) => { +export function SidebarSearchField(props: SidebarSearchFieldProps) { const [input, setInput] = useState(''); const classes = useStyles(); @@ -334,7 +334,7 @@ export const SidebarSearchField = (props: SidebarSearchFieldProps) => { ); -}; +} export const SidebarSpace = styled('div')({ flex: 1, diff --git a/packages/core-components/src/layout/Sidebar/Page.tsx b/packages/core-components/src/layout/Sidebar/Page.tsx index 0ace7468ef..47c5878cde 100644 --- a/packages/core-components/src/layout/Sidebar/Page.tsx +++ b/packages/core-components/src/layout/Sidebar/Page.tsx @@ -49,7 +49,7 @@ export const SidebarPinStateContext = createContext( }, ); -export const SidebarPage = (props: PropsWithChildren<{}>) => { +export function SidebarPage(props: PropsWithChildren<{}>) { const [isPinned, setIsPinned] = useState(() => LocalStorage.getSidebarPinState(), ); @@ -71,4 +71,4 @@ export const SidebarPage = (props: PropsWithChildren<{}>) => {
{props.children}
); -}; +} diff --git a/packages/core-components/src/layout/SignInPage/SignInPage.tsx b/packages/core-components/src/layout/SignInPage/SignInPage.tsx index dcaad83c72..e0d4f6ed0d 100644 --- a/packages/core-components/src/layout/SignInPage/SignInPage.tsx +++ b/packages/core-components/src/layout/SignInPage/SignInPage.tsx @@ -192,10 +192,10 @@ export const SingleSignInPage = ({ ); }; -export const SignInPage = (props: Props) => { +export function SignInPage(props: Props) { if ('provider' in props) { return ; } return ; -}; +} diff --git a/packages/core-components/src/layout/TabbedCard/TabbedCard.tsx b/packages/core-components/src/layout/TabbedCard/TabbedCard.tsx index c9f2a477ef..f350b24f1d 100644 --- a/packages/core-components/src/layout/TabbedCard/TabbedCard.tsx +++ b/packages/core-components/src/layout/TabbedCard/TabbedCard.tsx @@ -62,15 +62,16 @@ type Props = { deepLink?: BottomLinkProps; }; -const TabbedCard = ({ - slackChannel, - errorBoundaryProps, - children, - title, - deepLink, - value, - onChange, -}: PropsWithChildren) => { +export function TabbedCard(props: PropsWithChildren) { + const { + slackChannel, + errorBoundaryProps, + children, + title, + deepLink, + value, + onChange, + } = props; const tabsClasses = useTabsStyles(); const [selectedIndex, selectIndex] = useState(0); @@ -111,7 +112,7 @@ const TabbedCard = ({ ); -}; +} const useCardTabStyles = makeStyles(theme => ({ root: { @@ -135,10 +136,9 @@ type CardTabProps = TabProps & { children: ReactNode; }; -const CardTab = ({ children, ...props }: PropsWithChildren) => { +export function CardTab(props: PropsWithChildren) { + const { children, ...restProps } = props; const classes = useCardTabStyles(); - return ; -}; - -export { TabbedCard, CardTab }; + return ; +}