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 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` manually, this won't be set)
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>⚠️ Minor gotchas with deferred loading</strong></summary>
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
- generally works fine in browsers that support it, but there are situations where
202
- the unloaded image is hidden or covered, resulting in the full image never
203
- loading.
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
- If this happens, you can override the styles set on the full-size image using
206
- the `img[data-loading]` selector. This image sits immediately adjacent to the
207
- spaceball image and has the following default styles _while loading_:
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 `height`, but not both), it
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 WrapperPRops } from "sanity-image"
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).
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vite").UserConfig;
2
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sanity-image",
3
- "version": "1.0.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.0"
25
+ "@sanity-image/url-builder": "1.0.1"
26
26
  },
27
27
  "devDependencies": {
28
- "@eslint/js": "^9.18.0",
29
- "@size-limit/preset-small-lib": "^8.2.4",
30
- "@testing-library/dom": "^10.4.0",
31
- "@testing-library/react": "^16.2.0",
32
- "@types/jest": "^29.4.0",
33
- "@types/node": "^20.0.0",
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.0.0",
36
- "@types/react-dom": "^18.3.5",
37
- "esbuild": "^0.24.2",
38
- "eslint": "^9.18.0",
39
- "eslint-plugin-import": "^2.27.5",
40
- "eslint-plugin-react": "^7.32.2",
41
- "eslint-plugin-react-hooks": "^5.1.0",
42
- "globals": "^15.14.0",
43
- "jest": "^29.5.0",
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": "^4.4.1",
51
- "size-limit": "^8.2.4",
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.6.0",
55
- "typescript-eslint": "^8.21.0"
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": "jest",
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