@gluhar/app 2.5.2 → 2.6.0

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
+ # [2.6.0](https://github.com/gluharry/gluhar/compare/@gluhar/app@2.5.2...@gluhar/app@2.6.0) (2025-02-07)
7
+
8
+
9
+ ### 🚀 Enhancements
10
+
11
+ - SanityImg component ([04d86e2](https://github.com/gluharry/gluhar/commit/04d86e2d55ff03195a92efb1df7bc35c92e3394c))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [2.5.2](https://github.com/gluharry/gluhar/compare/@gluhar/app@2.5.1...@gluhar/app@2.5.2) (2025-01-28)
7
18
 
8
19
 
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gluhar/app",
3
3
  "configKey": "gluhar",
4
- "version": "2.5.2",
4
+ "version": "2.6.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.3",
7
7
  "unbuild": "2.0.0"
package/dist/module.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { defineNuxtModule, createResolver, installModule, addImportsDir } from '@nuxt/kit';
1
+ import { defineNuxtModule, createResolver, installModule, addImportsDir, addComponentsDir } from '@nuxt/kit';
2
2
  import defu from 'defu';
3
3
 
4
4
  const module = defineNuxtModule({
@@ -23,6 +23,7 @@ const module = defineNuxtModule({
23
23
  await installModule("@gluhar/sanity", sanity);
24
24
  }
25
25
  addImportsDir(resolve("runtime/composables"));
26
+ addComponentsDir({ path: resolve("runtime/components") });
26
27
  addImportsDir(resolve("runtime/utils"));
27
28
  addImportsDir(resolve("runtime/stores"));
28
29
  nuxt.options.vite = defu(nuxt.options.vite, {
@@ -0,0 +1,59 @@
1
+ <script setup lang="ts">
2
+ import { computed, ref } from "#imports";
3
+ import type { SanityImage } from "@gluhar/sanity/types";
4
+ import imageUrlBuilder from "@sanity/image-url";
5
+ import type { ImageFormat } from "@sanity/image-url/lib/types/types";
6
+ import sanityConfig from "~/config/sanity.config";
7
+
8
+ const props = withDefaults(
9
+ defineProps<{
10
+ image?: SanityImage;
11
+ by?: "w" | "h";
12
+ width?: number;
13
+ height?: number;
14
+ format?: ImageFormat | null;
15
+ }>(),
16
+ { by: "w" },
17
+ );
18
+
19
+ const { l } = useMessages();
20
+
21
+ const builder = imageUrlBuilder(sanityConfig);
22
+ const urlFor = (source: SanityImage) => builder.image(source);
23
+
24
+ const imgRef = ref<HTMLImageElement | null>(null);
25
+ const src = computed(() => {
26
+ const { width, height } = imgRef.value?.getBoundingClientRect() || {
27
+ width: undefined,
28
+ height: undefined,
29
+ };
30
+
31
+ if (!props.image || (!width && !height)) return undefined;
32
+
33
+ let url = urlFor(props.image);
34
+
35
+ if (props.width) url = url.width(props.width);
36
+ else if (width && props.by === "w") url = url.width(Math.ceil(width));
37
+
38
+ if (props.height) url = url.height(props.height);
39
+ else if (height && props.by === "h") url = url.height(Math.ceil(height));
40
+
41
+ url = url.format(props.format ?? "webp");
42
+ url = url.quality(100);
43
+
44
+ // const dpr = window.devicePixelRatio;
45
+ url = url.dpr(1.2);
46
+
47
+ return url.url();
48
+ });
49
+ </script>
50
+
51
+ <template>
52
+ <img
53
+ class="object-cover"
54
+ :src
55
+ :alt="l(image.caption) || l(image.alt)"
56
+ ref="imgRef"
57
+ v-if="image"
58
+ />
59
+ </template>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gluhar/app",
3
- "version": "2.5.2",
3
+ "version": "2.6.0",
4
4
  "description": "Gluhar main package. This combines and configures @gluhar/theme, @gluhar/i18n, @gluhar/sanity and @gluhar/core into one main package. Provides numerous components, composables, utils and types.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -43,6 +43,7 @@
43
43
  "@gluhar/theme": "^2.0.2",
44
44
  "@nuxt/kit": "^3.13.1",
45
45
  "@pinia/nuxt": "^0.5.4",
46
+ "@sanity/image-url": "^1.1.0",
46
47
  "defu": "^6.1.4",
47
48
  "pinia": "^2.2.2"
48
49
  },
@@ -58,5 +59,5 @@
58
59
  "nuxt": "^3.13.1",
59
60
  "vitest": "^2.0.5"
60
61
  },
61
- "gitHead": "f19d2e2a0f29905d9258938bd9239ab1c7e4e782"
62
+ "gitHead": "48de7c15bdc9a8186cfb49833ff588c2347a2c18"
62
63
  }