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

fix: conditionally import image style #12925

Merged
merged 8 commits into from
Jan 8, 2025
Merged

fix: conditionally import image style #12925

merged 8 commits into from
Jan 8, 2025

Conversation

ascorbic
Copy link
Contributor

@ascorbic ascorbic commented Jan 7, 2025

Changes

Responsive images need to include global styles, and currently these are being included even if responsive images are not enabled. This PR adds wrapper components that just add the styles to the main component, and conditionally export these according to whether the flag is enabled. This is temporary until the feature is unflagged.

Alongside #12921, this fixes #12868

Testing

Adds tests to ensure the styles aren't added to sites without the flag enabled. There are existing tests that check that they are added to pages that do have them enabled.

This also adds tests to the MDX integration that were needed for #12921 and are now possible. These check whether the styles are being applied to pages with no images.

Docs

Copy link

changeset-bot bot commented Jan 7, 2025

🦋 Changeset detected

Latest commit: 1d928cf

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Jan 7, 2025
Copy link

codspeed-hq bot commented Jan 7, 2025

CodSpeed Performance Report

Merging #12925 will not alter performance

Comparing conditional-img-style (1d928cf) with main (21aa25c)

Summary

✅ 6 untouched benchmarks

@github-actions github-actions bot added the pkg: integration Related to any renderer integration (scope) label Jan 8, 2025
@ascorbic ascorbic marked this pull request as ready for review January 8, 2025 10:34
@@ -26,15 +26,15 @@ describe('Content Collections - render()', () => {
assert.equal($('ul li').length, 3);

// Includes styles
assert.equal($('link[rel=stylesheet]').length, 2);
assert.equal($('link[rel=stylesheet]').length, 1);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are all tests that were changed when experimental images were added. This is just changing them back.

@ascorbic ascorbic force-pushed the conditional-img-style branch from d7bbb08 to 22c58a2 Compare January 8, 2025 12:52
@ascorbic ascorbic merged commit 44841fc into main Jan 8, 2025
4 checks passed
@ascorbic ascorbic deleted the conditional-img-style branch January 8, 2025 13:24
@astrobot-houston astrobot-houston mentioned this pull request Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope) pkg: integration Related to any renderer integration (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unused data-astro-image styles
3 participants