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 overrides for the Chef card #1589

Merged
merged 23 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7eb4c92
Add chef image field
jonathonherbert Jun 3, 2024
4537b2e
Move modals to own folder
jonathonherbert Jun 3, 2024
3fdf066
Add modal for palette options
jonathonherbert Jun 3, 2024
adcdecd
Add additional properties to card meta
jonathonherbert Jun 3, 2024
104b18e
Move palette components to own file for reuse
jonathonherbert Jun 3, 2024
07ae0ef
Transform image overrides on way in and out to ensure correct meta
jonathonherbert Jun 3, 2024
ea38d70
Add custom palette picker
jonathonherbert Jun 3, 2024
329afb2
Use 'done' rather than 'cancel' for palette changes
jonathonherbert Jun 3, 2024
6625634
Lint
jonathonherbert Jun 3, 2024
833978b
Wording for image field
jonathonherbert Jun 3, 2024
fe40766
Fix test cases
jonathonherbert Jun 3, 2024
8be01d7
Do not spread image overrides into existing fields, using chefImageOv…
jonathonherbert Jun 6, 2024
8674eed
Favour individual imports of lodash noop
jonathonherbert Jun 6, 2024
19c1716
Lint
jonathonherbert Jun 6, 2024
de003e3
Separate type for palette
jonathonherbert Jun 6, 2024
dfd9e61
Remove errant reference to ChefCardFormData
jonathonherbert Jun 6, 2024
8b5e23a
Nest palette fields
jonathonherbert Jun 6, 2024
e2d0563
Explain cast in ChefMetaForm
jonathonherbert Jun 13, 2024
c9a3cb2
Add better-typed entries fn for palette form
jonathonherbert Jun 13, 2024
2d915af
linting fix
Divs-B Jun 12, 2024
26732b1
set criteria by collection type, style portrait thumbnails, validate …
dblatcher Jun 17, 2024
1cf0783
Patch after rebase
jonathonherbert Jun 19, 2024
564fab7
Remove unnecessary cast
jonathonherbert Jun 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion app/model/editions/EditionsCard.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ object CoverCardImages {
implicit val format: OFormat[CoverCardImages] = Json.format[CoverCardImages]
}


case class Palette(paletteId: String, foregroundHex: String, backgroundHex: String)

object Palette {
implicit val format: OFormat[Palette] = Json.format[Palette]
}

case class CardMetadata(
headline: Option[String],
customKicker: Option[String],
Expand All @@ -43,7 +50,9 @@ case class CardMetadata(
overrideArticleMainMedia: Option[Boolean],
coverCardImages: Option[CoverCardImages],
promotionMetric: Option[Double],
bio: Option[String] = None
bio: Option[String] = None, // Chef,
palette: Option[Palette] = None, // Chef
chefImageOverride: Option[Image] = None, // Chef
)

object CardMetadata {
Expand Down
13 changes: 10 additions & 3 deletions app/model/editions/client/ClientCardMetadata.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package model.editions.client
import ai.x.play.json.Jsonx
import model.editions.{CardMetadata, CoverCardImages, Image, MediaType}
import play.api.libs.json.OFormat
import model.editions.Palette

// This is a subset of the shared model here - https://github.com/guardian/facia-scala-client/blob/master/facia-json/src/main/scala/com/gu/facia/client/models/Collection.scala#L18
// Why not reuse that model? We only want to surface the fields necessary for editions
Expand Down Expand Up @@ -37,7 +38,9 @@ case class ClientCardMetadata(
coverCardMobileImage: Option[Image],
coverCardTabletImage: Option[Image],
promotionMetric: Option[Double],
bio: Option[String]
bio: Option[String], // Chef
palette: Option[Palette], // Chef
chefImageOverride: Option[Image] // Chef
) {
def toCardMetadata: CardMetadata = {
val cutoutImage: Option[Image] = (imageCutoutSrcHeight, imageCutoutSrcWidth, imageCutoutSrc, imageCutoutSrcOrigin) match {
Expand Down Expand Up @@ -79,7 +82,9 @@ case class ClientCardMetadata(
overrideArticleMainMedia,
coverCardImages,
promotionMetric,
bio
bio,
palette,
chefImageOverride
)
}
}
Expand Down Expand Up @@ -121,7 +126,9 @@ object ClientCardMetadata {
cardMetadata.coverCardImages.flatMap(_.mobile),
cardMetadata.coverCardImages.flatMap(_.tablet),
cardMetadata.promotionMetric,
cardMetadata.bio
cardMetadata.bio,
cardMetadata.palette,
cardMetadata.chefImageOverride
)
}
}
5 changes: 3 additions & 2 deletions fronts-client/src/actions/OptionsModal.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import type { StartOptionsModal } from 'types/Action';
import type { OptionsModalChoices } from 'types/Modals';
import { ReactNode } from 'react';
import noop from 'lodash/noop';

const startOptionsModal = (
title: string,
description: string | ReactNode,
options: OptionsModalChoices[],
onCancel: () => void,
options: OptionsModalChoices[] = [],
onCancel: () => void = noop,
showCancelButton: boolean = true
): StartOptionsModal => ({
type: 'MODAL/START_OPTIONS_MODAL',
Expand Down
2 changes: 1 addition & 1 deletion fronts-client/src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
import ManageView from './Editions/ManageView';
import FeaturesView from './Features/FeaturesView';
import { PlaceholderAnimation } from 'components/BasePlaceholder';
import OptionsModal from './OptionsModal';
import OptionsModal from './modals/OptionsModal';
import BannerNotification from './notifications/BannerNotification';

// tslint:disable:no-unused-expression
Expand Down
115 changes: 0 additions & 115 deletions fronts-client/src/components/OptionsModal.tsx

This file was deleted.

4 changes: 3 additions & 1 deletion fronts-client/src/components/card/chef/ChefCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ export const ChefCard = ({
</CardHeadingContainer>
</CardContent>
<ImageAndGraphWrapper size={size}>
<ThumbnailSmall url={chef?.bylineLargeImageUrl} />
<ThumbnailSmall
url={chef?.chefImageOverride?.src ?? chef?.bylineLargeImageUrl}
/>
</ImageAndGraphWrapper>
<HoverActionsAreaOverlay data-testid="hover-overlay">
<HoverActionsButtonWrapper
Expand Down
40 changes: 7 additions & 33 deletions fronts-client/src/components/form/ArticleMetaForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from 'selectors/shared';
import { createSelectFormFieldsForCard } from 'selectors/formSelectors';
import { defaultObject } from 'util/selectorUtils';
import { CardMeta, ArticleTag, CardSizes } from 'types/Collection';
import { CardMeta, ArticleTag, CardSizes, ImageData } from 'types/Collection';
import InputText from 'components/inputs/InputText';
import InputTextArea from 'components/inputs/InputTextArea';
import InputCheckboxToggleInline from 'components/inputs/InputCheckboxToggleInline';
Expand All @@ -32,7 +32,6 @@ import ConditionalField from 'components/inputs/ConditionalField';
import ConditionalComponent from 'components/layout/ConditionalComponent';
import {
CardFormData,
ImageData,
getCardMetaFromFormValues,
getInitialValuesForCardForm,
getCapiValuesForArticleFields,
Expand Down Expand Up @@ -68,7 +67,10 @@ import { TextOptionsInputGroup } from 'components/form/TextOptionsInputGroup';
import { FormButtonContainer } from 'components/form/FormButtonContainer';
import { selectCollectionType } from 'selectors/frontsSelectors';
import { Criteria } from 'types/Grid';

import { ImageOptionsInputGroup } from './ImageOptionsInputGroup';
import { RowContainer } from './RowContainer';
import { ImageRowContainer } from './ImageRowContainer';
import { ImageCol } from './ImageCol';

interface ComponentProps extends ContainerProps {
articleExists: boolean;
Expand Down Expand Up @@ -100,21 +102,6 @@ type RenderSlideshowProps = WrappedFieldArrayProps<ImageData> & {
criteria: Criteria;
};

const RowContainer = styled.div`
overflow: hidden;
`;

const ImageOptionsContainer = styled.div`
display: flex;
height: fit-content;
flex-wrap: wrap;
flex: 1;
flex-direction: column;
min-width: 300px;
margin-top: ${(props: { size?: string }) =>
props.size !== 'wide' ? 0 : '6px'};
`;

const SlideshowRowContainer = styled(RowContainer)`
flex: 1 1 auto;
overflow: visible;
Expand All @@ -123,12 +110,6 @@ const SlideshowRowContainer = styled(RowContainer)`
props.size !== 'wide' ? 0 : '10px'};
`;

const ImageRowContainer = styled(RowContainer)`
flex: 1 1 auto;
margin-left: ${(props: { size?: string }) =>
props.size !== 'wide' ? 0 : '10px'};
`;

const slideshowGutter = 5;
const slidesPerRow = 5;

Expand All @@ -154,13 +135,6 @@ const SlideshowLabel = styled.div`
margin-bottom: 12px;
`;

const ImageCol = styled(Col)`
flex: initial;
flex-shrink: 0;
transition: opacity 0.15s;
opacity: ${(props: { faded: boolean }) => (props.faded ? 0.6 : 1)};
`;

const CollectionEditedError = styled.div`
background-color: yellow;
margin-bottom: 1em;
Expand Down Expand Up @@ -671,7 +645,7 @@ class FormComponent extends React.Component<Props, FormComponentState> {
originalValue={''}
/>
</TextOptionsInputGroup>
<ImageOptionsContainer size={this.props.size}>
<ImageOptionsInputGroup size={this.props.size}>
<ImageRowContainer size={this.props.size}>
<Row>
<ImageCol faded={imageHide || !!coverCardImageReplace}>
Expand Down Expand Up @@ -806,7 +780,7 @@ class FormComponent extends React.Component<Props, FormComponentState> {
/>
</SlideshowRowContainer>
)}
</ImageOptionsContainer>
</ImageOptionsInputGroup>
{isEditionsMode && coverCardImageReplace && (
<RowContainer>
<Row>
Expand Down
Loading
Loading