Skip to content

Commit 381e13c

Browse files
LBascorbic
andauthored
chore: change fluid to fullWidth (#28987)
* initial changes * Update packages/gatsby-plugin-image/README.md Co-authored-by: Matt Kane <[email protected]> * remove compat * update types * update tests * more test fixes * intermediate test naming * Update packages/gatsby-plugin-image/README.md Co-authored-by: Matt Kane <[email protected]> * conflict Co-authored-by: Matt Kane <[email protected]>
1 parent 12da978 commit 381e13c

File tree

28 files changed

+76
-245
lines changed

28 files changed

+76
-245
lines changed

e2e-tests/gatsby-static-image/cypress/integration/fluid.js renamed to e2e-tests/gatsby-static-image/cypress/integration/fullWidth.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const fluidTestId = `image-fluid`
22

3-
describe(`fluid`, () => {
3+
describe(`fullWidth`, () => {
44
beforeEach(() => {
5-
cy.visit(`/fluid`).waitForRouteChange()
5+
cy.visit(`/fullWidth`).waitForRouteChange()
66
})
77

88
it(`works on png files`, () => {

e2e-tests/gatsby-static-image/cypress/integration/image.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const fluidTestId = `image-fluid`
22

33
describe(`Production gatsby-image`, () => {
44
beforeEach(() => {
5-
cy.visit(`/fluid`).waitForRouteChange()
5+
cy.visit(`/fullWidth`).waitForRouteChange()
66
})
77

88
describe(`wrapping elements`, () => {
@@ -30,5 +30,4 @@ describe(`Production gatsby-image`, () => {
3030
.should(`not.exist`)
3131
})
3232
})
33-
3433
})

e2e-tests/gatsby-static-image/src/pages/fluid.js renamed to e2e-tests/gatsby-static-image/src/pages/fullWidth.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@ const FluidPage = () => (
88
<div data-testid="image-fluid">
99
<StaticImage
1010
src="../images/citrus-fruits.jpg"
11-
layout="fluid"
11+
layout="fullWidth"
1212
width={700}
1313
alt="Citrus fruits"
1414
/>
1515
</div>
1616
<div data-testid="image-fluid-png">
1717
<StaticImage
1818
src="../images/gatsby-icon.png"
19-
layout="fluid"
19+
layout="fullWidth"
2020
alt="Gatsby icon"
2121
/>
2222
</div>
2323
<div data-testid="image-fluid-relative">
2424
<StaticImage
2525
src="../../content/relative.jpg"
26-
layout="fluid"
26+
layout="fullWidth"
2727
alt="Citrus fruits"
2828
/>
2929
</div>
3030
<div data-testid="invalid-image">
31-
<StaticImage src="./does-not-exist.jpg" layout="fluid" />
31+
<StaticImage src="./does-not-exist.jpg" layout="fullWidth" />
3232
</div>
3333
</Layout>
3434
)

e2e-tests/visual-regression/cypress/integration/image.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
const testCases = [
22
["fixed image", "/images/fixed"],
33
["fixed image smaller than requested size", "/images/fixed-too-big"],
4-
["fluid image", "/images/fluid"],
4+
["fluid image", "/images/fullWidth"],
55
["constrained image", "/images/constrained"],
66
["avif format", "/images/avif"],
77
]
88
const staticImageTestCases = [
99
["fixed image", "/static-images/fixed"],
1010
["fixed image smaller than requested size", "/static-images/fixed-too-big"],
11-
["fluid image", "/static-images/fluid"],
11+
["fluid image", "/static-images/fullWidth"],
1212
["constrained image", "/static-images/constrained"],
1313
["avif format", "/static-images/avif"],
1414
]

e2e-tests/visual-regression/src/pages/images/fluid.js renamed to e2e-tests/visual-regression/src/pages/images/fullWidth.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ const Page = () => {
99
query {
1010
file(relativePath: { eq: "cornwall.jpg" }) {
1111
childImageSharp {
12-
gatsbyImageData(width: 1024, layout: FLUID)
12+
gatsbyImageData(width: 1024, layout: FULL_WIDTH)
1313
}
1414
}
1515
}
1616
`)
1717

1818
return (
1919
<Layout>
20-
<h1>Fluid, maxWidth</h1>
20+
<h1>fullWidth, maxWidth</h1>
2121
<TestWrapper style={{ display: `block` }}>
2222
<GatsbyImage
2323
image={getImage(data.file)}

e2e-tests/visual-regression/src/pages/index.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,20 @@ import Layout from "../components/layout"
66
const IndexPage = () => (
77
<Layout>
88
<h1>Gatsby Image integration test</h1>
9-
<ul>
10-
<li><Link to="/images/fixed">/images/fixed</Link></li>
11-
<li><Link to="/images/fixed-too-big">/images/fixed-too-big</Link></li>
12-
<li><Link to="/images/fluid">/images/fluid</Link></li>
13-
<li><Link to="/images/constrained">/images/constrained</Link></li>
14-
</ul>
9+
<ul>
10+
<li>
11+
<Link to="/images/fixed">/images/fixed</Link>
12+
</li>
13+
<li>
14+
<Link to="/images/fixed-too-big">/images/fixed-too-big</Link>
15+
</li>
16+
<li>
17+
<Link to="/images/fullWidth">/images/fullWidth</Link>
18+
</li>
19+
<li>
20+
<Link to="/images/constrained">/images/constrained</Link>
21+
</li>
22+
</ul>
1523
</Layout>
1624
)
1725

e2e-tests/visual-regression/src/pages/static-images/fluid.js renamed to e2e-tests/visual-regression/src/pages/static-images/fullWidth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const Page = () => {
1111
<StaticImage
1212
src="../../images/cornwall.jpg"
1313
loading="eager"
14-
layout="fluid"
14+
layout="fullWidth"
1515
width={1024}
1616
alt="cornwall"
1717
/>

packages/gatsby-plugin-image/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ devices with widths stretching from smartphone to wide desktop monitors.
272272

273273
To decide between the two, ask yourself: "do I know what the exact size of this image
274274
will be?" If yes, it's "fixed". If no and its width and/or height need to
275-
vary depending on the size of the screen, then it's "fluid". If you want it to shrink
275+
vary depending on the size of the screen, then it's "fullWidth". If you want it to shrink
276276
to fit on smaller screens, but not to expand larger than a maximum, then use "constrained"
277277

278278
In Gatsby's GraphQL implementation, you specify the type of image with the `layout` argument
@@ -289,7 +289,7 @@ In Gatsby's GraphQL implementation, you specify the type of image with the `layo
289289
# GraphQL resolver
290290

291291
We have added a new `gatsbyImageData` resolver to the `ImageSharp` node. Unlike the existing `fixed` and `fluid` resolvers, this returns a
292-
JSON type, meaning you don't specify the individual fields, but are instead given the whole object. This is because the object is then passed in to the `<GatsbyImage>` component. The API is like this:
292+
JSON type, meaning you don't specify the individual fields, but are instead given the whole object. This is because the object is then passed into the `<GatsbyImage>` component. The API is like this:
293293

294294
```graphql
295295
coverImage: file(relativePath: { eq: "plant.jpg" }) {
@@ -326,9 +326,9 @@ These arguments can be passed to the `gatsbyImageData()` resolver:
326326
- **layout**: The layout for the image.
327327
- `CONSTRAINED`: (default) Resizes to fit its container, up to a maximum width, at which point it will remain fixed in size.
328328
- `FIXED`: A static image size, that does not resize according to the screen width
329-
- `FLUID`: The image resizes to fit its container. Pass a "sizes" option if it isn't going to be the full width of the screen.
329+
- `FULL_WIDTH`: The image resizes to fit its container. Pass a "sizes" option if it isn't going to be the full width of the screen.
330330
- **outputPixelDensities**: A list of image pixel densities to generate, for high-resolution (retina) screens. It will never generate images larger than the source, and will always include a 1x image.
331-
Default is `[ 0.25, 0.5, 1, 2 ]`, for fluid/constrained images, and `[ 1, 2 ]` for fixed.
331+
Default is `[ 0.25, 0.5, 1, 2 ]`, for fullWidth/constrained images, and `[ 1, 2 ]` for fixed.
332332
- **sizes**: The "[sizes](https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images)" attribute, passed to the `<img>` tag. This describes the display size of the image. This does not affect the generated images, but is used by the browser to decide which images to download. You can leave this blank for fixed images, or if the responsive image container will be the full width of the screen. In these cases we will generate an appropriate value. If, however, you are generating responsive images that are not the full width of the screen, you should provide a sizes property for best performance. You can alternatively pass this value to the component.
333333
- **formats**: an array of file formats to generate. The default is `[AUTO, WEBP]`, which means it will generate images in the same format as the source image, as well as in the next-generation [WebP](https://developers.google.com/speed/webp) format. We strongly recommend you do not change this option, as doing so will affect performance scores.
334334
- **quality**: The default quality. This is overridden by any format-specific options

packages/gatsby-plugin-image/compat.browser.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/gatsby-plugin-image/compat.browser.modern.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)