Skip to content

Commit 381e13c

Browse files
LBascorbic
LB
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

+2-2
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

+1-2
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

+4-4
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

+2-2
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

+2-2
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

+14-6
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

+1-1
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

+4-4
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

-1
This file was deleted.

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

-1
This file was deleted.

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

-1
This file was deleted.

packages/gatsby-plugin-image/compat.js

-1
This file was deleted.

packages/gatsby-plugin-image/package.json

-12
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,12 @@
77
"build:gatsby-ssr": "microbundle -i src/gatsby-ssr.tsx -f cjs -o ./[name].js --no-pkg-main --jsx React.createElement --no-compress --external=common-tags,react --no-sourcemap",
88
"build:server": "microbundle -f cjs,es --jsx React.createElement --define SERVER=true",
99
"build:browser": "microbundle -i src/index.browser.ts -f cjs,modern,es --jsx React.createElement -o dist/gatsby-image.browser --define SERVER=false",
10-
"build:server-compat": "microbundle -i src/components/compat.tsx -f cjs,es --jsx React.createElement -o dist/gatsby-image.compat --define SERVER=true",
11-
"build:browser-compat": "microbundle -i src/components/compat.browser.tsx -f cjs,modern,es --jsx React.createElement -o dist/gatsby-image.compat.browser --define SERVER=false",
1210
"prepare": "yarn build",
1311
"watch": "run-p watch:*",
1412
"watch:gatsby-node": "yarn build:gatsby-node --watch",
1513
"watch:gatsby-ssr": "yarn build:gatsby-ssr watch",
1614
"watch:server": "yarn build:server --no-compress watch",
1715
"watch:browser": "yarn build:browser --no-compress watch",
18-
"watch:server-compat": "yarn build:server-compat --no-compress watch",
19-
"watch:browser-compat": "yarn build:browser-compat --no-compress watch",
2016
"test": "jest",
2117
"test:watch": "jest --watch",
2218
"clean": "del-cli dist/*"
@@ -30,20 +26,12 @@
3026
"module": "dist/gatsby-image.module.js",
3127
"esmodule": "dist/gatsby-image.modern.js",
3228
"browser": {
33-
"./compat.js": "./compat.browser.module.js",
34-
"./compat.module.js": "./compat.browser.module.js",
35-
"./compat.modern.js": "./compat.browser.modern.js",
3629
"./dist/gatsby-image.js": "./dist/gatsby-image.browser.js",
3730
"./dist/gatsby-image.module.js": "./dist/gatsby-image.browser.module.js",
3831
"./dist/gatsby-image.modern.js": "./dist/gatsby-image.browser.modern.js"
3932
},
4033
"files": [
4134
"dist/*",
42-
"compat.js",
43-
"compat.module.js",
44-
"compat.browser.js",
45-
"compat.browser.module.js",
46-
"compat.browser.modern.js",
4735
"gatsby-node.js",
4836
"gatsby-ssr.js"
4937
],

packages/gatsby-plugin-image/src/__tests__/image-utils.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const args: IGatsbyImageHelperArgs = {
3737

3838
const fluidArgs: IGatsbyImageHelperArgs = {
3939
...args,
40-
layout: `fluid`,
40+
layout: `fullWidth`,
4141
}
4242

4343
const constrainedArgs: IGatsbyImageHelperArgs = {
@@ -153,7 +153,7 @@ describe(`the image data helper`, () => {
153153
expect(data.images.fallback?.sizes).toEqual(`400px`)
154154
})
155155

156-
it(`calculates sizes for fluid`, () => {
156+
it(`calculates sizes for fullWidth`, () => {
157157
const data = generateImageData(fluidArgs)
158158
expect(data.images.fallback?.sizes).toEqual(`100vw`)
159159
})
@@ -176,7 +176,7 @@ describe(`the image data helper`, () => {
176176
)
177177
})
178178

179-
it(`returns URLs for fluid`, () => {
179+
it(`returns URLs for fullWidth`, () => {
180180
const data = generateImageData(fluidArgs)
181181
expect(data?.images?.fallback?.src).toEqual(
182182
`https://example.com/afile.jpg/400/300/image.jpg`

packages/gatsby-plugin-image/src/components/__tests__/gatsby-image.browser.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe(`GatsbyImage browser`, () => {
2626
image = {
2727
width: 100,
2828
height: 100,
29-
layout: `fluid`,
29+
layout: `fullWidth`,
3030
images: { fallback: { src: `some-src-fallback.jpg`, sizes: `192x192` } },
3131
placeholder: { sources: [] },
3232

packages/gatsby-plugin-image/src/components/__tests__/gatsby-image.server.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ describe(`GatsbyImage server`, () => {
4141
})
4242

4343
describe(`style verifications`, () => {
44-
it(`has a valid style attributes for fluid layout`, () => {
45-
const layout = `fluid`
44+
it(`has a valid style attributes for fullWidth layout`, () => {
45+
const layout = `fullWidth`
4646

4747
const image: IGatsbyImageData = {
4848
width: 100,
@@ -350,11 +350,11 @@ icon.svg`,
350350
})
351351

352352
describe(`placeholder verifications`, () => {
353-
it(`has a placeholder in a div with valid styles for fluid layout`, () => {
353+
it(`has a placeholder in a div with valid styles for fullWidth layout`, () => {
354354
const image: IGatsbyImageData = {
355355
width: 100,
356356
height: 100,
357-
layout: `fluid`,
357+
layout: `fullWidth`,
358358
images: {},
359359
placeholder: { sources: [] },
360360
backgroundColor: `red`,

0 commit comments

Comments
 (0)