Skip to content

Conversation

@Marianaguardian
Copy link

What does this change?

Investigate hiding the sign up component

Why?

There is an ambition to hide the sign up component that appears in articles when a user has already signed up to the newsletter in question. This would be a nice "quality of life" update that should make the sign up embeds less intrusive.

Ticket link: #14889

Subtask ticket link : #14890

Screenshots

Before After
before after

@Marianaguardian Marianaguardian linked an issue Nov 26, 2025 that may be closed by this pull request
7 tasks
@github-actions
Copy link

Hello 👋! When you're ready to run Chromatic, please apply the run_chromatic label to this PR.

You will need to reapply the label each time you want to run Chromatic.

Click here to see the Chromatic project.

@github-actions
Copy link

github-actions bot commented Nov 26, 2025

@github-actions
Copy link

github-actions bot commented Nov 26, 2025

}: EmailSignUpWrapperProps) => {
const [idApiUrl] = useState(() => {
if (typeof window === 'undefined') return '';
return window.guardian?.config?.page?.idApiUrl ?? '';

Choose a reason for hiding this comment

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

Might it be better to return undefined rather than an empty string here and then make the type string | undefined?

@Marianaguardian Marianaguardian requested a review from a team as a code owner November 28, 2025 14:43
Copy link

@georgerichmond georgerichmond left a comment

Choose a reason for hiding this comment

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

Looks good - just wondering about how we best test this - perhaps using the hook in the story is useful rather than repeating the content?

/**
* A hook to check if a user is subscribed to a specific newsletter.
*/
export const useNewsletterSubscription = (

Choose a reason for hiding this comment

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

Is it worth having a test for this?

Copy link

@georgerichmond georgerichmond Dec 1, 2025

Choose a reason for hiding this comment

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

It could be tested as part of testing the component by mocking the fetch call possibly

hidePrivacyMessage?: boolean;
}

const AlreadySubscribedWrapper = (props: EmailSignUpWrapperProps) => {

Choose a reason for hiding this comment

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

Could we use the hook in the react story and just mock out what the service call returns?

Choose a reason for hiding this comment

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

Either by mocking fetch or if there is a standard way it's mocked out in the codebase so that we can see the hook being used in the story.

Otherwise it's just repeating logic from the hook for the point of the story - may as well just show the component as it looks with and without a subscription

@georgerichmond
Copy link

I couldn't see the story in storybook for some reason

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

show or hide the sign-up newsletter component

3 participants