Skip to content

Commit

Permalink
Add immersive caption padding to compensate for negative margins
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmockett committed Jan 17, 2025
1 parent 56aa76e commit 3f646cd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions dotcom-rendering/src/components/Caption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type Props = {
isLeftCol?: boolean;
mediaType?: MediaType;
isMainMedia?: boolean;
isImmersive?: boolean;
};

type IconProps = {
Expand Down Expand Up @@ -123,6 +124,25 @@ const tabletCaptionPadding = css`
}
`;

const immersivePadding = css`
padding-left: 10px;
padding-right: 10px;
${from.mobileLandscape} {
padding-left: 20px;
padding-right: 20px;
}
${from.tablet} {
padding-right: 100px;
}
${from.desktop} {
padding-right: 340px;
}
${from.leftCol} {
padding-left: 0;
padding-right: 0;
}
`;

const bigLeftMargin = css`
width: inherit;
margin-left: ${space[9]}px;
Expand Down Expand Up @@ -228,6 +248,7 @@ export const Caption = ({
isLeftCol,
mediaType = 'Gallery',
isMainMedia = false,
isImmersive = false,
}: Props) => {
// Sometimes captions come thorough as a single blank space, so we trim here to ignore those
const noCaption = !captionText?.trim();
Expand All @@ -249,6 +270,7 @@ export const Caption = ({
(isBlog || mediaType === 'Video') &&
tabletCaptionPadding,
padCaption && captionPadding,
isImmersive && immersivePadding,
]}
data-spacefinder-role="inline"
>
Expand Down
1 change: 1 addition & 0 deletions dotcom-rendering/src/components/ImageComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ export const ImageComponent = ({
shouldLimitWidth={shouldLimitWidth}
isMainMedia={isMainMedia}
padCaption={role === 'showcase' && isTimeline}
isImmersive={role === 'immersive'}
/>
)}
</>
Expand Down

0 comments on commit 3f646cd

Please sign in to comment.