Skip to content

WORLDSERVICE-543: Refactor CTAs #12603

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

Merged
merged 55 commits into from
Apr 23, 2025
Merged

Conversation

Isabella-Mitchell
Copy link
Contributor

@Isabella-Mitchell Isabella-Mitchell commented Apr 4, 2025

Resolves JIRA: https://jira.dev.bbc.co.uk/browse/WORLDSERVICE-543

Summary

Refactors 3 CTA components into 1.

Code changes

  • Adds new CallToActionLink component (to be renamed)
  • Removes CallToActionLink, CallToActionLinkWithChevron, CtaLink (Used in Lite Site CTA)
  • Updates implementation in
    -- Message Banner
    -- Uploader Embed
    -- Korean Download Page
    -- Article Headline (Canonical To Lite Site CTA)
    -- LiteSiteCTA (Banner at top of Lite Site)

Developer Checklist

  • UX
    • UX Criteria met (visual UX & screenreader UX)
  • Accessibility
    • Accessibility Acceptance Criteria met
    • Accessibility swarm completed
    • Component Health updated
    • P1 accessibility bugs resolved
    • P2/P3 accessibility bugs planned (if not resolved)
  • Security
    • Security issues addressed
    • Threat Model updated
  • Documentation
    • Docs updated (runbook, READMEs)
  • Testing
    • Feature tested on relevant environments
  • Comms
    • Relevant parties notified of changes

Testing

  • Manual Testing required?
    • Local (Ready-For-Test, Local)
    • Test (Ready-For-Test, Test)
    • Preview (Ready-For-Test, Preview)
    • Live (Ready-For-Test, Live)
  • Manual Testing complete?
    • Local
    • Test
    • Preview
    • Live

Additional Testing Steps

  1. Check all Chromatic tests pass
  2. Check no regression on updated components by visiting each on storybook or localhost & live/test (paying attention to interaction states and different breakpoints, since these aren't fully tested by Chromatic):
    -- Message Banner - https://www.bbc.com/kyrgyz
    -- Uploader Embed - https://www.test.bbc.com/pidgin/articles/c7k3zrd3536o
    -- Korean Download Page - https://www.bbc.com/korean/downloads
    -- Article Headline (Canonical To Lite Site CTA) - (note due to an experiment the copy may vary) - https://www.bbc.com/gahuza/articles/c8xpj9vnd5wo
    -- LiteSiteCTA (Banner at top of Lite Site) - https://www.bbc.com/gahuza.lite
    Find historic A11y specs on the Jira ticket.

Useful Links

Isabella-Mitchell and others added 30 commits April 4, 2025 09:48
@Isabella-Mitchell Isabella-Mitchell marked this pull request as ready for review April 14, 2025 09:14
<RightChevron css={styles.chevron} />
)}
<CallToActionLink to={linkAddress} css={styles.callToActionLink}>
<CallToActionLink.FlexWrapper>
Copy link
Contributor

Choose a reason for hiding this comment

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

Could the flexwrapper always be included as part of the component, so that we don't have to specifiy it here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not all implementations need Flex. Catharine was keen to only use Flex when it's needed. It's currently used by the Message Banner and the Uploader Embed, (E.g. when the link is used to look a bit like a button, rather than an inline link).

Another option would be to use a Div with flex styles inside the Message Banner and the Uploader Embed. Then we could delete the FlexWrapper. Would this be better?

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps? I am keen to keep this component & its use as simple as possible. But why don't we get a second opinion because I'm not sure (and don't want you to go down the path of refactoring it if it's not recommended). Summoning @HarveyPeachey as our Component Standards expert)

Copy link
Contributor

@HarveyPeachey HarveyPeachey Apr 14, 2025

Choose a reason for hiding this comment

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

I think I prefer this separated flex wrapper. If we did the other option of creating a div with flex, you'll just be duplicating the code. And if we add a prop to render it conditionally we're starting to run into the whole prop drilling problem, even though it's only one level. Maybe we rename it to something like ButtonLikeWrapper, so it's a bit more explicit about what it's doing?

Feel free to get another opinion on this, as I've partly had influence by chatting to Izzy about the amendments to the current compound component standards

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a specific accessibility reason behind not wanting to use flex in this case? I can understand if there was content that reflows differently between screen sizes, but since the chevron is a purely decorative and isn't read out by screenreaders anyways, I would have thought that it wouldn't matter as much.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am happy to leave the flex wrapper as is - for the reasons stated above. Plus, if you're trying to push through some amendments to the compond component standards, then it's OK to influence what we do here, as we want to have a good example of what it should look like - this is the best way to make progress towards the standards we want (evolutionary architecture FTW!)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Based on this thread:

  • I have renamed FlexWrapper to ButtonLikeWrapper and kept this as part of the component

On your point @hotinglok, there is a discussion of Flex on this PR.

As I understand it, the issue is that flex is not needed for this component. Whilst it may not have a negative impact on users - it's better from an A11y stand point to keep styles and html as minimal as possible. You can see the A11y specs here for reference: AACs, Screen reader UX

Furthermore, since the CallToAction link wasn't built to be used without Flex, there was a lot of unnecessary HTML coming through.

Previously

<a href="">
    <div>
        <span>
            <span>Site yoroheje</span>
            <svg><path></path></svg>
        </span>
    </div>
</a>

Now

<a href="">
    <span>Data saving version</span>
    <svg><path></path></svg>
</a>

So it wasn't a requirement to do this for A11y. We saw the opportunity to make the CallToAction Link component more reusable.

css({
display: 'inline-block',
padding: `${pixelsToRem(13)}rem 0 ${pixelsToRem(13)}rem`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
padding: `${pixelsToRem(13)}rem 0 ${pixelsToRem(13)}rem`,
padding: `${pixelsToRem(12)}rem 0 ${pixelsToRem(12)}rem`,

I think this was originally 12px looking at https://www.test.bbc.com/pidgin/articles/c7k3zrd3536o. Was this done intentionally? Just checking!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it's a weird one - I lost a pixel when I removed the outer div. I needed to add 26 pixels total to make the 44 pixel touch target. It was 24 previously

There is an argument to use a nicer round number and make the touch target larger - but I made the call to use 13pixels so I didn't change the current experience.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2025-04-14 at 15 59 41
Screenshot 2025-04-14 at 16 00 05

<RightChevron css={styles.chevron} />
)}
<CallToActionLink to={linkAddress} css={styles.callToActionLink}>
<CallToActionLink.FlexWrapper>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a specific accessibility reason behind not wanting to use flex in this case? I can understand if there was content that reflows differently between screen sizes, but since the chevron is a purely decorative and isn't read out by screenreaders anyways, I would have thought that it wouldn't matter as much.

Comment on lines 51 to 55
<CallToActionLink.Text size="brevier" fontVariant="sansBold">
{toMainSite}
</CallToActionLink.Text>
<CallToActionLink.Chevron size="brevier" />
</CallToActionLink>
Copy link
Collaborator

@hotinglok hotinglok Apr 14, 2025

Choose a reason for hiding this comment

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

Should the bottom of the chevron be aligned with the bottom of the text with this if the link doesn't have an underline? It isn't on live either, but just wondering.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you have a screen grab which shows what you mean?

Copy link
Collaborator

Choose a reason for hiding this comment

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

So, the uploader test page conveniently has one CTA link with an underline, one without (by default without hovering). Ignore my original comment, it doesn't really make sense since I looked again and realised that the underline isn't aligned with the bottom of the chevron at all. There is still an inconsistency between the two though about how far below the underline appears beneath the text.

In this first screenshot below, the underline appears slightly lower than the bottom of the chevron:
image

Here the uploader form itself, the underline appears closer to the text and doesn't appear below or aligned with the bottom of the chevron:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking at the designs*

For components which have a "button like" background (Message Banner and Uploader), the Chevron is aligned in the vertical middle of the "button like" background.

For components that appear inline (LiteSiteCTA). We opted for aligning it with the middle of the text. Here are the designs.

*I can't access the designs for the message banner or uploader component (they're on Zeplin - which is an old UX tool). But this is how it appears to me to have been designed.
Screenshot 2025-04-15 at 09 02 06
image-2023-01-16-10-38-35-239

Copy link
Contributor

Choose a reason for hiding this comment

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

@hotinglok I wonder if the difference is because of the 'g' in 'Data saving version' - the underline has to move down to cater for that letter. In the example of Send form, there are no characters which go below the line

Comment on lines 51 to 55
<CallToActionLink.Text size="brevier" fontVariant="sansBold">
{toMainSite}
</CallToActionLink.Text>
<CallToActionLink.Chevron size="brevier" />
</CallToActionLink>
Copy link
Contributor

Choose a reason for hiding this comment

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

@hotinglok I wonder if the difference is because of the 'g' in 'Data saving version' - the underline has to move down to cater for that letter. In the example of Send form, there are no characters which go below the line

@Isabella-Mitchell Isabella-Mitchell merged commit 233fecc into latest Apr 23, 2025
11 checks passed
@Isabella-Mitchell Isabella-Mitchell deleted the WORLDSERVICE-543-CTA-refactor branch April 23, 2025 09:30
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.

5 participants