Skip to content

Commit

Permalink
Only show lightbox toggle if in experiment (#10279)
Browse files Browse the repository at this point in the history
  • Loading branch information
georgeblahblah authored Jan 22, 2024
1 parent d074d4e commit c574b91
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions dotcom-rendering/src/components/CartoonComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { css } from '@emotion/react';
import { ArticleDesign, ArticleDisplay, Pillar } from '@guardian/libs';
import { Hide } from '@guardian/source-react-components';
import { isWideEnough } from '../lib/lightbox';
import type { Switches } from '../types/config';
import type { ServerSideTests } from '../types/config';
import type { CartoonBlockElement, Image } from '../types/content';
import { AppsLightboxImage } from './AppsLightboxImage.importable';
import { Caption } from './Caption';
Expand All @@ -14,10 +14,10 @@ import { Picture } from './Picture';
type Props = {
format: ArticleFormat;
element: CartoonBlockElement;
switches?: Switches;
abTests?: ServerSideTests;
};

export const CartoonComponent = ({ format, element, switches }: Props) => {
export const CartoonComponent = ({ format, element, abTests }: Props) => {
const { renderingTarget } = useConfig();
const smallVariant = element.variants.find(
(variant) => variant.viewportSize === 'small',
Expand All @@ -26,6 +26,9 @@ export const CartoonComponent = ({ format, element, switches }: Props) => {
(variant) => variant.viewportSize === 'large',
);

const isInLightboxTest = abTests?.lightboxVariant === 'variant';
const webLightbox = renderingTarget === 'Web' && isInLightboxTest;

const render = (image: Image) => {
const altText = `${element.alt ? `${element.alt}, ` : ''}panel ${
image.index + 1
Expand Down Expand Up @@ -62,7 +65,7 @@ export const CartoonComponent = ({ format, element, switches }: Props) => {
/>
)}

{switches?.lightbox === true &&
{webLightbox &&
isWideEnough(image) &&
element.position !== undefined && (
<LightboxLink
Expand Down
2 changes: 1 addition & 1 deletion dotcom-rendering/src/lib/renderElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export const renderElement = ({
<CartoonComponent
format={format}
element={element}
switches={switches}
abTests={abTests}
/>
);
case 'model.dotcomrendering.pageElements.ChartAtomBlockElement':
Expand Down

0 comments on commit c574b91

Please sign in to comment.