@kiva/kv-components 3.87.3 → 3.87.4

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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.87.4](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@3.87.3...@kiva/kv-components@3.87.4) (2024-07-17)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * increase quality setting for small contentful images ([9a75d76](https://github.com/kiva/kv-ui-elements/commit/9a75d76837240dc7f07cd04097575677bd7cbdac))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [3.87.3](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@3.87.2...@kiva/kv-components@3.87.3) (2024-07-16)
7
18
 
8
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kiva/kv-components",
3
- "version": "3.87.3",
3
+ "version": "3.87.4",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -81,5 +81,5 @@
81
81
  "optional": true
82
82
  }
83
83
  },
84
- "gitHead": "99b5af537255fc539c78039e42970be595be6ea6"
84
+ "gitHead": "00dcbe465560e7ccbf9dba5e92bb03d4b78ff216"
85
85
  }
@@ -18,10 +18,11 @@
18
18
  :width="image.width ? image.width : null"
19
19
  :height="image.height ? image.height : null"
20
20
  :srcset="`
21
- ${buildUrl(image, 2)}&fit=${fit}&f=${focus}&fm=webp&q=65 2x,
22
- ${buildUrl(image)}&fit=${fit}&f=${focus}&fm=webp&q=80 1x`"
21
+ ${buildUrl(image, 2)}&fit=${fit}&f=${focus}&fm=webp&q=${setQuality(image.width, '2x')} 2x,
22
+ ${buildUrl(image)}&fit=${fit}&f=${focus}&fm=webp&q=${setQuality(image.width, '1x')} 1x`"
23
23
  >
24
24
  <!-- browser doesn't support webp -->
25
+ <!-- eslint-disable max-len -->
25
26
  <source
26
27
  v-for="(image, index) in sourceSizes"
27
28
  :key="'fallback-image'+index"
@@ -29,17 +30,20 @@
29
30
  :width="image.width ? image.width : null"
30
31
  :height="image.height ? image.height : null"
31
32
  :srcset="`
32
- ${buildUrl(image, 2)}&fit=${fit}&f=${focus}&fm=${fallbackFormat}&q=65 2x,
33
- ${buildUrl(image)}&fit=${fit}&f=${focus}&fm=${fallbackFormat}&q=80 1x`"
33
+ ${buildUrl(image, 2)}&fit=${fit}&f=${focus}&fm=${fallbackFormat}&q=${setQuality(image.width, '2x')} 2x,
34
+ ${buildUrl(image)}&fit=${fit}&f=${focus}&fm=${fallbackFormat}&q=${setQuality(image.width, '1x')} 1x`"
34
35
  >
36
+ <!-- eslint-enable max-len -->
35
37
  <!-- browser doesn't support picture element -->
38
+ <!-- eslint-disable max-len -->
36
39
  <img
37
40
  class="tw-max-w-full tw-max-h-full"
38
41
  style="width: inherit; height: inherit; object-fit: inherit;"
39
- :src="`${buildUrl(width, height)}&fit=${fit}&f=${focus}&fm=${fallbackFormat}&q=80`"
42
+ :src="`${buildUrl(width, height)}&fit=${fit}&f=${focus}&fm=${fallbackFormat}&q=${setQuality(width, '1x')}`"
40
43
  :alt="caption || alt"
41
44
  :loading="loading"
42
45
  >
46
+ <!-- eslint-enable max-len -->
43
47
  </template>
44
48
 
45
49
  <!-- Single image -->
@@ -48,17 +52,17 @@
48
52
  <source
49
53
  type="image/webp"
50
54
  :srcset="`
51
- ${buildUrl(null, 2)}&fit=${fit}&f=${focus}&fm=webp&q=65 2x,
52
- ${buildUrl()}&fit=${fit}&f=${focus}&fm=webp&q=80 1x`"
55
+ ${buildUrl(null, 2)}&fit=${fit}&f=${focus}&fm=webp&q=${setQuality(width, '2x')} 2x,
56
+ ${buildUrl()}&fit=${fit}&f=${focus}&fm=webp&q=${setQuality(width, '1x')} 1x`"
53
57
  >
54
58
  <!-- browser doesn't support webp or browser doesn't support picture element -->
55
59
  <img
56
60
  class="tw-max-w-full tw-max-h-full"
57
61
  style="width: inherit; height: inherit; object-fit: inherit;"
58
62
  :srcset="`
59
- ${buildUrl(null, 2)}&fit=${fit}&f=${focus}&fm=${fallbackFormat}&q=65 2x,
60
- ${buildUrl()}&fit=${fit}&f=${focus}&fm=${fallbackFormat}&q=80 1x`"
61
- :src="`${buildUrl()}&fit=${fit}&f=${focus}&fm=${fallbackFormat}&q=80`"
63
+ ${buildUrl(null, 2)}&fit=${fit}&f=${focus}&fm=${fallbackFormat}&q=${setQuality(width, '2x')} 2x,
64
+ ${buildUrl()}&fit=${fit}&f=${focus}&fm=${fallbackFormat}&q=${setQuality(width, '1x')} 1x`"
65
+ :src="`${buildUrl()}&fit=${fit}&f=${focus}&fm=${fallbackFormat}&q=${setQuality(width, '1x')}`"
62
66
  :width="width ? width : null"
63
67
  :height="height ? height : null"
64
68
  :alt="caption || alt"
@@ -241,6 +245,17 @@ export default {
241
245
  return src;
242
246
  };
243
247
 
248
+ const setQuality = (imgWidth, imgScale) => {
249
+ if (imgScale === '2x') {
250
+ return 65;
251
+ }
252
+ // Smaller images show a marked degradation at 80 quality so we bump it up to 95
253
+ if (imgWidth && parseInt(imgWidth, 10) < 200) {
254
+ return 95;
255
+ }
256
+ return 80;
257
+ };
258
+
244
259
  const caption = computed(() => {
245
260
  if (alt.value && alt.value.charAt(0) === '^') {
246
261
  return alt.value.slice(1).trim();
@@ -251,6 +266,7 @@ export default {
251
266
  return {
252
267
  buildUrl,
253
268
  caption,
269
+ setQuality,
254
270
  };
255
271
  },
256
272
  };