From d000cb3805139f87fe8bcffa699731c1b67bd009 Mon Sep 17 00:00:00 2001 From: DBlatcher Date: Fri, 25 Sep 2026 16:35:06 +0100 Subject: [PATCH 1/8] add grid picker component --- bun.lock | 4 +- src/apps/frontend/package.json | 2 +- .../compose/AppAlertReplaceImageSection.tsx | 6 + .../frontend/src/compose/GridImagePicker.tsx | 126 ++++++++++++++++++ src/apps/frontend/src/grid-client/grid-api.ts | 4 +- 5 files changed, 137 insertions(+), 5 deletions(-) create mode 100644 src/apps/frontend/src/compose/GridImagePicker.tsx diff --git a/bun.lock b/bun.lock index 9e055a85..253107bc 100644 --- a/bun.lock +++ b/bun.lock @@ -61,7 +61,7 @@ "version": "0.1.0", "dependencies": { "@emotion/react": "11.14.0", - "@guardian/stand": "0.0.74", + "@guardian/stand": "0.0.0-canary-20260925104835", "@hookform/resolvers": "5.9.1", "@models": "workspace:*", "@tanstack/react-query": "5.102.8", @@ -364,7 +364,7 @@ "@guardian/prettier": ["@guardian/prettier@11.0.0", "", { "peerDependencies": { "prettier": "^3.7.4", "tslib": "^2.8.1" } }, "sha512-zq3icTMZtkbt7dWSMotYDMSpoXsrf105/EoKC1cNecrFqqY45+R3TBRwGudyA+31eAhR7L6GAyB1qD3074lHYQ=="], - "@guardian/stand": ["@guardian/stand@0.0.74", "", { "peerDependencies": { "@emotion/react": ">=11.11.4 <=11.14.0", "@guardian/prosemirror-invisibles": "^3.1.1", "@internationalized/date": "^3.12.1", "prosemirror-dropcursor": "^1.8.2", "prosemirror-history": "^1.4.1", "prosemirror-keymap": "^1.2.2", "prosemirror-model": "^1.25.0", "prosemirror-state": "^1.4.3", "prosemirror-view": "^1.37.2", "react": "^17.0.2 || ^18.0.0 || ^19.0.0", "react-aria-components": ">= 1.14.0 <= 1.20.0", "react-dom": "^17.0.2 || ^18.0.0 || ^19.0.0", "typescript": ">=5.0.0 <7.0.0" }, "optionalPeers": ["@emotion/react", "@guardian/prosemirror-invisibles", "@internationalized/date", "prosemirror-dropcursor", "prosemirror-history", "prosemirror-keymap", "prosemirror-model", "prosemirror-state", "prosemirror-view", "react", "react-aria-components", "react-dom", "typescript"] }, "sha512-BpmL9JjCdkEZUVmNDFgg36KkVKOCoT+DIPQ6+ympHy0A7xMDIsEloyXN6uF7F6BijZans7Uko7CgCu9+c2FIdQ=="], + "@guardian/stand": ["@guardian/stand@0.0.0-canary-20260925104835", "", { "peerDependencies": { "@emotion/react": ">=11.11.4 <=11.14.0", "@guardian/prosemirror-invisibles": "^3.1.1", "@internationalized/date": "^3.12.1", "prosemirror-dropcursor": "^1.8.2", "prosemirror-history": "^1.4.1", "prosemirror-keymap": "^1.2.2", "prosemirror-model": "^1.25.0", "prosemirror-state": "^1.4.3", "prosemirror-view": "^1.37.2", "react": "^17.0.2 || ^18.0.0 || ^19.0.0", "react-aria-components": ">= 1.14.0 <= 1.20.0", "react-dom": "^17.0.2 || ^18.0.0 || ^19.0.0", "typescript": ">=5.0.0 <7.0.0" }, "optionalPeers": ["@emotion/react", "@guardian/prosemirror-invisibles", "@internationalized/date", "prosemirror-dropcursor", "prosemirror-history", "prosemirror-keymap", "prosemirror-model", "prosemirror-state", "prosemirror-view", "react", "react-aria-components", "react-dom", "typescript"] }, "sha512-HHbDbuwJ6oYP9pdADsu5UNMhiGxtLn1w/9K5ApLGo81HHhgdoZkhn7ohIDqZ1FzqqJHIYHk1i7+3RpbU8AjqSg=="], "@guardian/tsconfig": ["@guardian/tsconfig@2.0.0", "", {}, "sha512-alvlrRwOF42tCcxkT4zL+0wauoywMK9FzRgZgx8BV/4ggVEUARTTeCc+HXIbG8Gj9EZkFWFVWJJrFLwqJAkgBw=="], diff --git a/src/apps/frontend/package.json b/src/apps/frontend/package.json index 5c93eaa7..ed10c0ea 100644 --- a/src/apps/frontend/package.json +++ b/src/apps/frontend/package.json @@ -16,7 +16,7 @@ }, "dependencies": { "@emotion/react": "11.14.0", - "@guardian/stand": "0.0.74", + "@guardian/stand": "0.0.0-canary-20260925104835", "@hookform/resolvers": "5.9.1", "@models": "workspace:*", "@tanstack/react-query": "5.102.8", diff --git a/src/apps/frontend/src/compose/AppAlertReplaceImageSection.tsx b/src/apps/frontend/src/compose/AppAlertReplaceImageSection.tsx index 6630274f..290f6c32 100644 --- a/src/apps/frontend/src/compose/AppAlertReplaceImageSection.tsx +++ b/src/apps/frontend/src/compose/AppAlertReplaceImageSection.tsx @@ -9,6 +9,7 @@ import { Typography } from '@guardian/stand/Typography'; import { useContext } from 'react'; import { ConfigContext } from '../config/ConfigContext'; import { useImageUrlCheck } from '../hooks/use-image-url-check'; +import { GridImagePicker } from './GridImagePicker'; interface AppAlertReplaceImageSectionProps { replacementImageUrl: string; @@ -111,6 +112,11 @@ export const AppAlertReplaceImageSection = ({ {imageUpdated && replacementImageUrl && ( Image updated )} + + ); }; diff --git a/src/apps/frontend/src/compose/GridImagePicker.tsx b/src/apps/frontend/src/compose/GridImagePicker.tsx new file mode 100644 index 00000000..81fa14f6 --- /dev/null +++ b/src/apps/frontend/src/compose/GridImagePicker.tsx @@ -0,0 +1,126 @@ +import { semanticSpacing } from '@guardian/stand'; +import { Button } from '@guardian/stand/Button'; +import { InlineMessage } from '@guardian/stand/InlineMessage'; +import { PickerIframeModal } from '@guardian/stand/PickerIframeModal'; +import type { CropData, ImageData } from '@models'; +import { gridImageResponse } from '@models'; +import { useContext, useState } from 'react'; +import { ConfigContext } from '../config/ConfigContext'; +import { extractAsset, isFiveFourCrop } from '../grid-client/grid-api'; + +type ImageAndCrop = { + crop: CropData; + image: ImageData; +}; + +interface Props { + onUpdate: (replacementImageUrl: string) => void; + setTextInput?: (replacementImageUrl: string) => void; +} + +const validateGridData = (messageData: unknown): { data?: ImageAndCrop } => { + const responseParse = gridImageResponse.safeParse(messageData); + if (responseParse.success) { + const cropData = responseParse.data.crop?.data; + const imageData = responseParse.data.image?.data; + if (cropData && imageData) { + const payload: ImageAndCrop = { + crop: cropData, + image: imageData, + }; + return { data: payload }; + } + } + return {}; +}; + +export const GridImagePicker = ({ onUpdate, setTextInput }: Props) => { + const [gridPageOpen, seGridPageOpen] = useState<'search' | 'image'>(); + const [lastImageId, setLastImageId] = useState(); + const [failureFeedback, setFailureFeedBack] = useState(); + const { gridUri } = useContext(ConfigContext) ?? {}; + + const handleImageAndCrop = ({ crop, image }: ImageAndCrop) => { + setLastImageId(image.id); + const isRightAspect = isFiveFourCrop(crop); + const assetResult = extractAsset(crop); + const file = assetResult.success && assetResult.data.file; + + if (!isRightAspect) { + setFailureFeedBack('Please select a 5:4 crop'); + } + if (!file) { + setFailureFeedBack('Could not identify file to use'); + } + + if (file && isRightAspect) { + setTextInput?.(`${gridUri}/images/${image.id}?crop=${crop.id}`); + onUpdate(file); + } + }; + + const gridPageUri = gridPageOpen + ? lastImageId && gridPageOpen === 'image' + ? `${gridUri}/images/${lastImageId}?cropType=all&defaultCropType=landscape` + : `${gridUri}/search?cropType=all&defaultCropType=landscape` + : undefined; + + return ( +
+ + + {lastImageId && ( + + )} + + {failureFeedback && ( + {failureFeedback} + )} + seGridPageOpen(undefined)} + title={'Pick an image'} + validate={validateGridData} + handleData={handleImageAndCrop} + /> +
+ ); +}; diff --git a/src/apps/frontend/src/grid-client/grid-api.ts b/src/apps/frontend/src/grid-client/grid-api.ts index 9ece8209..e14f5a26 100644 --- a/src/apps/frontend/src/grid-client/grid-api.ts +++ b/src/apps/frontend/src/grid-client/grid-api.ts @@ -78,7 +78,7 @@ const findCrop = (imageData: ImageData, cropId: string): Result => { }; }; -const extractAsset = (crop: CropData): Result => { +export const extractAsset = (crop: CropData): Result => { const assetsSmallestFirst = crop.assets?.sort( (assetA, assetB) => (assetA.dimensions?.width ?? 0) - (assetB.dimensions?.width ?? 0), @@ -100,7 +100,7 @@ const extractAsset = (crop: CropData): Result => { }; }; -const isFiveFourCrop = (crop: CropData): boolean | undefined => { +export const isFiveFourCrop = (crop: CropData): boolean | undefined => { const { specification, master } = crop; if (specification?.aspectRatio) { return specification.aspectRatio === '5:4'; From 66f06baee320e216ac0e179f50f246f07e584ba5 Mon Sep 17 00:00:00 2001 From: DBlatcher Date: Fri, 25 Sep 2026 16:51:07 +0100 Subject: [PATCH 2/8] update alert banner theme format --- src/apps/frontend/src/compose/ReviewWarning.tsx | 4 +++- src/apps/frontend/src/themes.ts | 8 +++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/apps/frontend/src/compose/ReviewWarning.tsx b/src/apps/frontend/src/compose/ReviewWarning.tsx index 1f5ae327..50d71309 100644 --- a/src/apps/frontend/src/compose/ReviewWarning.tsx +++ b/src/apps/frontend/src/compose/ReviewWarning.tsx @@ -25,9 +25,11 @@ export const ReviewWarning = () => { shared: { content: { alignItems: 'flex-start', - icon: { color: semanticColors.text.blue }, }, }, + information: { + icon: { color: semanticColors.text.blue }, + }, }} >
= { - shared: { - content: { - icon: { - color: semanticColors.text.blue, - }, + information: { + icon: { + color: semanticColors.text.blue, }, }, }; From d923198175aa28b019f2bd8242f3e249cf15e00d Mon Sep 17 00:00:00 2001 From: DBlatcher Date: Fri, 2 Oct 2026 15:19:45 +0100 Subject: [PATCH 3/8] button icons --- .../frontend/src/compose/GridImagePicker.tsx | 6 ++++- src/apps/frontend/src/ui/GridIcon.tsx | 23 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/apps/frontend/src/ui/GridIcon.tsx diff --git a/src/apps/frontend/src/compose/GridImagePicker.tsx b/src/apps/frontend/src/compose/GridImagePicker.tsx index 81fa14f6..29a3dfce 100644 --- a/src/apps/frontend/src/compose/GridImagePicker.tsx +++ b/src/apps/frontend/src/compose/GridImagePicker.tsx @@ -7,6 +7,7 @@ import { gridImageResponse } from '@models'; import { useContext, useState } from 'react'; import { ConfigContext } from '../config/ConfigContext'; import { extractAsset, isFiveFourCrop } from '../grid-client/grid-api'; +import { GridIcon } from '../ui/GridIcon'; type ImageAndCrop = { crop: CropData; @@ -74,6 +75,7 @@ export const GridImagePicker = ({ onUpdate, setTextInput }: Props) => { }} > )} @@ -99,6 +102,7 @@ export const GridImagePicker = ({ onUpdate, setTextInput }: Props) => { {failureFeedback} )} ( + + + +); From 89287c659a992f965c64e3b5df0a36bc9f98f1aa Mon Sep 17 00:00:00 2001 From: DBlatcher Date: Fri, 2 Oct 2026 15:36:05 +0100 Subject: [PATCH 4/8] hide or show the replace image section instead of conditionally rendering --- .../compose/AppAlertReplaceImageSection.tsx | 12 ++++- .../ArticleThumbnailImageFormField.tsx | 44 +++++++++---------- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/apps/frontend/src/compose/AppAlertReplaceImageSection.tsx b/src/apps/frontend/src/compose/AppAlertReplaceImageSection.tsx index 0d315e1c..84178699 100644 --- a/src/apps/frontend/src/compose/AppAlertReplaceImageSection.tsx +++ b/src/apps/frontend/src/compose/AppAlertReplaceImageSection.tsx @@ -17,6 +17,7 @@ interface AppAlertReplaceImageSectionProps { onReplacementImageUrlChange: (replacementImageUrl: string) => void; onUpdate: (replacementImageUrl: string) => void; errorMessage?: string; + show: boolean; } export const AppAlertReplaceImageSection = ({ @@ -24,6 +25,7 @@ export const AppAlertReplaceImageSection = ({ onReplacementImageUrlChange, onUpdate, errorMessage, + show, }: AppAlertReplaceImageSectionProps) => { const { gridApiUri, gridUri } = useContext(ConfigContext) ?? {}; @@ -45,7 +47,13 @@ export const AppAlertReplaceImageSection = ({ }); return ( - <> +
- +
); }; diff --git a/src/apps/frontend/src/compose/ArticleThumbnailImageFormField.tsx b/src/apps/frontend/src/compose/ArticleThumbnailImageFormField.tsx index 4d22c8fb..868a6d44 100644 --- a/src/apps/frontend/src/compose/ArticleThumbnailImageFormField.tsx +++ b/src/apps/frontend/src/compose/ArticleThumbnailImageFormField.tsx @@ -117,30 +117,28 @@ export const ArticleThumbnailImageFormField = ({ />
- {openReplaceSection && ( - { - replacementImageUrlField.onChange(replacementImageUrl); - clearErrors('articleThumbnailUrl'); - }} - errorMessage={errors.articleThumbnailUrl?.message} - onUpdate={(replacementImageUrl) => { - const nextThumbnailUrl = - replacementImageUrl.trim() || - originalArticleThumbnailUrl; + { + replacementImageUrlField.onChange(replacementImageUrl); + clearErrors('articleThumbnailUrl'); + }} + errorMessage={errors.articleThumbnailUrl?.message} + onUpdate={(replacementImageUrl) => { + const nextThumbnailUrl = + replacementImageUrl.trim() || originalArticleThumbnailUrl; - setValue('articleThumbnailUrl', nextThumbnailUrl, { - shouldDirty: true, - shouldValidate: true, - }); - setValue('includeThumbnail', Boolean(nextThumbnailUrl), { - shouldDirty: true, - shouldValidate: true, - }); - }} - /> - )} + setValue('articleThumbnailUrl', nextThumbnailUrl, { + shouldDirty: true, + shouldValidate: true, + }); + setValue('includeThumbnail', Boolean(nextThumbnailUrl), { + shouldDirty: true, + shouldValidate: true, + }); + }} + /> )} From 1a3e73d3066545289224756f7502cc3cdca793be Mon Sep 17 00:00:00 2001 From: DBlatcher Date: Fri, 30 Oct 2026 12:24:46 +0000 Subject: [PATCH 5/8] use new stand grid image picker --- bun.lock | 6 +- src/apps/frontend/package.json | 2 +- .../compose/AppAlertReplaceImageSection.tsx | 4 +- .../frontend/src/compose/GridImagePicker.tsx | 127 +++--------------- 4 files changed, 26 insertions(+), 113 deletions(-) diff --git a/bun.lock b/bun.lock index 06efc37d..4ae12f36 100644 --- a/bun.lock +++ b/bun.lock @@ -61,7 +61,7 @@ "version": "0.1.0", "dependencies": { "@emotion/react": "11.14.0", - "@guardian/stand": "1.0.0", + "@guardian/stand": "0.0.0-canary-20261030120059", "@hookform/resolvers": "5.9.1", "@tanstack/react-query": "5.103.2", "models": "workspace:*", @@ -360,7 +360,7 @@ "@guardian/prettier": ["@guardian/prettier@11.0.0", "", { "peerDependencies": { "prettier": "^3.7.4", "tslib": "^2.8.1" } }, "sha512-zq3icTMZtkbt7dWSMotYDMSpoXsrf105/EoKC1cNecrFqqY45+R3TBRwGudyA+31eAhR7L6GAyB1qD3074lHYQ=="], - "@guardian/stand": ["@guardian/stand@1.0.0", "", { "peerDependencies": { "@emotion/react": ">=11.11.4 <=11.14.0", "@guardian/prosemirror-invisibles": "^3.1.1", "@internationalized/date": "^3.12.1", "prosemirror-dropcursor": "^1.8.2", "prosemirror-history": "^1.4.1", "prosemirror-keymap": "^1.2.2", "prosemirror-model": "^1.25.0", "prosemirror-state": "^1.4.3", "prosemirror-view": "^1.37.2", "react": "^17.0.2 || ^18.0.0 || ^19.0.0", "react-aria-components": ">= 1.14.0 <= 1.21.1", "react-dom": "^17.0.2 || ^18.0.0 || ^19.0.0", "typescript": ">=5.0.0 <7.0.0" }, "optionalPeers": ["@emotion/react", "@guardian/prosemirror-invisibles", "@internationalized/date", "prosemirror-dropcursor", "prosemirror-history", "prosemirror-keymap", "prosemirror-model", "prosemirror-state", "prosemirror-view", "react", "react-aria-components", "react-dom", "typescript"] }, "sha512-KwNHoe6lp6UaRum8esQT8JMrBdal+WrIQJd/r6fJP+HNGvJbSSbSN/M1QN2WDCckGC4M0/21vmDGKqKQ6s2lPg=="], + "@guardian/stand": ["@guardian/stand@0.0.0-canary-20261030120059", "", { "dependencies": { "zod": "^4.6.5" }, "peerDependencies": { "@emotion/react": ">=11.11.4 <=11.14.0", "@guardian/prosemirror-invisibles": "^3.1.1", "@internationalized/date": "^3.12.1", "prosemirror-dropcursor": "^1.8.2", "prosemirror-history": "^1.4.1", "prosemirror-keymap": "^1.2.2", "prosemirror-model": "^1.25.12", "prosemirror-state": "^1.4.3", "prosemirror-view": "^1.42.3", "react": "^17.0.2 || ^18.0.0 || ^19.0.0", "react-aria-components": ">= 1.14.0 <= 1.21.1", "react-dom": "^17.0.2 || ^18.0.0 || ^19.0.0", "typescript": ">=5.0.0 <7.0.0" }, "optionalPeers": ["@emotion/react", "@guardian/prosemirror-invisibles", "@internationalized/date", "prosemirror-dropcursor", "prosemirror-history", "prosemirror-keymap", "prosemirror-model", "prosemirror-state", "prosemirror-view", "react", "react-aria-components", "react-dom", "typescript"] }, "sha512-G9rCI75TIwJGPgZt4LxDs/1JDCoLu8P5hBJThe72KsRgrg2ShcxpQOezg/MjcTvKBlv0cIUJv9E+0r+eOLGN1w=="], "@guardian/tsconfig": ["@guardian/tsconfig@2.0.0", "", {}, "sha512-alvlrRwOF42tCcxkT4zL+0wauoywMK9FzRgZgx8BV/4ggVEUARTTeCc+HXIbG8Gj9EZkFWFVWJJrFLwqJAkgBw=="], @@ -2230,4 +2230,4 @@ "read-pkg-up/find-up/locate-path/p-locate/p-limit": ["p-limit@2.3.0", "", { "dependencies": { "p-try": "^2.0.0" } }, "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w=="], } -} \ No newline at end of file +} diff --git a/src/apps/frontend/package.json b/src/apps/frontend/package.json index bf0807a7..af1e13b8 100644 --- a/src/apps/frontend/package.json +++ b/src/apps/frontend/package.json @@ -16,7 +16,7 @@ }, "dependencies": { "@emotion/react": "11.14.0", - "@guardian/stand": "1.0.0", + "@guardian/stand": "0.0.0-canary-20261030120059", "@hookform/resolvers": "5.9.1", "models": "workspace:*", "@tanstack/react-query": "5.103.2", diff --git a/src/apps/frontend/src/compose/AppAlertReplaceImageSection.tsx b/src/apps/frontend/src/compose/AppAlertReplaceImageSection.tsx index 84178699..95624e18 100644 --- a/src/apps/frontend/src/compose/AppAlertReplaceImageSection.tsx +++ b/src/apps/frontend/src/compose/AppAlertReplaceImageSection.tsx @@ -10,7 +10,7 @@ import { useContext } from 'react'; import { ConfigContext } from '../config/ConfigContext'; import { useImageUrlCheck } from '../hooks/useImageUrlCheck'; import { CENTRAL_PRODUCTION_CONTACT_HREF } from '../support-links'; -import { GridImagePicker } from './GridImagePicker'; +import { GridImagePickerImp } from './GridImagePicker'; interface AppAlertReplaceImageSectionProps { replacementImageUrl: string; @@ -120,7 +120,7 @@ export const AppAlertReplaceImageSection = ({ Image updated )} - diff --git a/src/apps/frontend/src/compose/GridImagePicker.tsx b/src/apps/frontend/src/compose/GridImagePicker.tsx index e4e87de5..f3212f95 100644 --- a/src/apps/frontend/src/compose/GridImagePicker.tsx +++ b/src/apps/frontend/src/compose/GridImagePicker.tsx @@ -1,71 +1,16 @@ import { semanticSpacing } from '@guardian/stand'; -import { Button } from '@guardian/stand/Button'; -import { InlineMessage } from '@guardian/stand/InlineMessage'; -import { PickerIframeModal } from '@guardian/stand/PickerIframeModal'; -import type { CropData, ImageData } from 'models'; -import { gridImageResponse } from 'models'; -import { useContext, useState } from 'react'; +import { GridImagePicker } from '@guardian/stand/GridImagePicker'; +import { useContext } from 'react'; import { ConfigContext } from '../config/ConfigContext'; -import { extractAsset, isFiveFourCrop } from '../grid-client/grid-api'; -import { GridIcon } from '../ui/GridIcon'; - -type ImageAndCrop = { - crop: CropData; - image: ImageData; -}; interface Props { onUpdate: (replacementImageUrl: string) => void; setTextInput?: (replacementImageUrl: string) => void; } -const validateGridData = (messageData: unknown): { data?: ImageAndCrop } => { - const responseParse = gridImageResponse.safeParse(messageData); - if (responseParse.success) { - const cropData = responseParse.data.crop?.data; - const imageData = responseParse.data.image?.data; - if (cropData && imageData) { - const payload: ImageAndCrop = { - crop: cropData, - image: imageData, - }; - return { data: payload }; - } - } - return {}; -}; - -export const GridImagePicker = ({ onUpdate, setTextInput }: Props) => { - const [gridPageOpen, seGridPageOpen] = useState<'search' | 'image'>(); - const [lastImageId, setLastImageId] = useState(); - const [failureFeedback, setFailureFeedBack] = useState(); +export const GridImagePickerImp = ({ onUpdate, setTextInput }: Props) => { const { gridUri } = useContext(ConfigContext) ?? {}; - const handleImageAndCrop = ({ crop, image }: ImageAndCrop) => { - setLastImageId(image.id); - const isRightAspect = isFiveFourCrop(crop); - const assetResult = extractAsset(crop); - const file = assetResult.success && assetResult.data.file; - - if (!isRightAspect) { - setFailureFeedBack('Please select a 5:4 crop'); - } - if (!file) { - setFailureFeedBack('Could not identify file to use'); - } - - if (file && isRightAspect) { - setTextInput?.(`${gridUri}/images/${image.id}?crop=${crop.id}`); - onUpdate(file); - } - }; - - const gridPageUri = gridPageOpen - ? lastImageId && gridPageOpen === 'image' - ? `${gridUri}/images/${lastImageId}?cropType=all&defaultCropType=landscape` - : `${gridUri}/search?cropType=all&defaultCropType=landscape` - : undefined; - return (
{ alignItems: 'center', }} > - - - {lastImageId && ( - - )} - - {failureFeedback && ( - {failureFeedback} + gridUri={gridUri} + allowedAspectRatios={['5:4']} + theme={{ + container: { + width: '100%', + }, + imagePreview: { + maxHeight: '200px', + maxWidth: '300px', + }, + }} + /> )} - seGridPageOpen(undefined)} - title={'Pick an image'} - validate={validateGridData} - handleData={handleImageAndCrop} - />
); }; From f64a285bece7f637f3c1b0f1ebd2435c87b54a74 Mon Sep 17 00:00:00 2001 From: DBlatcher Date: Fri, 30 Oct 2026 14:49:48 +0000 Subject: [PATCH 6/8] undo changes not longer needed with new component --- src/apps/frontend/src/grid-client/grid-api.ts | 4 ++-- src/apps/frontend/src/ui/GridIcon.tsx | 23 ------------------- 2 files changed, 2 insertions(+), 25 deletions(-) delete mode 100644 src/apps/frontend/src/ui/GridIcon.tsx diff --git a/src/apps/frontend/src/grid-client/grid-api.ts b/src/apps/frontend/src/grid-client/grid-api.ts index b999d33f..af2c84c8 100644 --- a/src/apps/frontend/src/grid-client/grid-api.ts +++ b/src/apps/frontend/src/grid-client/grid-api.ts @@ -78,7 +78,7 @@ const findCrop = (imageData: ImageData, cropId: string): Result => { }; }; -export const extractAsset = (crop: CropData): Result => { +const extractAsset = (crop: CropData): Result => { const assetsSmallestFirst = crop.assets?.sort( (assetA, assetB) => (assetA.dimensions?.width ?? 0) - (assetB.dimensions?.width ?? 0), @@ -100,7 +100,7 @@ export const extractAsset = (crop: CropData): Result => { }; }; -export const isFiveFourCrop = (crop: CropData): boolean | undefined => { +const isFiveFourCrop = (crop: CropData): boolean | undefined => { const { specification, master } = crop; if (specification?.aspectRatio) { return specification.aspectRatio === '5:4'; diff --git a/src/apps/frontend/src/ui/GridIcon.tsx b/src/apps/frontend/src/ui/GridIcon.tsx deleted file mode 100644 index 2112ffbf..00000000 --- a/src/apps/frontend/src/ui/GridIcon.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import { baseColors } from '@guardian/stand'; - -interface Props { - color?: string; -} - -export const GridIcon = ({ color = baseColors.neutral[900] }: Props) => ( - - - -); From 5dd2e0a95b06bbc59120f25dcd0c95f233f9caf9 Mon Sep 17 00:00:00 2001 From: DBlatcher Date: Fri, 30 Oct 2026 14:54:23 +0000 Subject: [PATCH 7/8] move the stand component in to the replace image section --- .../compose/AppAlertReplaceImageSection.tsx | 25 ++++++++--- .../frontend/src/compose/GridImagePicker.tsx | 43 ------------------- 2 files changed, 20 insertions(+), 48 deletions(-) delete mode 100644 src/apps/frontend/src/compose/GridImagePicker.tsx diff --git a/src/apps/frontend/src/compose/AppAlertReplaceImageSection.tsx b/src/apps/frontend/src/compose/AppAlertReplaceImageSection.tsx index 95624e18..ea6163af 100644 --- a/src/apps/frontend/src/compose/AppAlertReplaceImageSection.tsx +++ b/src/apps/frontend/src/compose/AppAlertReplaceImageSection.tsx @@ -1,6 +1,7 @@ import { css } from '@emotion/react'; import { semanticColors, semanticSpacing } from '@guardian/stand'; import { Button } from '@guardian/stand/Button'; +import { GridImagePicker } from '@guardian/stand/GridImagePicker'; import { InlineMessage } from '@guardian/stand/InlineMessage'; import { Link } from '@guardian/stand/Link'; import { LinkButton } from '@guardian/stand/LinkButton'; @@ -10,7 +11,6 @@ import { useContext } from 'react'; import { ConfigContext } from '../config/ConfigContext'; import { useImageUrlCheck } from '../hooks/useImageUrlCheck'; import { CENTRAL_PRODUCTION_CONTACT_HREF } from '../support-links'; -import { GridImagePickerImp } from './GridImagePicker'; interface AppAlertReplaceImageSectionProps { replacementImageUrl: string; @@ -120,10 +120,25 @@ export const AppAlertReplaceImageSection = ({ Image updated )} - + {gridUri && ( + { + onUpdate(imageAssetUrl); + handleImageUrlChange(imageAssetUrl); + }} + gridUri={gridUri} + allowedAspectRatios={['5:4']} + theme={{ + container: { + width: '100%', + }, + imagePreview: { + maxHeight: '200px', + maxWidth: '300px', + }, + }} + /> + )} ); }; diff --git a/src/apps/frontend/src/compose/GridImagePicker.tsx b/src/apps/frontend/src/compose/GridImagePicker.tsx deleted file mode 100644 index f3212f95..00000000 --- a/src/apps/frontend/src/compose/GridImagePicker.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import { semanticSpacing } from '@guardian/stand'; -import { GridImagePicker } from '@guardian/stand/GridImagePicker'; -import { useContext } from 'react'; -import { ConfigContext } from '../config/ConfigContext'; - -interface Props { - onUpdate: (replacementImageUrl: string) => void; - setTextInput?: (replacementImageUrl: string) => void; -} - -export const GridImagePickerImp = ({ onUpdate, setTextInput }: Props) => { - const { gridUri } = useContext(ConfigContext) ?? {}; - - return ( -
- {gridUri && ( - { - onUpdate(imageAssetUrl); - setTextInput?.(imageAssetUrl); - }} - gridUri={gridUri} - allowedAspectRatios={['5:4']} - theme={{ - container: { - width: '100%', - }, - imagePreview: { - maxHeight: '200px', - maxWidth: '300px', - }, - }} - /> - )} -
- ); -}; From 8d27c6df2a698488de63c76a3ae29926e507d823 Mon Sep 17 00:00:00 2001 From: DBlatcher Date: Fri, 20 Nov 2026 12:45:29 +0000 Subject: [PATCH 8/8] TEMP FIX - hardcode gird URI into CSP --- src/apps/backend/middleware/security-headers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/backend/middleware/security-headers.ts b/src/apps/backend/middleware/security-headers.ts index c0e750ad..09970a68 100644 --- a/src/apps/backend/middleware/security-headers.ts +++ b/src/apps/backend/middleware/security-headers.ts @@ -22,7 +22,7 @@ const buildContentSecurityPolicy = (nonce: string): string => `img-src 'self' data: blob: https:`, `font-src 'self' data: https:`, `connect-src 'self' https:`, - `frame-src 'self'`, + `frame-src 'self https://media.test.dev-gutools.co.uk/ https://media.gutools.co.uk/`, // TO DO - read the Grid URI from config? ].join('; '); /**