import { getPlanClass, isEcommercePlan, isBusinessPlan, isWooExpressPlan, isWpcomEnterpriseGridPlan, isPersonalPlan, isPremiumPlan, isFreePlan, PlanSlug, isPartnerBundleOnboarding, } from '@automattic/calypso-products'; import { AutomatticLogo, CloudLogo, VIPLogo, WooLogo } from '@automattic/components'; import clsx from 'clsx'; import { useTranslate } from 'i18n-calypso'; import { usePlansGridContext } from '../grid-context'; import useHighlightAdjacencyMatrix from '../hooks/use-highlight-adjacency-matrix'; import { useManageTooltipToggle } from '../hooks/use-manage-tooltip-toggle'; import PlanDivOrTdContainer from './plan-div-td-container'; import { Plans2023Tooltip } from './plans-2023-tooltip'; import PopularBadge from './popular-badge'; import type { GridPlan } from '../types'; const PlanLogo: React.FunctionComponent< { renderedGridPlans: GridPlan[]; planSlug: PlanSlug; isInSignup?: boolean; isTableCell?: boolean; planIndex: number; } > = ( { planSlug, isInSignup, renderedGridPlans, isTableCell, planIndex } ) => { const [ activeTooltipId, setActiveTooltipId ] = useManageTooltipToggle(); const translate = useTranslate(); const { gridPlansIndex, intent, isEnterpriseA4AIndia } = usePlansGridContext(); const isWooHostingSolutionsIntent = intent === 'plans-woo-hosting-solutions'; const shouldShowWooLogo = isWooHostingSolutionsIntent || ( isEcommercePlan( planSlug ) && ! isWooExpressPlan( planSlug ) ); const shouldShowPopularBadge = ! isPartnerBundleOnboarding(); const { current } = gridPlansIndex[ planSlug ]; const highlightAdjacencyMatrix = useHighlightAdjacencyMatrix( { renderedGridPlans, } ); const headerClasses = clsx( 'plan-features-2023-grid__header-logo', getPlanClass( planSlug ) ); const tableItemClasses = clsx( 'plan-features-2023-grid__table-item', { 'popular-plan-parent-class': gridPlansIndex[ planSlug ]?.highlightLabel, 'is-left-of-highlight': highlightAdjacencyMatrix[ planSlug as keyof typeof highlightAdjacencyMatrix ] ?.leftOfHighlight, 'is-right-of-highlight': highlightAdjacencyMatrix[ planSlug as keyof typeof highlightAdjacencyMatrix ] ?.rightOfHighlight, 'is-only-highlight': highlightAdjacencyMatrix[ planSlug as keyof typeof highlightAdjacencyMatrix ] ?.isOnlyHighlight, 'is-current-plan': current, 'is-first-in-row': planIndex === 0, 'is-last-in-row': planIndex === renderedGridPlans.length - 1, } ); const popularBadgeClasses = clsx( { 'with-plan-logo': ! ( isFreePlan( planSlug ) || isPersonalPlan( planSlug ) || isPremiumPlan( planSlug ) ), } ); return ( { shouldShowPopularBadge && ( ) }
{ ! isWooHostingSolutionsIntent && isBusinessPlan( planSlug ) && ( ) } { shouldShowWooLogo && ( ) } { ! isWooHostingSolutionsIntent && isWpcomEnterpriseGridPlan( planSlug ) && ( isEnterpriseA4AIndia ? ( ) : ( ) ) }
); }; export default PlanLogo;