import { NavigatorScreens, useNavigatorButtons } from '@automattic/onboarding'; import { Navigator } from '@wordpress/components/build-types/navigator/types'; import { Element, useMemo } from '@wordpress/element'; import { decodeEntities } from '@wordpress/html-entities'; import { useTranslate } from 'i18n-calypso'; import { MutableRefObject } from 'react'; import type { Category } from '@automattic/design-picker/src/types'; import type { NavigatorScreenObject } from '@automattic/onboarding'; interface CategoryBadgeProps { category: Category; onClick?: ( category: Category ) => void; } const CategoryBadge: React.FC< CategoryBadgeProps > = ( { category, onClick } ) => { if ( ! onClick ) { return
{ category.name }
; } return ( ); }; interface SidebarProps { title?: Element; author?: string; categories?: Category[]; description?: string; shortDescription?: string; pricingBadge?: React.ReactNode; screens: NavigatorScreenObject[]; actionButtons: React.ReactNode; navigatorRef: MutableRefObject< Navigator | null >; onClickCategory?: ( category: Category ) => void; onNavigatorPathChange?: ( path?: string ) => void; } const Sidebar: React.FC< SidebarProps > = ( { title, author, categories = [], pricingBadge, description, shortDescription, screens, actionButtons, navigatorRef, onClickCategory, onNavigatorPathChange, } ) => { const translate = useTranslate(); const navigatorButtons = useNavigatorButtons( screens ); const decodedDescription = useMemo( () => ( description ? decodeEntities( description ) : undefined ), [ description ] ); const decodedShortDescription = useMemo( () => ( shortDescription ? decodeEntities( shortDescription ) : undefined ), [ shortDescription ] ); return (
<>

{ title }

{ author && (
{ translate( 'By %(author)s', { args: { author } } ) }
) } { ( pricingBadge || categories.length > 0 ) && (
{ pricingBadge } { categories.map( ( category ) => ( ) ) }
) } { ( decodedDescription || decodedShortDescription ) && (

{ screens.length !== 1 ? decodedDescription : decodedShortDescription }

) }
{ navigatorButtons } { actionButtons && (
{ actionButtons }
) }
); }; export default Sidebar;