sanity-image 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -13
- package/dist/vitest.config.d.ts +2 -0
- package/package.json +23 -25
- /package/dist/{ImageWithPreview.d.ts → src/ImageWithPreview.d.ts} +0 -0
- /package/dist/{SanityImage.d.ts → src/SanityImage.d.ts} +0 -0
- /package/dist/{index.d.ts → src/index.d.ts} +0 -0
- /package/dist/{types.d.ts → src/types.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -126,7 +126,8 @@ How it works at a glance:
|
|
|
126
126
|
`width` and `height` attributes are set automatically to avoid layout shifts
|
|
127
127
|
- A few image params are applied by default:
|
|
128
128
|
- `auto=format` - Sanity will use AVIF images if they're supported by the
|
|
129
|
-
browser (https://www.sanity.io/help/avif) (note: if you specify `fm`
|
|
129
|
+
browser (https://www.sanity.io/help/avif) (note: if you specify `fm`
|
|
130
|
+
manually, this won't be set)
|
|
130
131
|
- `fit` - if the image aspect ratio isn't changed, this will be set to `max`;
|
|
131
132
|
if the aspect ratio will change it's set to `crop`; you don't really need to
|
|
132
133
|
worry about this though
|
|
@@ -195,16 +196,26 @@ start a discussion if you have questions or suggestions, or find me on the
|
|
|
195
196
|
Sanity Slack!
|
|
196
197
|
|
|
197
198
|
<details>
|
|
198
|
-
<summary><strong>⚠️
|
|
199
|
+
<summary><strong>⚠️ “Help! My full-size image isn’t loading!"</strong></summary>
|
|
199
200
|
|
|
200
|
-
`SanityImage` is relying on browser-native deferred image loading. This
|
|
201
|
-
|
|
202
|
-
the
|
|
203
|
-
|
|
201
|
+
`SanityImage` is relying on browser-native deferred image loading. This relies
|
|
202
|
+
on the `<img>` element being visible on the page to trigger loading
|
|
203
|
+
automatically. If the image is hidden or covered by another element, it may
|
|
204
|
+
never be loaded.
|
|
204
205
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
206
|
+
For example, if you are using `overflow: hidden` on a parent element, the image
|
|
207
|
+
might be positioned in a way that it is not treated as visible by the browser.
|
|
208
|
+
This can also happen if you have `display: none` on the image or a parent
|
|
209
|
+
element, or if the image is positioned off-screen (e.g., in a carousel, or
|
|
210
|
+
waiting for an animation to reveal it).
|
|
211
|
+
|
|
212
|
+
Inspecting the DOM in your browser’s dev tools and checking the position of the
|
|
213
|
+
`<img>` element with the `data-loading` attribute can help you identify the
|
|
214
|
+
issue usually. Once you can identify the cause of the image being hidden, you
|
|
215
|
+
can adjust the CSS styles on the `img[data-loading]` element to make it visible.
|
|
216
|
+
|
|
217
|
+
For reference, the full-size image sits immediately adjacent to the preview
|
|
218
|
+
image and has the following default styles _while loading_:
|
|
208
219
|
|
|
209
220
|
```css
|
|
210
221
|
position: absolute;
|
|
@@ -222,8 +233,8 @@ userselect: none;
|
|
|
222
233
|
|
|
223
234
|
### Choosing the right `mode`
|
|
224
235
|
|
|
225
|
-
If you are providing only one dimension (`width` or
|
|
226
|
-
doesn't matter since the behavior will be the same.
|
|
236
|
+
If you are providing only one dimension (`width` or `height`, but not both), it
|
|
237
|
+
doesn't matter since the behavior will be the same.
|
|
227
238
|
|
|
228
239
|
- **Contain** mode will treat the dimensions you provide as boundaries, resizing
|
|
229
240
|
the image to fit inside of them. The output image will match the aspect ratio
|
|
@@ -248,7 +259,7 @@ example for quick reference:
|
|
|
248
259
|
|
|
249
260
|
```tsx
|
|
250
261
|
import * as React from "react"
|
|
251
|
-
import { SanityImage, type
|
|
262
|
+
import { SanityImage, type WrapperProps } from "sanity-image"
|
|
252
263
|
|
|
253
264
|
export const Image = <T extends React.ElementType = "img">(
|
|
254
265
|
props: WrapperProps<T>
|
|
@@ -420,5 +431,5 @@ crop {
|
|
|
420
431
|
|
|
421
432
|
## License
|
|
422
433
|
|
|
423
|
-
Copyright ©2023 Corey Ward. Available under the
|
|
434
|
+
Copyright ©2023-2025 Corey Ward. Available under the
|
|
424
435
|
[MIT License](https://github.com/coreyward/sanity-image/blob/main/LICENSE).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sanity-image",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"author": "Corey Ward <corey@hey.com>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "https://github.com/coreyward/sanity-image",
|
|
@@ -22,37 +22,35 @@
|
|
|
22
22
|
"react": "^18.0.0 || ^19.0.0"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@sanity-image/url-builder": "1.0.
|
|
25
|
+
"@sanity-image/url-builder": "1.0.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@eslint/
|
|
29
|
-
"@
|
|
30
|
-
"@
|
|
31
|
-
"@testing-library/
|
|
32
|
-
"@
|
|
33
|
-
"@types/node": "^20.
|
|
28
|
+
"@eslint/eslintrc": "^3.3.3",
|
|
29
|
+
"@eslint/js": "^9.39.2",
|
|
30
|
+
"@size-limit/preset-small-lib": "^12.0.0",
|
|
31
|
+
"@testing-library/dom": "^10.4.1",
|
|
32
|
+
"@testing-library/react": "^16.3.2",
|
|
33
|
+
"@types/node": "^20.19.0",
|
|
34
34
|
"@types/probe-image-size": "^7.2.0",
|
|
35
|
-
"@types/react": "^18.
|
|
36
|
-
"@types/react-dom": "^18.3.
|
|
37
|
-
"esbuild": "^0.
|
|
38
|
-
"eslint": "^9.
|
|
39
|
-
"eslint-plugin-import": "^2.
|
|
40
|
-
"eslint-plugin-react": "^7.
|
|
41
|
-
"eslint-plugin-react-hooks": "^5.
|
|
42
|
-
"globals": "^15.
|
|
43
|
-
"
|
|
44
|
-
"jest-environment-jsdom": "^29.5.0",
|
|
45
|
-
"prettier": "^3.0.0",
|
|
35
|
+
"@types/react": "^18.3.28",
|
|
36
|
+
"@types/react-dom": "^18.3.7",
|
|
37
|
+
"esbuild": "^0.25.12",
|
|
38
|
+
"eslint": "^9.39.2",
|
|
39
|
+
"eslint-plugin-import": "^2.32.0",
|
|
40
|
+
"eslint-plugin-react": "^7.37.5",
|
|
41
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
42
|
+
"globals": "^15.15.0",
|
|
43
|
+
"prettier": "^3.8.1",
|
|
46
44
|
"probe-image-size": "^7.2.3",
|
|
47
45
|
"react": "^18.3.0",
|
|
48
46
|
"react-dom": "^18.3.0",
|
|
49
47
|
"react-test-renderer": "^18.3.0",
|
|
50
|
-
"rimraf": "^
|
|
51
|
-
"size-limit": "^
|
|
52
|
-
"ts-jest": "^29.1.0",
|
|
48
|
+
"rimraf": "^6.1.3",
|
|
49
|
+
"size-limit": "^12.0.0",
|
|
53
50
|
"ts-node": "^10.9.1",
|
|
54
|
-
"typescript": "^5.
|
|
55
|
-
"typescript-eslint": "^8.
|
|
51
|
+
"typescript": "^5.9.3",
|
|
52
|
+
"typescript-eslint": "^8.56.0",
|
|
53
|
+
"vitest": "^4.0.18"
|
|
56
54
|
},
|
|
57
55
|
"engines": {
|
|
58
56
|
"node": ">=16"
|
|
@@ -73,7 +71,7 @@
|
|
|
73
71
|
"postbuild:sanity-image": "./scripts/postbuild.sh",
|
|
74
72
|
"build:url-builder": "pnpm --filter @sanity-image/url-builder run build",
|
|
75
73
|
"size": "size-limit",
|
|
76
|
-
"test": "
|
|
74
|
+
"test": "vitest run",
|
|
77
75
|
"test:generate-measurements": "yarn build && yarn node tests/buildTestCases.js",
|
|
78
76
|
"lint": "eslint src/**/*{.ts,.tsx}"
|
|
79
77
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|