@gluhar/app 5.1.5 → 5.2.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 +11 -0
- package/dist/module.cjs +5 -0
- package/dist/module.d.mts +21 -0
- package/dist/module.d.ts +21 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +59 -0
- package/dist/runtime/components/GContactLink.vue +49 -0
- package/dist/runtime/components/GLenisScroller.vue +40 -0
- package/dist/runtime/components/GluharLogo.vue +46 -0
- package/dist/runtime/components/SanityImg.vue +68 -0
- package/dist/runtime/composables/useLenis.d.ts +370 -0
- package/dist/runtime/composables/useLenis.js +101 -0
- package/dist/runtime/composables/useSanityPage.d.ts +23 -0
- package/dist/runtime/composables/useSanityPage.js +60 -0
- package/dist/runtime/composables/useSeo.d.ts +2 -0
- package/dist/runtime/composables/useSeo.js +34 -0
- package/dist/runtime/stores/useGStore.d.ts +80 -0
- package/dist/runtime/stores/useGStore.js +21 -0
- package/dist/runtime/types/index.d.ts +1 -0
- package/dist/runtime/types/index.js +0 -0
- package/dist/runtime/utils/seo.d.ts +3 -0
- package/dist/runtime/utils/seo.js +22 -0
- package/dist/types.d.mts +7 -0
- package/dist/types.d.ts +7 -0
- package/package.json +6 -7
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
|
+
# [5.2.0](https://github.com/gluharco/gluhar/compare/@gluhar/app@5.1.5...@gluhar/app@5.2.0) (2026-04-28)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### 🚀 Enhancements
|
|
10
|
+
|
|
11
|
+
- Bump minor ([97ce7ec](https://github.com/gluharco/gluhar/commit/97ce7ece5e0d16846269319bdce425d497895ff1))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [5.1.5](https://github.com/gluharco/gluhar/compare/@gluhar/app@5.1.4...@gluhar/app@5.1.5) (2026-03-23)
|
|
7
18
|
|
|
8
19
|
**📝 Note:** Version bump only for package @gluhar/app
|
package/dist/module.cjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
import { GluharI18nOptions } from '@gluhar/i18n';
|
|
3
|
+
import { GluharThemeOptions } from '@gluhar/theme';
|
|
4
|
+
import { GluharSanityOptions } from '@gluhar/sanity';
|
|
5
|
+
import { ModuleOptions } from 'v-gsap-nuxt';
|
|
6
|
+
import { ModuleOptions as ModuleOptions$1 } from '@nuxt/image';
|
|
7
|
+
import { ModuleOptions as ModuleOptions$2 } from 'dayjs-nuxt';
|
|
8
|
+
|
|
9
|
+
interface GluharAppOptions {
|
|
10
|
+
theme?: GluharThemeOptions | false;
|
|
11
|
+
i18n?: GluharI18nOptions | false;
|
|
12
|
+
sanity?: GluharSanityOptions | false;
|
|
13
|
+
vgsap?: (ModuleOptions & {
|
|
14
|
+
dev?: boolean;
|
|
15
|
+
}) | false;
|
|
16
|
+
image?: ModuleOptions$1 | false;
|
|
17
|
+
dayjs?: ModuleOptions$2 | false;
|
|
18
|
+
}
|
|
19
|
+
declare const _default: _nuxt_schema.NuxtModule<GluharAppOptions, GluharAppOptions, false>;
|
|
20
|
+
|
|
21
|
+
export { type GluharAppOptions, _default as default };
|
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
import { GluharI18nOptions } from '@gluhar/i18n';
|
|
3
|
+
import { GluharThemeOptions } from '@gluhar/theme';
|
|
4
|
+
import { GluharSanityOptions } from '@gluhar/sanity';
|
|
5
|
+
import { ModuleOptions } from 'v-gsap-nuxt';
|
|
6
|
+
import { ModuleOptions as ModuleOptions$1 } from '@nuxt/image';
|
|
7
|
+
import { ModuleOptions as ModuleOptions$2 } from 'dayjs-nuxt';
|
|
8
|
+
|
|
9
|
+
interface GluharAppOptions {
|
|
10
|
+
theme?: GluharThemeOptions | false;
|
|
11
|
+
i18n?: GluharI18nOptions | false;
|
|
12
|
+
sanity?: GluharSanityOptions | false;
|
|
13
|
+
vgsap?: (ModuleOptions & {
|
|
14
|
+
dev?: boolean;
|
|
15
|
+
}) | false;
|
|
16
|
+
image?: ModuleOptions$1 | false;
|
|
17
|
+
dayjs?: ModuleOptions$2 | false;
|
|
18
|
+
}
|
|
19
|
+
declare const _default: _nuxt_schema.NuxtModule<GluharAppOptions, GluharAppOptions, false>;
|
|
20
|
+
|
|
21
|
+
export { type GluharAppOptions, _default as default };
|
package/dist/module.json
ADDED
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { defineNuxtModule, createResolver, installModule, addImportsDir, addComponentsDir } from '@nuxt/kit';
|
|
2
|
+
import defu from 'defu';
|
|
3
|
+
|
|
4
|
+
const module = defineNuxtModule({
|
|
5
|
+
meta: {
|
|
6
|
+
name: "@gluhar/app",
|
|
7
|
+
configKey: "gluhar"
|
|
8
|
+
},
|
|
9
|
+
// Default configuration options of the Nuxt module
|
|
10
|
+
defaults: {},
|
|
11
|
+
async setup(options, nuxt) {
|
|
12
|
+
const { resolve } = createResolver(import.meta.url);
|
|
13
|
+
const { theme, i18n, sanity, vgsap, image, dayjs } = options;
|
|
14
|
+
await installModule("@gluhar/core");
|
|
15
|
+
await installModule("@pinia/nuxt");
|
|
16
|
+
if (theme !== false) {
|
|
17
|
+
await installModule("@gluhar/theme", theme);
|
|
18
|
+
}
|
|
19
|
+
if (i18n !== false) {
|
|
20
|
+
await installModule("@gluhar/i18n", i18n);
|
|
21
|
+
}
|
|
22
|
+
if (sanity !== false && i18n !== false) {
|
|
23
|
+
await installModule("@gluhar/sanity", sanity);
|
|
24
|
+
}
|
|
25
|
+
if (vgsap !== false) {
|
|
26
|
+
if (vgsap?.dev) {
|
|
27
|
+
await installModule("@gluhar/v-gsap-nuxt", vgsap);
|
|
28
|
+
} else {
|
|
29
|
+
await installModule("v-gsap-nuxt", vgsap);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (image !== false) {
|
|
33
|
+
await installModule("@nuxt/image", image);
|
|
34
|
+
}
|
|
35
|
+
if (dayjs !== false) {
|
|
36
|
+
await installModule("dayjs-nuxt", dayjs);
|
|
37
|
+
}
|
|
38
|
+
addImportsDir(resolve("runtime/composables"));
|
|
39
|
+
addComponentsDir({ path: resolve("runtime/components") });
|
|
40
|
+
addImportsDir(resolve("runtime/stores"));
|
|
41
|
+
addImportsDir(resolve("runtime/utils"));
|
|
42
|
+
nuxt.options.vite = defu(nuxt.options.vite, {
|
|
43
|
+
esbuild: {
|
|
44
|
+
legalComments: "none"
|
|
45
|
+
},
|
|
46
|
+
build: {
|
|
47
|
+
terserOptions: {
|
|
48
|
+
format: {
|
|
49
|
+
comments: false
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
nuxt.options.experimental.watcher = "parcel";
|
|
55
|
+
nuxt.options.devtools.enabled = false;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
export { module as default };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useResponsive, computed, ref } from "#imports";
|
|
3
|
+
|
|
4
|
+
const props = defineProps<{
|
|
5
|
+
phone?: string;
|
|
6
|
+
email?: string;
|
|
7
|
+
onCopy?: () => void;
|
|
8
|
+
}>();
|
|
9
|
+
|
|
10
|
+
const defaultCursorText = "Copy to clipboard";
|
|
11
|
+
const cursorText = ref(defaultCursorText);
|
|
12
|
+
|
|
13
|
+
const { isMobile } = useResponsive();
|
|
14
|
+
|
|
15
|
+
const href = computed(() => {
|
|
16
|
+
if (!isMobile.value) return undefined;
|
|
17
|
+
return props.phone ? `tel:${props.phone}` : `mailto:${props.email}`;
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const handleClick = async (isPhone: boolean) => {
|
|
21
|
+
const value = isPhone ? props.phone : props.email;
|
|
22
|
+
|
|
23
|
+
if (isMobile.value) return;
|
|
24
|
+
cursorText.value = "Copied!";
|
|
25
|
+
|
|
26
|
+
await navigator.clipboard.writeText(value!);
|
|
27
|
+
|
|
28
|
+
props.onCopy?.();
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const onMouseLeave = () => {
|
|
32
|
+
cursorText.value = defaultCursorText;
|
|
33
|
+
};
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<template>
|
|
37
|
+
<a :href v-bind="$attrs" v-if="isMobile">
|
|
38
|
+
<slot> {{ phone || email }} </slot>
|
|
39
|
+
</a>
|
|
40
|
+
<div
|
|
41
|
+
:data-cursor-text="cursorText"
|
|
42
|
+
@mousedown="handleClick(!!phone)"
|
|
43
|
+
@mouseleave="onMouseLeave"
|
|
44
|
+
v-bind="$attrs"
|
|
45
|
+
v-else
|
|
46
|
+
>
|
|
47
|
+
<slot> {{ phone || email }} </slot>
|
|
48
|
+
</div>
|
|
49
|
+
</template>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useResizeObserver } from "@vueuse/core";
|
|
3
|
+
import { ref, type CSSProperties } from "vue";
|
|
4
|
+
import { useLenis } from "#imports";
|
|
5
|
+
|
|
6
|
+
defineProps<{
|
|
7
|
+
contentClass?: string;
|
|
8
|
+
contentStyle?: CSSProperties;
|
|
9
|
+
}>();
|
|
10
|
+
|
|
11
|
+
const scrollerRef = ref<HTMLDivElement>();
|
|
12
|
+
const contentRef = ref<HTMLDivElement>();
|
|
13
|
+
|
|
14
|
+
const { lenis } = useLenis(scrollerRef);
|
|
15
|
+
|
|
16
|
+
const prevHeight = ref(0);
|
|
17
|
+
|
|
18
|
+
useResizeObserver(contentRef, (entries) => {
|
|
19
|
+
const entry = entries[0];
|
|
20
|
+
const { height } = entry.contentRect;
|
|
21
|
+
|
|
22
|
+
if (height === prevHeight.value) return;
|
|
23
|
+
|
|
24
|
+
prevHeight.value = height;
|
|
25
|
+
lenis.value?.resize();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
defineExpose({
|
|
29
|
+
lenis,
|
|
30
|
+
scrollerRef,
|
|
31
|
+
});
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<template>
|
|
35
|
+
<div class="lenis-scroller overflow-y-auto" ref="scrollerRef">
|
|
36
|
+
<div :class="contentClass" :style="contentStyle" ref="contentRef">
|
|
37
|
+
<slot />
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
</template>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<script setup lang="ts"></script>
|
|
2
|
+
|
|
3
|
+
<template>
|
|
4
|
+
<svg viewBox="0 0 262.1 89" class="fill-secondary-base">
|
|
5
|
+
<path
|
|
6
|
+
d="M229.5,28l-15.8-14.6l4.7-4.7l12.2,13.2L229.8,0h6.6l-0.9,21.9L249,6.8l4.7,4.7l-17,16.5l13.9,12.8l-4.7,4.7
|
|
7
|
+
l-12.8-13.9c-6.4,6.6-10.6,12.6-13.3,18.1c-2.9,6-4.2,12.8-4.2,23.3H209c0-11.1,1.3-19,4.9-26.2C217,40.3,222.9,34.7,229.5,28z
|
|
8
|
+
M262.1,31.3l-14.9-0.9v-4.8l14.9-0.9V31.3z"
|
|
9
|
+
/>
|
|
10
|
+
<path
|
|
11
|
+
d="M181.4,72.6V38.4h6.2l0.6,5c0.9-1.9,2.4-3.3,4.4-4.2c2-1,4.1-1.4,6.2-1.4c3.7,0,6.9,1.1,9.6,3.2l-2.9,5.6
|
|
12
|
+
c-1.9-1.6-4.1-2.4-6.7-2.4c-1.7,0-3.4,0.4-4.9,1.2s-2.7,1.9-3.7,3.4s-1.5,3.2-1.5,5.2v18.7L181.4,72.6L181.4,72.6z"
|
|
13
|
+
/>
|
|
14
|
+
<path
|
|
15
|
+
d="M153.5,73.5c-4,0-7.4-0.9-10.3-2.7c-2.8-1.9-4.2-4.7-4.2-8.4s1.3-6.4,4-8c2.7-1.7,6.1-2.5,10.1-2.5h13.5
|
|
16
|
+
c-0.2-2.3-1.3-4.2-3.3-5.7c-2-1.4-4.4-2.2-7.2-2.2c-2.1,0-4,0.4-6,1.2c-1.9,0.8-3.4,2-4.4,3.4l-5.3-2.9c1.6-2.7,3.8-4.7,6.5-6.1
|
|
17
|
+
c2.8-1.4,5.9-2.2,9.1-2.2c3.1,0,6,0.6,8.7,1.7c2.8,1.1,5,2.8,6.7,5s2.6,4.8,2.6,7.8v14l0.3,6.5h-6.9l-0.6-5.2
|
|
18
|
+
c-1.1,2-2.9,3.5-5.2,4.6C159.4,73,156.7,73.5,153.5,73.5z M154.2,67c3.3,0,6.3-0.6,8.8-1.8c2.5-1.2,3.8-3.4,3.8-6.5v-1.1h-13.5
|
|
19
|
+
c-1.9,0-3.5,0.4-4.9,1.1c-1.3,0.8-2,1.9-2,3.5c0,1.7,0.8,2.9,2.4,3.7C150.4,66.7,152.2,67,154.2,67z"
|
|
20
|
+
/>
|
|
21
|
+
<path
|
|
22
|
+
d="M98.8,72.6V22.3h7.4v21.1c1-1.9,2.5-3.3,4.4-4.2c1.9-1,4.1-1.4,6.5-1.4c4.7,0,8.8,1.4,12.1,4.2s5,7.2,5,13.2v17.4h-7.5V55
|
|
23
|
+
c0-3.8-0.9-6.7-2.7-8.5c-1.9-1.8-4.2-2.8-7-2.8c-1.8,0-3.5,0.4-5.2,1.3c-1.6,0.9-3,2.2-4,3.9s-1.5,3.9-1.5,6.4v17.2L98.8,72.6
|
|
24
|
+
L98.8,72.6z"
|
|
25
|
+
/>
|
|
26
|
+
<path
|
|
27
|
+
d="M73.1,73.2c-4.7,0-8.8-1.4-12.1-4.2c-3.3-2.8-5-7.2-5-13.2V38.4h7.5v17.5c0,3.8,0.9,6.7,2.7,8.5c1.9,1.8,4.2,2.8,7,2.8
|
|
28
|
+
c1.8,0,3.5-0.4,5.2-1.3c1.6-0.9,2.9-2.2,3.9-3.9c1.1-1.8,1.6-3.9,1.6-6.5V38.4h7.4v34.2h-6.6l-0.6-5c-1,1.9-2.5,3.3-4.5,4.2
|
|
29
|
+
S75.5,73.2,73.1,73.2z"
|
|
30
|
+
/>
|
|
31
|
+
<path d="M50,72.6h-7.4V22.3H50V72.6z" />
|
|
32
|
+
<path
|
|
33
|
+
d="M19.8,89c-4.1,0-7.7-0.4-10.6-1.3c-3-0.9-5.3-2.6-6.9-5.2c-1-1.6-1.5-3.4-1.5-5.3c0-1.5,0.3-2.8,0.9-4.1
|
|
34
|
+
c0.6-1.2,1.5-2.2,2.7-2.9c-1.4-0.5-2.5-1.3-3.3-2.4C0.4,66.7,0,65.4,0,63.9c0-1.6,0.5-3,1.4-4.2c1-1.2,2.3-2,3.9-2.4
|
|
35
|
+
c-1-0.9-1.7-1.9-2.2-3.2c-0.5-1.2-0.8-2.5-0.8-3.7c0-2.8,0.8-5.2,2.5-7.2c1.6-1.9,3.8-3.3,6.5-4.1c2.7-0.9,5.6-1.2,8.5-1.1L37,38.3
|
|
36
|
+
v0.8v3.7v0.9l-3.4-0.1l-1.9-0.1c1.3,0.8,2.3,1.8,3.1,3S36,49,36,50.4c0,2.8-0.8,5.1-2.4,7c-1.6,1.9-3.7,3.3-6.2,4.3
|
|
37
|
+
c-2.5,0.9-5.2,1.4-8,1.4c-2.4,0-4.8-0.3-7.2-1C11,61.8,9.9,61.6,9,61.6c-0.5,0-1,0.1-1.4,0.2c-0.5,0.2-0.8,0.5-1.1,0.9
|
|
38
|
+
c-0.2,0.3-0.4,0.7-0.4,1.1c0,0.6,0.3,1.2,0.9,1.7c0.7,0.5,1.6,0.7,2.8,0.7H19c5.5,0,10,0.7,13.6,2.1c3.7,1.3,5.5,4.1,5.5,8.3
|
|
39
|
+
c0,3-0.9,5.4-2.8,7.2c-1.9,1.9-4.2,3.2-7,4C25.6,88.6,22.7,89,19.8,89z M19.3,57.2c2.3,0,4.5-0.6,6.5-1.7c2-1.1,2.9-2.8,2.9-5
|
|
40
|
+
c0-2.1-0.9-3.7-2.8-4.9c-1.9-1.1-4.1-1.7-6.7-1.7s-4.9,0.6-6.7,1.7c-1.9,1.1-2.8,2.8-2.8,4.9c0,2.3,1,4,2.9,5.1
|
|
41
|
+
C14.6,56.6,16.9,57.2,19.3,57.2z M19.7,82.7c3.1,0,5.7-0.6,7.8-1.7c2.2-1.1,3.2-2.7,3.2-4.8c0-1.3-0.5-2.3-1.6-2.8s-2.4-0.9-4.1-1.1
|
|
42
|
+
c-0.8-0.1-2-0.1-3.5-0.1h-2.4h-9c-0.9,0.4-1.5,1-2,1.7s-0.7,1.5-0.7,2.3c0,1.1,0.4,2.1,1.1,3c0.9,1.1,2.4,2,4.5,2.6
|
|
43
|
+
C15.1,82.4,17.3,82.7,19.7,82.7z"
|
|
44
|
+
/>
|
|
45
|
+
</svg>
|
|
46
|
+
</template>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, ref, useMessages } from "#imports";
|
|
3
|
+
import type { LocaleString } from "@gluhar/i18n/types";
|
|
4
|
+
import type { SanityImage } from "@gluhar/sanity/types";
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
import imageUrlBuilder from "@sanity/image-url/lib/browser/image-url.esm"; // INFO this is a strange fix
|
|
7
|
+
// import imageUrlBuilder from "@sanity/image-url";
|
|
8
|
+
import type { CropMode, ImageFormat } from "@sanity/image-url/lib/types/types";
|
|
9
|
+
import sanityConfig from "~/config/sanity.config";
|
|
10
|
+
|
|
11
|
+
const props = defineProps<{
|
|
12
|
+
image?: SanityImage;
|
|
13
|
+
alt?: LocaleString;
|
|
14
|
+
by?: "width" | "height" | "both";
|
|
15
|
+
width?: number;
|
|
16
|
+
height?: number;
|
|
17
|
+
format?: ImageFormat | null;
|
|
18
|
+
crop?: CropMode;
|
|
19
|
+
dpr?: number;
|
|
20
|
+
}>();
|
|
21
|
+
|
|
22
|
+
const { l } = useMessages();
|
|
23
|
+
|
|
24
|
+
const builder = imageUrlBuilder(sanityConfig);
|
|
25
|
+
const urlFor = (source: SanityImage) => builder.image(source);
|
|
26
|
+
|
|
27
|
+
const imgRef = ref<HTMLImageElement | null>(null);
|
|
28
|
+
const src = computed(() => {
|
|
29
|
+
const { width, height } = imgRef.value?.getBoundingClientRect() || {
|
|
30
|
+
width: undefined,
|
|
31
|
+
height: undefined,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
if (!props.image?.asset || (!width && !height)) return undefined;
|
|
35
|
+
|
|
36
|
+
let url = urlFor(props.image);
|
|
37
|
+
|
|
38
|
+
if (props.width) url = url.width(props.width);
|
|
39
|
+
else if (width && (props.by === "width" || !props.by))
|
|
40
|
+
url = url.width(Math.ceil(width));
|
|
41
|
+
|
|
42
|
+
if (props.height) url = url.height(props.height);
|
|
43
|
+
else if (height && (props.by === "height" || !props.by))
|
|
44
|
+
url = url.height(Math.ceil(height));
|
|
45
|
+
|
|
46
|
+
if (props.crop) url = url.fit("crop").crop(props.crop);
|
|
47
|
+
|
|
48
|
+
url = url.format(props.format ?? "webp");
|
|
49
|
+
url = url.quality(100);
|
|
50
|
+
|
|
51
|
+
url = url.dpr(
|
|
52
|
+
props.dpr || typeof window !== "undefined" ? window.devicePixelRatio : 1,
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
return url.url();
|
|
56
|
+
});
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<template>
|
|
60
|
+
<img
|
|
61
|
+
class="object-cover"
|
|
62
|
+
:style="{ aspectRatio: image?.asset?.metadata?.dimensions?.aspectRatio }"
|
|
63
|
+
:src
|
|
64
|
+
:alt="l(alt) || l(image.caption) || l(image.alt)"
|
|
65
|
+
ref="imgRef"
|
|
66
|
+
v-if="image"
|
|
67
|
+
/>
|
|
68
|
+
</template>
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import Lenis from "lenis";
|
|
2
|
+
import { type Ref } from "vue";
|
|
3
|
+
interface LenisOptions {
|
|
4
|
+
wrapper?: HTMLElement | string;
|
|
5
|
+
content?: HTMLElement;
|
|
6
|
+
lerp?: number;
|
|
7
|
+
duration?: number;
|
|
8
|
+
orientation?: "vertical" | "horizontal";
|
|
9
|
+
gestureOrientation?: "vertical" | "horizontal" | "both";
|
|
10
|
+
smoothWheel?: boolean;
|
|
11
|
+
smoothTouch?: boolean;
|
|
12
|
+
wheelMultiplier?: number;
|
|
13
|
+
touchMultiplier?: number;
|
|
14
|
+
normalizeWheel?: boolean;
|
|
15
|
+
easing?: (t: number) => number;
|
|
16
|
+
}
|
|
17
|
+
export declare const useLenis: (wrapperOrOptions?: string | HTMLElement | Ref<HTMLElement | undefined> | LenisOptions) => {
|
|
18
|
+
lenis: Ref<{
|
|
19
|
+
isTouching?: boolean | undefined;
|
|
20
|
+
time: number;
|
|
21
|
+
userData: import("lenis").UserData;
|
|
22
|
+
lastVelocity: number;
|
|
23
|
+
velocity: number;
|
|
24
|
+
direction: 1 | -1 | 0;
|
|
25
|
+
options: {
|
|
26
|
+
wrapper: Window | HTMLElement | Element;
|
|
27
|
+
content: HTMLElement | Element;
|
|
28
|
+
eventsTarget: Window | HTMLElement | Element;
|
|
29
|
+
smoothWheel: boolean;
|
|
30
|
+
syncTouch: boolean;
|
|
31
|
+
syncTouchLerp: number;
|
|
32
|
+
touchInertiaExponent: number;
|
|
33
|
+
lerp: number;
|
|
34
|
+
infinite: boolean;
|
|
35
|
+
orientation: import("lenis").Orientation;
|
|
36
|
+
gestureOrientation: import("lenis").GestureOrientation;
|
|
37
|
+
touchMultiplier: number;
|
|
38
|
+
wheelMultiplier: number;
|
|
39
|
+
autoResize: boolean;
|
|
40
|
+
overscroll: boolean;
|
|
41
|
+
autoRaf: boolean;
|
|
42
|
+
anchors: boolean | {
|
|
43
|
+
offset?: number | undefined;
|
|
44
|
+
immediate?: boolean | undefined;
|
|
45
|
+
lock?: boolean | undefined;
|
|
46
|
+
duration?: number | undefined;
|
|
47
|
+
easing?: import("lenis").EasingFunction | undefined;
|
|
48
|
+
lerp?: number | undefined;
|
|
49
|
+
onStart?: ((lenis: Lenis) => void) | undefined;
|
|
50
|
+
onComplete?: ((lenis: Lenis) => void) | undefined;
|
|
51
|
+
force?: boolean | undefined;
|
|
52
|
+
programmatic?: boolean | undefined;
|
|
53
|
+
userData?: import("lenis").UserData | undefined;
|
|
54
|
+
};
|
|
55
|
+
autoToggle: boolean;
|
|
56
|
+
allowNestedScroll: boolean;
|
|
57
|
+
__experimental__naiveDimensions: boolean;
|
|
58
|
+
virtualScroll?: ((data: import("lenis").VirtualScrollData) => boolean) | undefined;
|
|
59
|
+
duration?: number | undefined;
|
|
60
|
+
easing?: import("lenis").EasingFunction | undefined;
|
|
61
|
+
prevent?: ((node: HTMLElement) => boolean) | undefined;
|
|
62
|
+
};
|
|
63
|
+
targetScroll: number;
|
|
64
|
+
animatedScroll: number;
|
|
65
|
+
readonly dimensions: {
|
|
66
|
+
width: number;
|
|
67
|
+
height: number;
|
|
68
|
+
scrollHeight: number;
|
|
69
|
+
scrollWidth: number;
|
|
70
|
+
destroy: () => void;
|
|
71
|
+
resize: () => void;
|
|
72
|
+
onWrapperResize: () => void;
|
|
73
|
+
onContentResize: () => void;
|
|
74
|
+
readonly limit: {
|
|
75
|
+
x: number;
|
|
76
|
+
y: number;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
destroy: () => void;
|
|
80
|
+
on: {
|
|
81
|
+
(event: "scroll", callback: import("lenis").ScrollCallback): () => void;
|
|
82
|
+
(event: "virtual-scroll", callback: import("lenis").VirtualScrollCallback): () => void;
|
|
83
|
+
};
|
|
84
|
+
off: {
|
|
85
|
+
(event: "scroll", callback: import("lenis").ScrollCallback): void;
|
|
86
|
+
(event: "virtual-scroll", callback: import("lenis").VirtualScrollCallback): void;
|
|
87
|
+
};
|
|
88
|
+
resize: () => void;
|
|
89
|
+
start: () => void;
|
|
90
|
+
stop: () => void;
|
|
91
|
+
raf: (time: number) => void;
|
|
92
|
+
scrollTo: (target: number | string | HTMLElement, { offset, immediate, lock, duration, easing, lerp, onStart, onComplete, force, programmatic, userData, }?: import("lenis").ScrollToOptions) => void;
|
|
93
|
+
readonly rootElement: HTMLElement;
|
|
94
|
+
readonly limit: number;
|
|
95
|
+
readonly isHorizontal: boolean;
|
|
96
|
+
readonly actualScroll: number;
|
|
97
|
+
readonly scroll: number;
|
|
98
|
+
readonly progress: number;
|
|
99
|
+
isScrolling: import("lenis").Scrolling;
|
|
100
|
+
isStopped: boolean;
|
|
101
|
+
isLocked: boolean;
|
|
102
|
+
readonly isSmooth: boolean;
|
|
103
|
+
readonly className: string;
|
|
104
|
+
} | null, Lenis | {
|
|
105
|
+
isTouching?: boolean | undefined;
|
|
106
|
+
time: number;
|
|
107
|
+
userData: import("lenis").UserData;
|
|
108
|
+
lastVelocity: number;
|
|
109
|
+
velocity: number;
|
|
110
|
+
direction: 1 | -1 | 0;
|
|
111
|
+
options: {
|
|
112
|
+
wrapper: Window | HTMLElement | Element;
|
|
113
|
+
content: HTMLElement | Element;
|
|
114
|
+
eventsTarget: Window | HTMLElement | Element;
|
|
115
|
+
smoothWheel: boolean;
|
|
116
|
+
syncTouch: boolean;
|
|
117
|
+
syncTouchLerp: number;
|
|
118
|
+
touchInertiaExponent: number;
|
|
119
|
+
lerp: number;
|
|
120
|
+
infinite: boolean;
|
|
121
|
+
orientation: import("lenis").Orientation;
|
|
122
|
+
gestureOrientation: import("lenis").GestureOrientation;
|
|
123
|
+
touchMultiplier: number;
|
|
124
|
+
wheelMultiplier: number;
|
|
125
|
+
autoResize: boolean;
|
|
126
|
+
overscroll: boolean;
|
|
127
|
+
autoRaf: boolean;
|
|
128
|
+
anchors: boolean | {
|
|
129
|
+
offset?: number | undefined;
|
|
130
|
+
immediate?: boolean | undefined;
|
|
131
|
+
lock?: boolean | undefined;
|
|
132
|
+
duration?: number | undefined;
|
|
133
|
+
easing?: import("lenis").EasingFunction | undefined;
|
|
134
|
+
lerp?: number | undefined;
|
|
135
|
+
onStart?: ((lenis: Lenis) => void) | undefined;
|
|
136
|
+
onComplete?: ((lenis: Lenis) => void) | undefined;
|
|
137
|
+
force?: boolean | undefined;
|
|
138
|
+
programmatic?: boolean | undefined;
|
|
139
|
+
userData?: import("lenis").UserData | undefined;
|
|
140
|
+
};
|
|
141
|
+
autoToggle: boolean;
|
|
142
|
+
allowNestedScroll: boolean;
|
|
143
|
+
__experimental__naiveDimensions: boolean;
|
|
144
|
+
virtualScroll?: ((data: import("lenis").VirtualScrollData) => boolean) | undefined;
|
|
145
|
+
duration?: number | undefined;
|
|
146
|
+
easing?: import("lenis").EasingFunction | undefined;
|
|
147
|
+
prevent?: ((node: HTMLElement) => boolean) | undefined;
|
|
148
|
+
};
|
|
149
|
+
targetScroll: number;
|
|
150
|
+
animatedScroll: number;
|
|
151
|
+
readonly dimensions: {
|
|
152
|
+
width: number;
|
|
153
|
+
height: number;
|
|
154
|
+
scrollHeight: number;
|
|
155
|
+
scrollWidth: number;
|
|
156
|
+
destroy: () => void;
|
|
157
|
+
resize: () => void;
|
|
158
|
+
onWrapperResize: () => void;
|
|
159
|
+
onContentResize: () => void;
|
|
160
|
+
readonly limit: {
|
|
161
|
+
x: number;
|
|
162
|
+
y: number;
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
destroy: () => void;
|
|
166
|
+
on: {
|
|
167
|
+
(event: "scroll", callback: import("lenis").ScrollCallback): () => void;
|
|
168
|
+
(event: "virtual-scroll", callback: import("lenis").VirtualScrollCallback): () => void;
|
|
169
|
+
};
|
|
170
|
+
off: {
|
|
171
|
+
(event: "scroll", callback: import("lenis").ScrollCallback): void;
|
|
172
|
+
(event: "virtual-scroll", callback: import("lenis").VirtualScrollCallback): void;
|
|
173
|
+
};
|
|
174
|
+
resize: () => void;
|
|
175
|
+
start: () => void;
|
|
176
|
+
stop: () => void;
|
|
177
|
+
raf: (time: number) => void;
|
|
178
|
+
scrollTo: (target: number | string | HTMLElement, { offset, immediate, lock, duration, easing, lerp, onStart, onComplete, force, programmatic, userData, }?: import("lenis").ScrollToOptions) => void;
|
|
179
|
+
readonly rootElement: HTMLElement;
|
|
180
|
+
readonly limit: number;
|
|
181
|
+
readonly isHorizontal: boolean;
|
|
182
|
+
readonly actualScroll: number;
|
|
183
|
+
readonly scroll: number;
|
|
184
|
+
readonly progress: number;
|
|
185
|
+
isScrolling: import("lenis").Scrolling;
|
|
186
|
+
isStopped: boolean;
|
|
187
|
+
isLocked: boolean;
|
|
188
|
+
readonly isSmooth: boolean;
|
|
189
|
+
readonly className: string;
|
|
190
|
+
} | null>;
|
|
191
|
+
destroy: () => void;
|
|
192
|
+
createInstance?: undefined;
|
|
193
|
+
} | {
|
|
194
|
+
lenis: Ref<{
|
|
195
|
+
isTouching?: boolean | undefined;
|
|
196
|
+
time: number;
|
|
197
|
+
userData: import("lenis").UserData;
|
|
198
|
+
lastVelocity: number;
|
|
199
|
+
velocity: number;
|
|
200
|
+
direction: 1 | -1 | 0;
|
|
201
|
+
options: {
|
|
202
|
+
wrapper: Window | HTMLElement | Element;
|
|
203
|
+
content: HTMLElement | Element;
|
|
204
|
+
eventsTarget: Window | HTMLElement | Element;
|
|
205
|
+
smoothWheel: boolean;
|
|
206
|
+
syncTouch: boolean;
|
|
207
|
+
syncTouchLerp: number;
|
|
208
|
+
touchInertiaExponent: number;
|
|
209
|
+
lerp: number;
|
|
210
|
+
infinite: boolean;
|
|
211
|
+
orientation: import("lenis").Orientation;
|
|
212
|
+
gestureOrientation: import("lenis").GestureOrientation;
|
|
213
|
+
touchMultiplier: number;
|
|
214
|
+
wheelMultiplier: number;
|
|
215
|
+
autoResize: boolean;
|
|
216
|
+
overscroll: boolean;
|
|
217
|
+
autoRaf: boolean;
|
|
218
|
+
anchors: boolean | {
|
|
219
|
+
offset?: number | undefined;
|
|
220
|
+
immediate?: boolean | undefined;
|
|
221
|
+
lock?: boolean | undefined;
|
|
222
|
+
duration?: number | undefined;
|
|
223
|
+
easing?: import("lenis").EasingFunction | undefined;
|
|
224
|
+
lerp?: number | undefined;
|
|
225
|
+
onStart?: ((lenis: Lenis) => void) | undefined;
|
|
226
|
+
onComplete?: ((lenis: Lenis) => void) | undefined;
|
|
227
|
+
force?: boolean | undefined;
|
|
228
|
+
programmatic?: boolean | undefined;
|
|
229
|
+
userData?: import("lenis").UserData | undefined;
|
|
230
|
+
};
|
|
231
|
+
autoToggle: boolean;
|
|
232
|
+
allowNestedScroll: boolean;
|
|
233
|
+
__experimental__naiveDimensions: boolean;
|
|
234
|
+
virtualScroll?: ((data: import("lenis").VirtualScrollData) => boolean) | undefined;
|
|
235
|
+
duration?: number | undefined;
|
|
236
|
+
easing?: import("lenis").EasingFunction | undefined;
|
|
237
|
+
prevent?: ((node: HTMLElement) => boolean) | undefined;
|
|
238
|
+
};
|
|
239
|
+
targetScroll: number;
|
|
240
|
+
animatedScroll: number;
|
|
241
|
+
readonly dimensions: {
|
|
242
|
+
width: number;
|
|
243
|
+
height: number;
|
|
244
|
+
scrollHeight: number;
|
|
245
|
+
scrollWidth: number;
|
|
246
|
+
destroy: () => void;
|
|
247
|
+
resize: () => void;
|
|
248
|
+
onWrapperResize: () => void;
|
|
249
|
+
onContentResize: () => void;
|
|
250
|
+
readonly limit: {
|
|
251
|
+
x: number;
|
|
252
|
+
y: number;
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
destroy: () => void;
|
|
256
|
+
on: {
|
|
257
|
+
(event: "scroll", callback: import("lenis").ScrollCallback): () => void;
|
|
258
|
+
(event: "virtual-scroll", callback: import("lenis").VirtualScrollCallback): () => void;
|
|
259
|
+
};
|
|
260
|
+
off: {
|
|
261
|
+
(event: "scroll", callback: import("lenis").ScrollCallback): void;
|
|
262
|
+
(event: "virtual-scroll", callback: import("lenis").VirtualScrollCallback): void;
|
|
263
|
+
};
|
|
264
|
+
resize: () => void;
|
|
265
|
+
start: () => void;
|
|
266
|
+
stop: () => void;
|
|
267
|
+
raf: (time: number) => void;
|
|
268
|
+
scrollTo: (target: number | string | HTMLElement, { offset, immediate, lock, duration, easing, lerp, onStart, onComplete, force, programmatic, userData, }?: import("lenis").ScrollToOptions) => void;
|
|
269
|
+
readonly rootElement: HTMLElement;
|
|
270
|
+
readonly limit: number;
|
|
271
|
+
readonly isHorizontal: boolean;
|
|
272
|
+
readonly actualScroll: number;
|
|
273
|
+
readonly scroll: number;
|
|
274
|
+
readonly progress: number;
|
|
275
|
+
isScrolling: import("lenis").Scrolling;
|
|
276
|
+
isStopped: boolean;
|
|
277
|
+
isLocked: boolean;
|
|
278
|
+
readonly isSmooth: boolean;
|
|
279
|
+
readonly className: string;
|
|
280
|
+
} | null, Lenis | {
|
|
281
|
+
isTouching?: boolean | undefined;
|
|
282
|
+
time: number;
|
|
283
|
+
userData: import("lenis").UserData;
|
|
284
|
+
lastVelocity: number;
|
|
285
|
+
velocity: number;
|
|
286
|
+
direction: 1 | -1 | 0;
|
|
287
|
+
options: {
|
|
288
|
+
wrapper: Window | HTMLElement | Element;
|
|
289
|
+
content: HTMLElement | Element;
|
|
290
|
+
eventsTarget: Window | HTMLElement | Element;
|
|
291
|
+
smoothWheel: boolean;
|
|
292
|
+
syncTouch: boolean;
|
|
293
|
+
syncTouchLerp: number;
|
|
294
|
+
touchInertiaExponent: number;
|
|
295
|
+
lerp: number;
|
|
296
|
+
infinite: boolean;
|
|
297
|
+
orientation: import("lenis").Orientation;
|
|
298
|
+
gestureOrientation: import("lenis").GestureOrientation;
|
|
299
|
+
touchMultiplier: number;
|
|
300
|
+
wheelMultiplier: number;
|
|
301
|
+
autoResize: boolean;
|
|
302
|
+
overscroll: boolean;
|
|
303
|
+
autoRaf: boolean;
|
|
304
|
+
anchors: boolean | {
|
|
305
|
+
offset?: number | undefined;
|
|
306
|
+
immediate?: boolean | undefined;
|
|
307
|
+
lock?: boolean | undefined;
|
|
308
|
+
duration?: number | undefined;
|
|
309
|
+
easing?: import("lenis").EasingFunction | undefined;
|
|
310
|
+
lerp?: number | undefined;
|
|
311
|
+
onStart?: ((lenis: Lenis) => void) | undefined;
|
|
312
|
+
onComplete?: ((lenis: Lenis) => void) | undefined;
|
|
313
|
+
force?: boolean | undefined;
|
|
314
|
+
programmatic?: boolean | undefined;
|
|
315
|
+
userData?: import("lenis").UserData | undefined;
|
|
316
|
+
};
|
|
317
|
+
autoToggle: boolean;
|
|
318
|
+
allowNestedScroll: boolean;
|
|
319
|
+
__experimental__naiveDimensions: boolean;
|
|
320
|
+
virtualScroll?: ((data: import("lenis").VirtualScrollData) => boolean) | undefined;
|
|
321
|
+
duration?: number | undefined;
|
|
322
|
+
easing?: import("lenis").EasingFunction | undefined;
|
|
323
|
+
prevent?: ((node: HTMLElement) => boolean) | undefined;
|
|
324
|
+
};
|
|
325
|
+
targetScroll: number;
|
|
326
|
+
animatedScroll: number;
|
|
327
|
+
readonly dimensions: {
|
|
328
|
+
width: number;
|
|
329
|
+
height: number;
|
|
330
|
+
scrollHeight: number;
|
|
331
|
+
scrollWidth: number;
|
|
332
|
+
destroy: () => void;
|
|
333
|
+
resize: () => void;
|
|
334
|
+
onWrapperResize: () => void;
|
|
335
|
+
onContentResize: () => void;
|
|
336
|
+
readonly limit: {
|
|
337
|
+
x: number;
|
|
338
|
+
y: number;
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
destroy: () => void;
|
|
342
|
+
on: {
|
|
343
|
+
(event: "scroll", callback: import("lenis").ScrollCallback): () => void;
|
|
344
|
+
(event: "virtual-scroll", callback: import("lenis").VirtualScrollCallback): () => void;
|
|
345
|
+
};
|
|
346
|
+
off: {
|
|
347
|
+
(event: "scroll", callback: import("lenis").ScrollCallback): void;
|
|
348
|
+
(event: "virtual-scroll", callback: import("lenis").VirtualScrollCallback): void;
|
|
349
|
+
};
|
|
350
|
+
resize: () => void;
|
|
351
|
+
start: () => void;
|
|
352
|
+
stop: () => void;
|
|
353
|
+
raf: (time: number) => void;
|
|
354
|
+
scrollTo: (target: number | string | HTMLElement, { offset, immediate, lock, duration, easing, lerp, onStart, onComplete, force, programmatic, userData, }?: import("lenis").ScrollToOptions) => void;
|
|
355
|
+
readonly rootElement: HTMLElement;
|
|
356
|
+
readonly limit: number;
|
|
357
|
+
readonly isHorizontal: boolean;
|
|
358
|
+
readonly actualScroll: number;
|
|
359
|
+
readonly scroll: number;
|
|
360
|
+
readonly progress: number;
|
|
361
|
+
isScrolling: import("lenis").Scrolling;
|
|
362
|
+
isStopped: boolean;
|
|
363
|
+
isLocked: boolean;
|
|
364
|
+
readonly isSmooth: boolean;
|
|
365
|
+
readonly className: string;
|
|
366
|
+
} | null>;
|
|
367
|
+
createInstance: (customOptions?: LenisOptions) => Lenis | null;
|
|
368
|
+
destroy: () => void;
|
|
369
|
+
};
|
|
370
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import Lenis from "lenis";
|
|
2
|
+
import { ScrollTrigger } from "gsap/ScrollTrigger";
|
|
3
|
+
import { computed, onMounted, onUnmounted, isRef, ref } from "vue";
|
|
4
|
+
import { useClientOnly, useGSAP, watch } from "#imports";
|
|
5
|
+
const globalLenis = ref(null);
|
|
6
|
+
const globalDestroy = () => {
|
|
7
|
+
if (globalLenis.value) {
|
|
8
|
+
globalLenis.value.destroy();
|
|
9
|
+
globalLenis.value = null;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
export const useLenis = (wrapperOrOptions) => {
|
|
13
|
+
const { isClient } = useClientOnly();
|
|
14
|
+
const gsap = useGSAP();
|
|
15
|
+
if (!wrapperOrOptions) {
|
|
16
|
+
return {
|
|
17
|
+
lenis: globalLenis,
|
|
18
|
+
destroy: globalDestroy
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const lenis = ref(null);
|
|
22
|
+
const options = computed(() => {
|
|
23
|
+
if (!isClient.value) return {};
|
|
24
|
+
if (typeof wrapperOrOptions === "string" || wrapperOrOptions instanceof HTMLElement) {
|
|
25
|
+
return { wrapper: wrapperOrOptions };
|
|
26
|
+
}
|
|
27
|
+
if (isRef(wrapperOrOptions)) {
|
|
28
|
+
return { wrapper: wrapperOrOptions.value };
|
|
29
|
+
}
|
|
30
|
+
return wrapperOrOptions || {};
|
|
31
|
+
});
|
|
32
|
+
const initLenis = (customOptions = {}) => {
|
|
33
|
+
if (!isClient.value) return null;
|
|
34
|
+
const currentOptions = options.value;
|
|
35
|
+
if (currentOptions.wrapper === void 0) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const lenisOptions = {
|
|
39
|
+
wrapper: window,
|
|
40
|
+
// Default to window/body instead of #scroller
|
|
41
|
+
...currentOptions,
|
|
42
|
+
...customOptions
|
|
43
|
+
};
|
|
44
|
+
let wrapper = lenisOptions.wrapper;
|
|
45
|
+
if (typeof wrapper === "string") {
|
|
46
|
+
wrapper = document.querySelector(wrapper) || window;
|
|
47
|
+
}
|
|
48
|
+
const lenisInstance = new Lenis({
|
|
49
|
+
...lenisOptions,
|
|
50
|
+
wrapper
|
|
51
|
+
});
|
|
52
|
+
lenisInstance.on("scroll", ScrollTrigger.update);
|
|
53
|
+
gsap.ticker.add((time) => {
|
|
54
|
+
lenisInstance.raf(time * 1e3);
|
|
55
|
+
});
|
|
56
|
+
gsap.ticker.lagSmoothing(0);
|
|
57
|
+
return lenisInstance;
|
|
58
|
+
};
|
|
59
|
+
const createInstance = (customOptions = {}) => {
|
|
60
|
+
const instance = initLenis(customOptions);
|
|
61
|
+
if (!lenis.value) {
|
|
62
|
+
lenis.value = instance;
|
|
63
|
+
}
|
|
64
|
+
return instance;
|
|
65
|
+
};
|
|
66
|
+
const destroy = () => {
|
|
67
|
+
if (lenis.value) {
|
|
68
|
+
lenis.value.destroy();
|
|
69
|
+
lenis.value = null;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
watch(
|
|
73
|
+
() => options.value.wrapper,
|
|
74
|
+
(newWrapper) => {
|
|
75
|
+
if (newWrapper && !lenis.value) {
|
|
76
|
+
lenis.value = initLenis();
|
|
77
|
+
if (newWrapper === "#scroller" || typeof newWrapper === "object" && newWrapper?.id === "scroller") {
|
|
78
|
+
globalLenis.value = lenis.value;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
{ immediate: true }
|
|
83
|
+
);
|
|
84
|
+
onMounted(() => {
|
|
85
|
+
if (!lenis.value) {
|
|
86
|
+
lenis.value = initLenis();
|
|
87
|
+
const currentWrapper = options.value.wrapper;
|
|
88
|
+
if (currentWrapper === "#scroller" || typeof currentWrapper === "object" && currentWrapper?.id === "scroller") {
|
|
89
|
+
globalLenis.value = lenis.value;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
onUnmounted(() => {
|
|
94
|
+
destroy();
|
|
95
|
+
});
|
|
96
|
+
return {
|
|
97
|
+
lenis,
|
|
98
|
+
createInstance,
|
|
99
|
+
destroy
|
|
100
|
+
};
|
|
101
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AsyncDataRequestStatus } from "#app";
|
|
2
|
+
import type { KeysOf, PickFrom } from "#app/composables/asyncData";
|
|
3
|
+
import type { SanityPage } from "@gluhar/sanity/types";
|
|
4
|
+
interface Page extends SanityPage {
|
|
5
|
+
_type: "page";
|
|
6
|
+
}
|
|
7
|
+
type PageTypeKeys = "page" | string;
|
|
8
|
+
type PageInterfaces = Record<PageTypeKeys, Page | SanityPage>;
|
|
9
|
+
type PageTypes<PI extends PageInterfaces> = Record<keyof PI, {
|
|
10
|
+
query: string;
|
|
11
|
+
slug: string;
|
|
12
|
+
type?: string;
|
|
13
|
+
}>;
|
|
14
|
+
export declare const useSanityPage: <PI extends PageInterfaces = {
|
|
15
|
+
page: Page;
|
|
16
|
+
}, PT extends PageTypes<PI> = PageTypes<PI>>(types?: PT, slug?: string | string[]) => Promise<{
|
|
17
|
+
page: import("vue").Ref<PickFrom<PI[Extract<keyof PT, string>], KeysOf<PI[Extract<keyof PT, string>]>> | null, PickFrom<PI[Extract<keyof PT, string>], KeysOf<PI[Extract<keyof PT, string>]>> | null>;
|
|
18
|
+
status: import("vue").Ref<AsyncDataRequestStatus, AsyncDataRequestStatus>;
|
|
19
|
+
} | {
|
|
20
|
+
page: import("vue").Ref<Page | null, Page | null>;
|
|
21
|
+
status: import("vue").Ref<AsyncDataRequestStatus, AsyncDataRequestStatus>;
|
|
22
|
+
}>;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getCanonicalUrl,
|
|
3
|
+
groq,
|
|
4
|
+
useHead,
|
|
5
|
+
useRoute,
|
|
6
|
+
useSanityQueryWithPreview
|
|
7
|
+
} from "#imports";
|
|
8
|
+
import { imageWithAsset, linkWithPage } from "@gluhar/sanity/query";
|
|
9
|
+
export const useSanityPage = async (types, slug) => {
|
|
10
|
+
const route = useRoute();
|
|
11
|
+
const s = slug ? slug : route.params.slug;
|
|
12
|
+
const sl = Array.isArray(s) ? s : [s];
|
|
13
|
+
if (types && sl.length > 1) {
|
|
14
|
+
for (const type in types) {
|
|
15
|
+
const options = types[type];
|
|
16
|
+
if (sl[0] === options.slug) {
|
|
17
|
+
const query2 = groq`
|
|
18
|
+
*[_type == "${type}" && slug.current == "${sl[1]}"]{
|
|
19
|
+
${options.query}
|
|
20
|
+
}[0]
|
|
21
|
+
`;
|
|
22
|
+
const { data: page2, status: status2 } = await useSanityQueryWithPreview(query2);
|
|
23
|
+
useHead({
|
|
24
|
+
link: [
|
|
25
|
+
{
|
|
26
|
+
rel: "canonical",
|
|
27
|
+
href: getCanonicalUrl(page2?.value)
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
});
|
|
31
|
+
return { page: page2, status: status2 };
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const pageQuery = groq`
|
|
36
|
+
...,
|
|
37
|
+
content[]{
|
|
38
|
+
...,
|
|
39
|
+
_ref != null => @-> {
|
|
40
|
+
...,
|
|
41
|
+
button{ ${linkWithPage} },
|
|
42
|
+
thumbnail{ ${imageWithAsset} },
|
|
43
|
+
image{ ${imageWithAsset} },
|
|
44
|
+
images[]{ ${imageWithAsset} },
|
|
45
|
+
bckg{ ${imageWithAsset} },
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
const query = groq`
|
|
50
|
+
*[_type == "page" && slug.current == "${sl[0] ? sl?.join("/") : "/"}"]{
|
|
51
|
+
${types?.page?.query ?? pageQuery}
|
|
52
|
+
}[0]
|
|
53
|
+
`;
|
|
54
|
+
const { data: page, status } = await useSanityQueryWithPreview(query);
|
|
55
|
+
if (page.value) page.value._type = "page";
|
|
56
|
+
useHead({
|
|
57
|
+
link: [{ rel: "canonical", href: getCanonicalUrl(page.value) }]
|
|
58
|
+
});
|
|
59
|
+
return { page, status };
|
|
60
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useGStore } from "../stores/useGStore.js";
|
|
2
|
+
import { useMessages } from "#imports";
|
|
3
|
+
import {
|
|
4
|
+
useSeoMeta,
|
|
5
|
+
useServerSeoMeta
|
|
6
|
+
} from "@unhead/vue";
|
|
7
|
+
export const useSeo = (seo) => {
|
|
8
|
+
const store = useGStore();
|
|
9
|
+
const { l } = useMessages();
|
|
10
|
+
const meta = {
|
|
11
|
+
title: l(store.defaultSeo?.title),
|
|
12
|
+
ogTitle: l(store.defaultSeo?.title),
|
|
13
|
+
description: l(store.defaultSeo?.description),
|
|
14
|
+
ogDescription: l(store.defaultSeo?.description),
|
|
15
|
+
ogImage: store.defaultSeo?.ogImage?.asset?.url,
|
|
16
|
+
twitterCard: "summary_large_image"
|
|
17
|
+
};
|
|
18
|
+
if (seo) {
|
|
19
|
+
const { title, description, ogImage } = seo;
|
|
20
|
+
if (title && l(title)) {
|
|
21
|
+
meta.title = l(title);
|
|
22
|
+
meta.ogTitle = l(title);
|
|
23
|
+
}
|
|
24
|
+
if (description && l(description)) {
|
|
25
|
+
meta.description = l(description);
|
|
26
|
+
meta.ogDescription = l(description);
|
|
27
|
+
}
|
|
28
|
+
if (ogImage && ogImage.asset?.url) {
|
|
29
|
+
meta.ogImage = ogImage.asset?.url;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
useServerSeoMeta(meta);
|
|
33
|
+
useSeoMeta(meta);
|
|
34
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { Seo } from "@gluhar/sanity/types";
|
|
2
|
+
export declare const useGStore: import("pinia").StoreDefinition<"gluhar", Pick<{
|
|
3
|
+
defaultSeo: import("vue").Ref<{
|
|
4
|
+
title?: import("@gluhar/i18n/types").LocaleString | undefined;
|
|
5
|
+
description?: import("@gluhar/i18n/types").LocaleString | undefined;
|
|
6
|
+
ogImage?: {
|
|
7
|
+
asset?: {
|
|
8
|
+
url: string;
|
|
9
|
+
} | undefined;
|
|
10
|
+
caption?: import("@gluhar/i18n/types").LocaleString | undefined;
|
|
11
|
+
alt?: import("@gluhar/i18n/types").LocaleString | undefined;
|
|
12
|
+
} | undefined;
|
|
13
|
+
}, Seo | {
|
|
14
|
+
title?: import("@gluhar/i18n/types").LocaleString | undefined;
|
|
15
|
+
description?: import("@gluhar/i18n/types").LocaleString | undefined;
|
|
16
|
+
ogImage?: {
|
|
17
|
+
asset?: {
|
|
18
|
+
url: string;
|
|
19
|
+
} | undefined;
|
|
20
|
+
caption?: import("@gluhar/i18n/types").LocaleString | undefined;
|
|
21
|
+
alt?: import("@gluhar/i18n/types").LocaleString | undefined;
|
|
22
|
+
} | undefined;
|
|
23
|
+
}>;
|
|
24
|
+
setDefaultSeo: (seo: Seo) => void;
|
|
25
|
+
mobileMenuActive: import("vue").Ref<boolean, boolean>;
|
|
26
|
+
toggleMobileMenu: () => void;
|
|
27
|
+
closeMobileMenu: () => void;
|
|
28
|
+
}, "defaultSeo" | "mobileMenuActive">, Pick<{
|
|
29
|
+
defaultSeo: import("vue").Ref<{
|
|
30
|
+
title?: import("@gluhar/i18n/types").LocaleString | undefined;
|
|
31
|
+
description?: import("@gluhar/i18n/types").LocaleString | undefined;
|
|
32
|
+
ogImage?: {
|
|
33
|
+
asset?: {
|
|
34
|
+
url: string;
|
|
35
|
+
} | undefined;
|
|
36
|
+
caption?: import("@gluhar/i18n/types").LocaleString | undefined;
|
|
37
|
+
alt?: import("@gluhar/i18n/types").LocaleString | undefined;
|
|
38
|
+
} | undefined;
|
|
39
|
+
}, Seo | {
|
|
40
|
+
title?: import("@gluhar/i18n/types").LocaleString | undefined;
|
|
41
|
+
description?: import("@gluhar/i18n/types").LocaleString | undefined;
|
|
42
|
+
ogImage?: {
|
|
43
|
+
asset?: {
|
|
44
|
+
url: string;
|
|
45
|
+
} | undefined;
|
|
46
|
+
caption?: import("@gluhar/i18n/types").LocaleString | undefined;
|
|
47
|
+
alt?: import("@gluhar/i18n/types").LocaleString | undefined;
|
|
48
|
+
} | undefined;
|
|
49
|
+
}>;
|
|
50
|
+
setDefaultSeo: (seo: Seo) => void;
|
|
51
|
+
mobileMenuActive: import("vue").Ref<boolean, boolean>;
|
|
52
|
+
toggleMobileMenu: () => void;
|
|
53
|
+
closeMobileMenu: () => void;
|
|
54
|
+
}, never>, Pick<{
|
|
55
|
+
defaultSeo: import("vue").Ref<{
|
|
56
|
+
title?: import("@gluhar/i18n/types").LocaleString | undefined;
|
|
57
|
+
description?: import("@gluhar/i18n/types").LocaleString | undefined;
|
|
58
|
+
ogImage?: {
|
|
59
|
+
asset?: {
|
|
60
|
+
url: string;
|
|
61
|
+
} | undefined;
|
|
62
|
+
caption?: import("@gluhar/i18n/types").LocaleString | undefined;
|
|
63
|
+
alt?: import("@gluhar/i18n/types").LocaleString | undefined;
|
|
64
|
+
} | undefined;
|
|
65
|
+
}, Seo | {
|
|
66
|
+
title?: import("@gluhar/i18n/types").LocaleString | undefined;
|
|
67
|
+
description?: import("@gluhar/i18n/types").LocaleString | undefined;
|
|
68
|
+
ogImage?: {
|
|
69
|
+
asset?: {
|
|
70
|
+
url: string;
|
|
71
|
+
} | undefined;
|
|
72
|
+
caption?: import("@gluhar/i18n/types").LocaleString | undefined;
|
|
73
|
+
alt?: import("@gluhar/i18n/types").LocaleString | undefined;
|
|
74
|
+
} | undefined;
|
|
75
|
+
}>;
|
|
76
|
+
setDefaultSeo: (seo: Seo) => void;
|
|
77
|
+
mobileMenuActive: import("vue").Ref<boolean, boolean>;
|
|
78
|
+
toggleMobileMenu: () => void;
|
|
79
|
+
closeMobileMenu: () => void;
|
|
80
|
+
}, "setDefaultSeo" | "toggleMobileMenu" | "closeMobileMenu">>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineStore, ref } from "#imports";
|
|
2
|
+
export const useGStore = defineStore("gluhar", () => {
|
|
3
|
+
const defaultSeo = ref({});
|
|
4
|
+
const setDefaultSeo = (seo) => {
|
|
5
|
+
defaultSeo.value = seo;
|
|
6
|
+
};
|
|
7
|
+
const mobileMenuActive = ref(false);
|
|
8
|
+
const toggleMobileMenu = () => {
|
|
9
|
+
mobileMenuActive.value = !mobileMenuActive.value;
|
|
10
|
+
};
|
|
11
|
+
const closeMobileMenu = () => {
|
|
12
|
+
mobileMenuActive.value = false;
|
|
13
|
+
};
|
|
14
|
+
return {
|
|
15
|
+
defaultSeo,
|
|
16
|
+
setDefaultSeo,
|
|
17
|
+
mobileMenuActive,
|
|
18
|
+
toggleMobileMenu,
|
|
19
|
+
closeMobileMenu
|
|
20
|
+
};
|
|
21
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useRuntimeConfig } from "#imports";
|
|
2
|
+
import { envMode } from "@gluhar/core/utils/common";
|
|
3
|
+
export const getCanonicalUrl = (page) => {
|
|
4
|
+
const prod = envMode() === "prod";
|
|
5
|
+
const config = useRuntimeConfig().public;
|
|
6
|
+
const websiteUrl = (prod ? config.baseUrl?.toString() : config.devUrl?.toString()) || "http://localhost:3000";
|
|
7
|
+
if (!page?.slug) return websiteUrl;
|
|
8
|
+
const { _type } = page;
|
|
9
|
+
const slug = page.slug.current;
|
|
10
|
+
const path = _type === "page" ? slug : `${_type}s/${slug}`;
|
|
11
|
+
const url = new URL(path, websiteUrl);
|
|
12
|
+
return url.toString();
|
|
13
|
+
};
|
|
14
|
+
export const defaultSeoQuery = `
|
|
15
|
+
*[_id == "defaultSeo"]{
|
|
16
|
+
...,
|
|
17
|
+
ogImage{
|
|
18
|
+
...,
|
|
19
|
+
asset->
|
|
20
|
+
}
|
|
21
|
+
}[0]
|
|
22
|
+
`;
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { NuxtModule } from '@nuxt/schema'
|
|
2
|
+
|
|
3
|
+
import type { default as Module } from './module.js'
|
|
4
|
+
|
|
5
|
+
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
6
|
+
|
|
7
|
+
export { type GluharAppOptions, default } from './module.js'
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { NuxtModule } from '@nuxt/schema'
|
|
2
|
+
|
|
3
|
+
import type { default as Module } from './module'
|
|
4
|
+
|
|
5
|
+
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
6
|
+
|
|
7
|
+
export { type GluharAppOptions, default } from './module'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gluhar/app",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.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",
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
"scripts": {
|
|
29
29
|
"gluhar": "npm run gluhar --prefix ../.. -- --cwd=$PWD",
|
|
30
30
|
"build": "npm run gluhar build -- -t module",
|
|
31
|
-
"prepack": "npm run build",
|
|
32
31
|
"dev": "nuxi dev playground",
|
|
33
32
|
"dev:build": "nuxi build playground",
|
|
34
33
|
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
@@ -37,10 +36,10 @@
|
|
|
37
36
|
"test:watch": "vitest watch"
|
|
38
37
|
},
|
|
39
38
|
"dependencies": {
|
|
40
|
-
"@gluhar/core": "^4.
|
|
41
|
-
"@gluhar/i18n": "^4.
|
|
42
|
-
"@gluhar/sanity": "^5.
|
|
43
|
-
"@gluhar/theme": "^4.0
|
|
39
|
+
"@gluhar/core": "^4.2.0",
|
|
40
|
+
"@gluhar/i18n": "^4.2.0",
|
|
41
|
+
"@gluhar/sanity": "^5.2.0",
|
|
42
|
+
"@gluhar/theme": "^4.1.0",
|
|
44
43
|
"@gluhar/v-gsap-nuxt": "^1.5.1",
|
|
45
44
|
"@nuxt/image": "^1.10.0",
|
|
46
45
|
"@nuxt/kit": "^3.13.1",
|
|
@@ -64,5 +63,5 @@
|
|
|
64
63
|
"nuxt": "^3.13.1",
|
|
65
64
|
"vitest": "^2.0.5"
|
|
66
65
|
},
|
|
67
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "10ebf6500c71e1beeceece4de90467b26aa67a21"
|
|
68
67
|
}
|