Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add info popover for tier dropdown #90600

Merged
merged 3 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions client/my-sites/plans/jetpack-plans/product-lightbox/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,24 @@ export const PRODUCT_OPTIONS_HEADER: Record< string, TranslateResult > = {
comment: '%(product)s is the name of the product',
} ),
};

export const PRODUCT_OPTIONS_HEADER_INFO_CONTENT: Record< string, TranslateResult > = {
[ PRODUCT_JETPACK_AI_BI_YEARLY ]: translate(
'Each interaction with the AI system counts as one request. Images may use multiple requests. You can upgrade at any time if you run out of requests.'
),
[ PRODUCT_JETPACK_AI_YEARLY ]: translate(
'Each interaction with the AI system counts as one request. Images may use multiple requests. You can upgrade at any time if you run out of requests.'
),
[ PRODUCT_JETPACK_AI_MONTHLY ]: translate(
'Each interaction with the AI system counts as one request. Images may use multiple requests. You can upgrade at any time if you run out of requests.'
),
[ PRODUCT_JETPACK_STATS_MONTHLY ]: translate(
'Upgrade your plan when your website gets more visitors! Our plans adjust to match your site’s growth.'
),
[ PRODUCT_JETPACK_STATS_YEARLY ]: translate(
'Upgrade your plan when your website gets more visitors! Our plans adjust to match your site’s growth.'
),
[ PRODUCT_JETPACK_STATS_BI_YEARLY ]: translate(
'Upgrade your plan when your website gets more visitors! Our plans adjust to match your site’s growth.'
),
};
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import { isJetpackTieredProduct } from '@automattic/calypso-products';
import { SelectDropdown } from '@automattic/components';
import { useTranslate } from 'i18n-calypso';
import { useMemo, useCallback, type FC } from 'react';
import FormFieldset from 'calypso/components/forms/form-fieldset';
import FormLegend from 'calypso/components/forms/form-legend';
import InfoPopover from 'calypso/components/info-popover';
import { preventWidows } from 'calypso/lib/formatting';
import { getProductPartsFromAlias } from 'calypso/my-sites/checkout/src/hooks/use-prepare-products-for-cart';
import { useDispatch } from 'calypso/state';
import { recordTracksEvent } from 'calypso/state/analytics/actions/record';
import slugToSelectorProduct from '../slug-to-selector-product';
import useItemPrice from '../use-item-price';
import { PRODUCT_OPTIONS_HEADER, PRODUCT_TIER_OPTIONS } from './constants';
import {
PRODUCT_OPTIONS_HEADER,
PRODUCT_OPTIONS_HEADER_INFO_CONTENT,
PRODUCT_TIER_OPTIONS,
} from './constants';
import type { SelectorProduct } from '../types';

interface QuantityDropdownProps {
Expand All @@ -20,6 +27,7 @@ interface QuantityDropdownProps {
const QuantityDropdown: FC< QuantityDropdownProps > = ( { product, siteId, onChangeProduct } ) => {
const dispatch = useDispatch();
const listPrices = useItemPrice( siteId, product, product?.monthlyProductSlug || '' );
const translate = useTranslate();

const tierOptions = useMemo( () => {
if ( ! isJetpackTieredProduct( product.productSlug ) ) {
Expand Down Expand Up @@ -65,7 +73,16 @@ const QuantityDropdown: FC< QuantityDropdownProps > = ( { product, siteId, onCha
return (
<div className="product-lightbox__variants-dropdown">
<FormFieldset>
<FormLegend>{ PRODUCT_OPTIONS_HEADER[ product?.productSlug ] }</FormLegend>
<FormLegend>
<span>{ PRODUCT_OPTIONS_HEADER[ product?.productSlug ] }</span>
<InfoPopover
position="right"
screenReaderText={ translate( 'Learn more' ) }
className="product-lightbox__variants-dropdown--popover"
>
{ preventWidows( PRODUCT_OPTIONS_HEADER_INFO_CONTENT[ product?.productSlug ] ) }
</InfoPopover>
</FormLegend>
<SelectDropdown
className="product-lightbox__tiers-dropdown"
options={ tierOptions }
Expand Down
13 changes: 13 additions & 0 deletions client/my-sites/plans/jetpack-plans/product-lightbox/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.product-lightbox__variants-options,
.product-lightbox__variants-dropdown {
.form-legend {
display: flex;
font-weight: 600;
font-size: $font-body;
margin-bottom: 0.5rem;
Expand Down Expand Up @@ -60,6 +61,11 @@
}
}

.info-popover.product-lightbox__variants-dropdown--popover {
height: 24px;
width: 24px;
}

.product-lightbox__variants-content {
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -250,3 +256,10 @@
white-space: nowrap !important;
border: 0 !important;
}

// The lightbox z-index is 100200, consequences of updating the popover z-index
// to higher than that are unclear, so we'll manually set it to 100200 here so we
// can see the popover in the lightbox.
.popover.product-lightbox__variants-dropdown--popover {
z-index: 100200;
}