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 header image form to designable banner page #536

Merged
merged 2 commits into from
Dec 8, 2023

Conversation

KaliedaRik
Copy link
Contributor

What does this change?

Extends the designable banner page to allow users to self-serve a header image

How to test

  • In the CODE designable banner page, live view a design which makes use of this new component
  • In the CODE banner channels, create and preview banner tests which uses the design: one with header copy, another without header copy

@@ -27,6 +27,13 @@ object GuardianRoundelDesign {
implicit val decoder = deriveEnumerationDecoder[GuardianRoundelDesign]
}

case class HeaderImage(
Copy link
Member

Choose a reason for hiding this comment

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

did you consider reusing BannerDesignVisual.Image?

Copy link
Member

Choose a reason for hiding this comment

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

I think I may have dissuaded Rik from that because that type has a kind which isn't used/needed here. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Ok fair enough

Comment on lines +7 to +10
const imageUrlValidation = {
value: /^https:\/\/i\.guim\.co\.uk\//,
message: 'Images must be valid URLs hosted on https://i.guim.co.uk/',
};
Copy link
Member

Choose a reason for hiding this comment

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

Not a big deal, but perhaps this common validation could be shared with the other image fields?

useEffect(() => {
const isValid = Object.keys(errors).length === 0;
onValidationChange('headerImage', isValid);
console.log(errors);
Copy link
Member

Choose a reason for hiding this comment

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

Should this console.log be removed?

@@ -54,6 +54,7 @@ export type BannerDesignVisual = BannerDesignImage | ChoiceCardsDesign;

export type BannerDesignProps = {
visual?: BannerDesignVisual;
headerImage?: BannerDesignImage;
Copy link
Member

Choose a reason for hiding this comment

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

I think this TS type has a kind field, but the Scala case class doesn't. I wonder if that's confusing or going to cause subtle issues anywhere? What do you reckon, should they match?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed (hopefully)

@@ -161,7 +170,7 @@ const BannerDesignForm: React.FC<Props> = ({

<Accordion className={classes.accordion}>
<AccordionSummary className={classes.sectionHeader} expandIcon={<ExpandMoreIcon />}>
Image or Choice Cards
Main Image or Choice Cards
Copy link
Member

Choose a reason for hiding this comment

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

❤️

@@ -38,14 +38,17 @@ export interface TickerDesign {
goalMarker: HexColour;
}

export interface BannerDesignImage {
kind: 'Image';
export interface BannerDesignHeaderImage {
Copy link
Member

Choose a reason for hiding this comment

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

it's only names and not important, but perhaps it makes more sense to call this just BannerDesignImage and the one that extends it MainBannerDesignImage

Copy link
Member

@tomrf1 tomrf1 left a comment

Choose a reason for hiding this comment

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

great!

@KaliedaRik KaliedaRik merged commit b0b1f88 into main Dec 8, 2023
1 check passed
@KaliedaRik KaliedaRik deleted the rjr-designable-banner-header-image branch December 8, 2023 11:21
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.

3 participants