-
Notifications
You must be signed in to change notification settings - Fork 7
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 overrides for the Chef card #1589
Conversation
lightBackgroundHex: '#F9F9F5', | ||
darkForegroundHex: '#F0C5B4', | ||
darkBackgroundHex: '#363632', | ||
imageURL: 'https://uploads.guim.co.uk/2024/03/21/Potatos.png', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick #1: Potatoes :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ikr? not my images 😅
lightBackgroundHex: '#F9F9F5', | ||
darkForegroundHex: '#ACD8E5', | ||
darkBackgroundHex: '#363632', | ||
imageURL: 'https://uploads.guim.co.uk/2024/03/21/TVsbacks.png', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick #2: TVsnacks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as above, but we could always rename 'em, it's somewhat irritating
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like it! I made some comments which I hope are helpful, though feel free to disregard as I don't know the frontend code on this project well
0238025
to
53b15b5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven’t yet run this locally, but it looks good to me! I have some questions below, but I’m happy to merge as-is as well :)
|
||
return ( | ||
<ConnectedChefForm | ||
chef={chef} | ||
chefWithoutOverrides={chefWithoutOverrides} | ||
card={card} | ||
initialValues={initialValues} | ||
initialValues={card.meta as ChefCardMeta} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, a comment here explaining why this cast is ok might be helpful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 this should go away with a larger refactor: comment added in 8cb223e.
return undefined; | ||
} | ||
|
||
return formValues[fieldName] as Palette; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this as Palette
needed, given the type for formValues above? I wouldn’t have expected it to be, but I have not checked!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Frustratingly, I think Object.entries
will not give a union type for the object keys, even if they're known type – we just get string
, requiring a cast further downstream.
In reminding myself why Typescript behaves this way, I stumbled across the first answer in this post on stackoverflow, which was very informative, and gave a few examples of a better-typed implementation! I've added that in 10213da. Thanks for the prompt, this is nicer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good! Nice to have some clearer types. I don’t quite see how Object.entries is relevant here though: since the code declares the type of formValues to be {[T: string]: Palette;}
, I’m quite surprised that the compiler can’t tell the type of formValues[fieldName] must be Palette. But also: why is the check if (!formValues)
needed? (Maybe the type given for formValues should include undefined, and this is what’s confusing the compiler?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you can remove as Palette
without getting any complaints from the compiler. But I guess there’s no real need: it doesn’t provide any benefits, especially as I think the type of getFormValues(formName) is any => any
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I read your comment as relating to as PaletteId
! The improvements above are fine, but spot on, this is not needed. Possibly artefact from previous model where keys were a union. 564fab7
darkBackgroundHex: '#363632', | ||
imageURL: 'https://uploads.guim.co.uk/2024/03/21/Celebration.png', | ||
}, | ||
'Celebration\nCakes': { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A newline in a key?? I assume this is outside our control, but it sure is strange.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're stuck for now, but I will point this out to Feast. It's weird.
7ac4285
to
4a2a80b
Compare
Co-authored-by: Jonathon Herbert <jonathon.herbert@guardian.co.uk>
…on drop (#1591) * use hard coded constant so all trails are required to be portrait * allow grid to select either image type, add state for the dimension of the selected replacement image, use to style the ImageContainer * bug fix? aspect ratio test should use absolute difference * use the criteria to set the gird url, not a separate prop * export the default trail image criteria from constants * remove unused imports * shorted var name, comments about use of constant criteria * add selectCollectionType selector * provide the collection type to the InputImage * add feature switch for whether to allow portrait crops * if the feature switch is enabled, set criteria based on collection type * dont change the FeatureSwitch class - just hide the new one client-side * provide criteria to slideshow * dont need state for imageDims - can get from props.input.value * remove collection type from render * use horrendous css funcions to style the image containers for small portraits in slideshows * wrangle the css for ImageContainer * move the image container to own file * validate image error distinguishes between 'no crops' and 'no matching crops' * dont use the default criteria * move constants to constants/image * Card components check the collection type to set criteria for image drops * add TO DO about dragging images from card to card * cards check replacement image dimensions and style thumbnails to display portraits right * validate dimensions of incoming dragged images from other cards * undo switch change * more coherent comments * update tests to account for more specific error messaging * message correctly when crops fail validation of a criteria without aspect ratio * refactor validation to reduce duplication of dimension criteria checks * add a crop icon next to the Collection title if it uses 5:4 crops * remove import * don't show the crop icon with feature switch off * remove test value from COLLECTIONS_USING_PORTRAIT_TRAILS * define type for empty string array
3e5fd60
to
1cf0783
Compare
Seen on PROD (merged by @jonathonherbert 9 minutes and 32 seconds ago) Please check your changes! |
What's changed?
Adds the missing overrides for the Chef card – image and palette overrides. The palette data is copied from mis-en-place, the tool that Fronts will eventually replace, here.
Implementation notes
cardType
values have different types of metadata. I've left that for now, as this PR was already large, but it'd be good to do this in another PR on both client and server.Checklist
General
Client