@gluhar/app 2.5.2 → 2.6.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/CHANGELOG.md CHANGED
@@ -3,6 +3,28 @@
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.1](https://github.com/gluharry/gluhar/compare/@gluhar/app@2.6.0...@gluhar/app@2.6.1) (2025-02-12)
7
+
8
+
9
+ ### 🩹 Fixes
10
+
11
+ - SanityImg to import useMessage and fix by prop ([deec5d1](https://github.com/gluharry/gluhar/commit/deec5d1a5f8bbcbc9e823767ab95b195e867c909))
12
+
13
+
14
+
15
+
16
+
17
+ # [2.6.0](https://github.com/gluharry/gluhar/compare/@gluhar/app@2.5.2...@gluhar/app@2.6.0) (2025-02-07)
18
+
19
+
20
+ ### 🚀 Enhancements
21
+
22
+ - SanityImg component ([04d86e2](https://github.com/gluharry/gluhar/commit/04d86e2d55ff03195a92efb1df7bc35c92e3394c))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [2.5.2](https://github.com/gluharry/gluhar/compare/@gluhar/app@2.5.1...@gluhar/app@2.5.2) (2025-01-28)
7
29
 
8
30
 
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.1",
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,61 @@
1
+ <script setup lang="ts">
2
+ import { computed, ref, useMessages } 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 =
9
+ withDefaults(
10
+ defineProps<{
11
+ image?: SanityImage;
12
+ by?: "width" | "height" | "both";
13
+ width?: number;
14
+ height?: number;
15
+ format?: ImageFormat | null;
16
+ }>(),
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 === "width" || !props.by))
37
+ url = url.width(Math.ceil(width));
38
+
39
+ if (props.height) url = url.height(props.height);
40
+ else if (height && (props.by === "height" || !props.by))
41
+ url = url.height(Math.ceil(height));
42
+
43
+ url = url.format(props.format ?? "webp");
44
+ url = url.quality(100);
45
+
46
+ // const dpr = window.devicePixelRatio;
47
+ url = url.dpr(1.2);
48
+
49
+ return url.url();
50
+ });
51
+ </script>
52
+
53
+ <template>
54
+ <img
55
+ class="object-cover"
56
+ :src
57
+ :alt="l(image.caption) || l(image.alt)"
58
+ ref="imgRef"
59
+ v-if="image"
60
+ />
61
+ </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.1",
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",
@@ -40,9 +40,10 @@
40
40
  "@gluhar/core": "^2.0.0",
41
41
  "@gluhar/i18n": "^2.0.0",
42
42
  "@gluhar/sanity": "^2.0.3",
43
- "@gluhar/theme": "^2.0.2",
43
+ "@gluhar/theme": "^2.0.3",
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": "eface90f2dee58d45f4d217f2d3de388f67ed3fc"
62
63
  }