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 pricing-cards, billing-radio & tabs-ax #60

Merged
merged 6 commits into from
Oct 16, 2024
Merged

add pricing-cards, billing-radio & tabs-ax #60

merged 6 commits into from
Oct 16, 2024

Conversation

jrrings
Copy link
Contributor

@jrrings jrrings commented Sep 25, 2024

Describe your specific features or fixes

Resolves:

Test URLs:

Copy link

aem-code-sync bot commented Sep 25, 2024

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed.
In case there are problems, just click a checkbox below to rerun the respective action.

  • Re-run PSI checks
  • Re-sync branch
Commits

Copy link

aem-code-sync bot commented Sep 25, 2024

Page Scores Audits
📱 /express/pricing PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS
🖥️ /express/pricing PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS

@codecov-commenter
Copy link

codecov-commenter commented Sep 25, 2024

Codecov Report

Attention: Patch coverage is 43.47826% with 26 lines in your changes missing coverage. Please review.

Project coverage is 64.65%. Comparing base (77322f4) to head (ca60e53).

Files with missing lines Patch % Lines
express/scripts/utils/pricing.js 13.33% 26 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #60      +/-   ##
==========================================
+ Coverage   64.52%   64.65%   +0.12%     
==========================================
  Files          41       41              
  Lines        6399     6445      +46     
==========================================
+ Hits         4129     4167      +38     
- Misses       2270     2278       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

/* @TODO REMOVE IMPORTS DIRECTLY FROM MILO STYLE.CSS */

/* Spacing */
--spacing-xxs: 8px;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They added these here instead of their styles.css... so we have some duplicates of what we now already have in styles.css

express/blocks/billing-radio/billing-radio.js Outdated Show resolved Hide resolved
@jrrings jrrings changed the title add pricing-cards & tabs-ax add pricing-cards, billing-radio & tabs-ax Oct 10, 2024
Copy link
Collaborator

@vhargrave vhargrave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as of the second tab I'm seeing issues with content that looks like it should be getting replaced with dynamic content like [[tooltip]] or in the students tab savePercentage%
image
image

express/blocks/billing-radio/billing-radio.css Outdated Show resolved Hide resolved
@@ -20,6 +20,9 @@ function addColorSampler(pill, colorHex, btn) {
}

export default async function decorate(block) {
const headerButton = document.querySelector('.hero-color-wrapper .text-container p:last-child');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need this?

Copy link
Collaborator

@vhargrave vhargrave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another thing I just realized is we should also be porting over the tests as part of a block migration

Copy link
Collaborator

@vhargrave vhargrave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i also found a few more things that have changed to these files over the past few weeks while syncing repos. Just mentioning the changes get added and aren't forgotten in the old repo.

tooltipDiv.append(iconWrapper);
}

async function handlePrice(pricingArea, specialPromo, legacyVersion) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handlePrice(placeholders, pricingArea, specialPromo, groupID, legacyVersion)


priceRow.append(basePrice, price, priceSuffix);

const response = await fetchPlanOnePlans(priceEl?.href);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add this directly under?

if (response.term && groupID) {
    BlockMediator.set(groupID, response.term);
  }

fetchPlanOnePlans,
} from '../../scripts/utils/pricing.js';
import createToggle, { tagFreePlan } from './pricing-toggle.js';

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import BlockMediator from '../../scripts/block-mediator.min.js';

pricingSuffixTextElem?.remove();
}

async function createPricingSection(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

async function createPricingSection(
  pricingArea,
  ctaGroup,
  specialPromo,
  groupID,
  legacyVersion,
)

offer.classList.add('card-offer');
offer.parentElement.outerHTML = offer.outerHTML;
}
await handlePrice(pricingArea, specialPromo, legacyVersion);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await handlePrice(pricingArea, specialPromo, groupID, legacyVersion);

const [{ createTag, getConfig }, placeholderMod] = await Promise.all([import(`${getLibs()}/utils/utils.js`), import(`${getLibs()}/features/placeholders.js`)]);
const PLANS = ['monthly', 'annually'];
const placeholders = await placeholderMod.replaceKeyArray([...PLANS, 'subscription-type'], getConfig());

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new line
const SPECIAL_PLAN = 'annual-billed-monthly';

const PLANS = ['monthly', 'annually'];
const placeholders = await placeholderMod.replaceKeyArray([...PLANS, 'subscription-type'], getConfig());

function toggleOther(pricingSections, buttons, planIndex) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function togglePlan(pricingSections, buttons, planIndex) {

buttons[prevIndex].focus();
}

function onKeyDown(e, pricingSections, buttons, toggleWrapper) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace
function handleKeyNavigation(e, pricingSections, buttons, toggleWrapper) {

case 'Enter':
case 'Space':
e.preventDefault();
toggleOther(pricingSections, buttons, currentIndex);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace
togglePlan(pricingSections, buttons, currentIndex);

});
}

export default function createToggle(pricingSections, groupID, adjElemPos) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace whole method

export default function createToggle(placeholders, pricingSections, groupID, adjElemPos) {
  const subDesc = placeholders?.['subscription-type'] || 'Subscription Type:';
  const toggleWrapper = createTag('div', {
    class: 'billing-toggle',
    role: 'radiogroup',
    'aria-labelledby': groupID,
  });

  const groupLabel = createTag('strong', { id: groupID }, subDesc);
  toggleWrapper.appendChild(groupLabel);

  const buttons = PLANS.map((basePlan, i) => {
    const planLabelID = (BlockMediator.get(groupID) === 'ABM' && placeholders?.[SPECIAL_PLAN] && basePlan === 'monthly')
      ? SPECIAL_PLAN
      : basePlan;
    const label = placeholders?.[planLabelID];
    const buttonID = `${groupID}:${basePlan}`;
    // urgent update
    const isDefault = i === (BlockMediator.get(groupID) === 'ABM' ? 1 : 0);
    const button = createTag('button', {
      class: isDefault ? 'checked' : '',
      id: buttonID,
      plan: basePlan,
      role: 'radio',
      'aria-checked': isDefault.toString(),
      'aria-labelledby': buttonID,
    });

    button.appendChild(createTag('span'));

    button.appendChild(createTag('div', { id: `${buttonID}:radio` }, label));

    button.addEventListener('click', () => {
      togglePlan(pricingSections, buttons, i);
      adjElemPos();
    });

    return button;
  });

  const toggleButtonWrapper = createTag('div', { class: 'toggle-button-wrapper' });
  toggleButtonWrapper.append(...buttons);
  toggleWrapper.append(toggleButtonWrapper);
  toggleWrapper.addEventListener('keydown', (e) => handleKeyNavigation(e, pricingSections, buttons, toggleWrapper));

  return toggleWrapper;
}

@@ -269,6 +269,36 @@ export async function fetchPlanOnePlans(planUrl) {
return plan;
}

const offerIdSuppressMap = new Map();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to replace:

export function shallSuppressOfferEyebrowText(savePer, offerTextContent, isPremiumCard,
  isSpecialEyebrowText, offerId) {
  if (offerId == null || offerId === undefined) return true;
  const key = offerId + isSpecialEyebrowText;
  if (offerIdSuppressMap.has(key)) {
    return offerIdSuppressMap.get(key);
  }
  let suppressOfferEyeBrowText = false;
  if (offerTextContent) {
    suppressOfferEyeBrowText = savePer === '' && offerTextContent.includes('{{savePercentage}}');
  }
  offerIdSuppressMap.set(key, suppressOfferEyeBrowText);
  return suppressOfferEyeBrowText;
}

@jrrings jrrings merged commit 47c9af1 into main Oct 16, 2024
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants