Skip to content

Demo Site: Add createImageSizes helper #3804

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

stekalt
Copy link
Contributor

@stekalt stekalt commented Apr 24, 2025

Description

The function createImageSizes is implemented to generate the sizes attribute string for Next.js images based on the breakpoints in the project. The sizes attribute is used by the browser to decide which image from the srcset to load depending on the viewport width. If not set, it defaults to 100vw.

Acceptance criteria

Screenshots/screencasts

Bildschirmaufnahme.2025-04-24.um.15.25.08.mov

Further information

@stekalt stekalt self-assigned this Apr 24, 2025
@auto-assign auto-assign bot requested a review from johnnyomair April 24, 2025 13:42
<RichTextBlock data={text} />
</TextContainer>
</Root>
<PageLayout>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By adding into a block, you are converting it into a PageContent-Block (a block that positions itself in the page (adds margins etc)).

PageContent-Blocks can only be used in the outer PageContentBlock (the root content-BlocksBlock) as it would add extra margins for nested usages.

common/blocks/* blocks can have two exports: A PageContent version and a plain version.

@stekalt stekalt force-pushed the add-createNextImageSizes-function branch from 5f93d98 to dfb5c9f Compare April 28, 2025 13:52
@@ -0,0 +1,17 @@
import theme, { Theme } from "@src/theme";

export function createImageSizes(breakpointWidths: Partial<Record<keyof Theme["breakpoints"], string | number>>) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this helper will never move into @comet/site (because then you can't just import from src/theme)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed in the focus meeting and with @johnnyomair the helper should only exist in the demo and the starter.

flex: 1;
aspect-ratio: ${({ $imageAspectRatio }) => $imageAspectRatio};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this needed? the image itself already has the aspect-ratio

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without it there's a layout shift occurring. But there's already a task (https://vivid-planet.atlassian.net/browse/COM-1678) for it, so I removed it again.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍
one PR, one task :)

import styled, { css } from "styled-components";

import { DamImageBlock } from "./DamImageBlock";
import { RichTextBlock } from "./RichTextBlock";

export const TextImageBlock = withPreview(
const TextImageBlock = withPreview(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const TextImageBlock = withPreview(
export const TextImageBlock = withPreview(e

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment the TextImageBlock is not used in any other file. Just for my understanding, why would you export it already?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. if it is a PageContent-Only block, it should not be in common/blocks (documents/pages/blocks would be correct I assume)
  2. it is very likely to be used in eg. Columns block (maybe we should add it there)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I guess adding it to the ColumnsBlock (and probably the AccordionBlock) would be a topic for another PR, right? If yes, I wouldn't change anything in the folder structure now and handle it in a second PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, please.

(and don't remove the export in this PR)

@stekalt stekalt force-pushed the add-createNextImageSizes-function branch from 2ba9767 to 13838b5 Compare April 30, 2025 09:03
@stekalt stekalt force-pushed the add-createNextImageSizes-function branch from 13838b5 to f0da793 Compare May 5, 2025 09:03
@stekalt stekalt force-pushed the add-createNextImageSizes-function branch from f0da793 to e684f5f Compare May 5, 2025 09:05
@johnnyomair johnnyomair self-requested a review May 7, 2025 07:42
@johnnyomair johnnyomair added the needs-starter-pr Change in Demo that needs to be changed in Starter as well. label May 13, 2025
@johnnyomair johnnyomair changed the title Demo Site: Add createNextImageSizes helper Demo Site: Add createImageSizes helper May 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-starter-pr Change in Demo that needs to be changed in Starter as well.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants