create-nuxt-base 0.1.23 → 0.2.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.
Files changed (74) hide show
  1. package/.eslintignore +14 -0
  2. package/.eslintrc +3 -0
  3. package/.github/workflows/release.yml +1 -1
  4. package/.prettierignore +5 -0
  5. package/.prettierrc +6 -0
  6. package/.vscode/settings.json +10 -10
  7. package/CHANGELOG.md +22 -33
  8. package/README.md +1 -0
  9. package/index.js +30 -29
  10. package/nuxt-base-template/.env.example +8 -0
  11. package/nuxt-base-template/.eslintrc +1 -1
  12. package/nuxt-base-template/.vscode/settings.json +6 -16
  13. package/nuxt-base-template/e2e/init.spec.ts +18 -0
  14. package/nuxt-base-template/nuxt.config.ts +27 -12
  15. package/nuxt-base-template/package-lock.json +6050 -4606
  16. package/nuxt-base-template/package.json +47 -29
  17. package/nuxt-base-template/playwright.config.ts +77 -0
  18. package/nuxt-base-template/src/app.vue +4 -4
  19. package/nuxt-base-template/src/assets/css/tailwind.css +42 -33
  20. package/nuxt-base-template/src/components/SocialMediaBubble.vue +1 -1
  21. package/nuxt-base-template/src/components/base/BaseAccordion.vue +16 -13
  22. package/nuxt-base-template/src/components/base/BaseButton.vue +10 -13
  23. package/nuxt-base-template/src/components/base/BaseContainer.vue +1 -1
  24. package/nuxt-base-template/src/components/base/BaseContextMenuContainer.vue +61 -0
  25. package/nuxt-base-template/src/components/base/BaseInfinityList.vue +1 -1
  26. package/nuxt-base-template/src/components/base/BaseProgressbar.vue +28 -30
  27. package/nuxt-base-template/src/components/base/BaseToggle.vue +17 -10
  28. package/nuxt-base-template/src/components/form/FormInput.vue +34 -0
  29. package/nuxt-base-template/src/components/form/FormPassword.vue +47 -0
  30. package/nuxt-base-template/src/components/form/FormSelect.vue +40 -0
  31. package/nuxt-base-template/src/components/form/FormSubmit.vue +18 -0
  32. package/nuxt-base-template/src/components/form/FormTextarea.vue +36 -0
  33. package/nuxt-base-template/src/components/form/FormToggle.vue +27 -0
  34. package/nuxt-base-template/src/components/modal/Modal.vue +48 -0
  35. package/nuxt-base-template/src/components/modal/ModalConfirm.vue +38 -0
  36. package/nuxt-base-template/src/components/{base/BaseModalContainer.vue → modal/ModalContainer.vue} +1 -1
  37. package/nuxt-base-template/src/components/modal/ModalInfo.vue +22 -0
  38. package/nuxt-base-template/src/components/{ModalShare.vue → modal/ModalShare.vue} +7 -11
  39. package/nuxt-base-template/src/components/{base/BaseNotification.vue → notification/Notification.vue} +8 -7
  40. package/nuxt-base-template/src/components/{base/BaseNotificationContainer.vue → notification/NotificationContainer.vue} +11 -5
  41. package/nuxt-base-template/src/components/pwa/pwa-install-banner.vue +224 -0
  42. package/nuxt-base-template/src/components/transition/TransitionFade.vue +10 -7
  43. package/nuxt-base-template/src/components/transition/TransitionFadeScale.vue +10 -7
  44. package/nuxt-base-template/src/composables/use-auth-fetch.ts +22 -8
  45. package/nuxt-base-template/src/composables/use-context-menu.ts +19 -0
  46. package/nuxt-base-template/src/composables/use-file.ts +1 -2
  47. package/nuxt-base-template/src/composables/use-modal.ts +1 -1
  48. package/nuxt-base-template/src/composables/use-notification.ts +2 -2
  49. package/nuxt-base-template/src/composables/use-share.ts +3 -3
  50. package/nuxt-base-template/src/error.vue +10 -14
  51. package/nuxt-base-template/src/layouts/default.vue +13 -0
  52. package/nuxt-base-template/src/middleware/auth.global.ts +2 -2
  53. package/nuxt-base-template/src/pages/index.vue +31 -6
  54. package/nuxt-base-template/src/plugins/auth.server.ts +72 -0
  55. package/nuxt-base-template/src/plugins/form.plugin.ts +21 -0
  56. package/nuxt-base-template/src/plugins/pwa.plugin.ts +110 -0
  57. package/nuxt-base-template/src/tests/init.test.ts +1 -1
  58. package/nuxt-base-template/tailwind.config.js +33 -23
  59. package/nuxt-base-template/vitest.config.js +3 -3
  60. package/package.json +3 -1
  61. package/nuxt-base-template/formkit-theme.js +0 -137
  62. package/nuxt-base-template/formkit.config.js +0 -33
  63. package/nuxt-base-template/src/components/hello-world.vue +0 -10
  64. package/nuxt-base-template/src/composables/use-form-helper.ts +0 -100
  65. package/nuxt-base-template/src/composables/use-helper.ts +0 -52
  66. package/nuxt-base-template/src/forms/inputs/InputCheckbox.vue +0 -29
  67. package/nuxt-base-template/src/forms/inputs/InputFreeTags.vue +0 -98
  68. package/nuxt-base-template/src/forms/inputs/InputImage.vue +0 -65
  69. package/nuxt-base-template/src/forms/inputs/InputTags.vue +0 -112
  70. package/nuxt-base-template/src/forms/inputs/InputToggle.vue +0 -18
  71. package/nuxt-base-template/src/forms/plugins/asterisk-plugin.ts +0 -29
  72. package/nuxt-base-template/src/forms/plugins/scroll-error-plugin.ts +0 -36
  73. package/nuxt-base-template/src/forms/plugins/value-changes-plugin.ts +0 -13
  74. package/nuxt-base-template/src/plugins/4.auth.server.ts +0 -70
@@ -0,0 +1,47 @@
1
+ <script setup lang="ts">
2
+ import { ErrorMessage, useField } from 'vee-validate';
3
+
4
+ enum InputType {
5
+ Password = 'password',
6
+ Text = 'text',
7
+ }
8
+
9
+ const props = defineProps<{
10
+ label: string;
11
+ name: string;
12
+ placeholder: string;
13
+ }>();
14
+
15
+ const type = ref<InputType>(InputType.Password);
16
+ const { handleBlur, handleChange, meta, value, setTouched } = useField(() => props.name);
17
+
18
+ function changeType() {
19
+ type.value = type.value === InputType.Password ? InputType.Text : InputType.Password;
20
+ }
21
+ </script>
22
+
23
+ <template>
24
+ <div class="mt-3">
25
+ <label v-if="label" :for="name" class="block text-sm font-medium leading-6 text-foreground">{{ label }}{{ meta.required ? '*' : '' }}</label>
26
+ <div class="relative mt-2 pb-2">
27
+ <div class="relative">
28
+ <input
29
+ :id="name"
30
+ v-model="value"
31
+ :type="type"
32
+ :name="name"
33
+ @blur="handleBlur"
34
+ @focus="setTouched(true)"
35
+ @change="handleChange"
36
+ class="bg-background block w-full rounded-md border-0 py-1.5 text-foreground shadow-sm ring-1 ring-inset ring-border placeholder:text-foreground/50 focus:ring-1 focus:ring-inset focus:ring-primary-500 sm:text-sm sm:leading-6"
37
+ :placeholder="placeholder"
38
+ />
39
+ <button type="button" class="absolute right-2 bottom-1/2 transform translate-y-1/2 text-secondary-100 flex items-center hover:text-primary-500" @click="changeType()">
40
+ <span v-if="type === 'password'" class="i-bi-eye"></span>
41
+ <span v-else class="i-bi-eye-slash"></span>
42
+ </button>
43
+ </div>
44
+ <ErrorMessage class="absolute -bottom-2.5 text-xs font-light text-red-600" :name="name" />
45
+ </div>
46
+ </div>
47
+ </template>
@@ -0,0 +1,40 @@
1
+ <script setup lang="ts">
2
+ import { ErrorMessage, useField } from 'vee-validate';
3
+
4
+ interface Option {
5
+ label: string;
6
+ value: any;
7
+ }
8
+
9
+ const props = defineProps<{
10
+ disabled?: boolean;
11
+ label?: string;
12
+ multiple?: boolean;
13
+ name: string;
14
+ options: Option[];
15
+ placeholder?: string;
16
+ }>();
17
+
18
+ const { handleBlur, handleChange, meta, value, setTouched } = useField(() => props.name);
19
+ </script>
20
+
21
+ <template>
22
+ <div class="relative mt-3 pb-2">
23
+ <label v-if="label" :for="name" class="block text-sm font-medium leading-6 text-foreground">{{ label }}{{ meta.required ? '*' : '' }}</label>
24
+ <select
25
+ :id="name"
26
+ v-model="value"
27
+ @focus="setTouched(true)"
28
+ :name="name"
29
+ :multiple="multiple ?? false"
30
+ :disabled="disabled"
31
+ class="bg-background mt-2 block w-full rounded-md border-0 py-1.5 pl-3 pr-10 text-foreground ring-1 ring-inset ring-border focus:ring-1 focus:ring-primary-500 sm:text-sm sm:leading-6"
32
+ @blur="handleBlur"
33
+ @change="handleChange"
34
+ >
35
+ <option class="text-foreground/50" :value="null" disabled selected>{{ placeholder }}</option>
36
+ <option v-for="option of options" :value="option.value">{{ option.label }}</option>
37
+ </select>
38
+ <ErrorMessage class="absolute -bottom-2.5 text-xs font-light text-red-600" :name="name" />
39
+ </div>
40
+ </template>
@@ -0,0 +1,18 @@
1
+ <script setup lang="ts">
2
+ const props = defineProps<{
3
+ isSubmitting?: boolean;
4
+ label: string;
5
+ }>();
6
+ </script>
7
+
8
+ <template>
9
+ <div>
10
+ <BaseButton v-if="isSubmitting" type="button" disabled>
11
+ <span class="animate-bounce">.</span>
12
+ <span class="animate-bounce delay-150">.</span>
13
+ <span class="animate-bounce delay-300 me-1">.</span>
14
+ Loading
15
+ </BaseButton>
16
+ <BaseButton v-else type="submit"> {{ label }} </BaseButton>
17
+ </div>
18
+ </template>
@@ -0,0 +1,36 @@
1
+ <script setup lang="ts">
2
+ import { ErrorMessage, useField } from 'vee-validate';
3
+
4
+ const props = defineProps<{
5
+ disabled?: boolean;
6
+ label?: string;
7
+ name: string;
8
+ placeholder?: string;
9
+ cols?: number;
10
+ maxlength?: number;
11
+ }>();
12
+
13
+ const { handleBlur, handleChange, value, meta, setTouched } = useField(() => props.name);
14
+ </script>
15
+
16
+ <template>
17
+ <div class="mt-3">
18
+ <label v-if="label" :for="name" class="block text-sm font-medium leading-6 text-foreground">{{ label }}{{ meta.required ? '*' : '' }}</label>
19
+ <div class="relative mt-2 pb-2">
20
+ <textarea
21
+ :id="name"
22
+ :cols="cols"
23
+ :maxlength="maxlength"
24
+ :name="name"
25
+ v-model="value"
26
+ :disabled="disabled"
27
+ @blur="handleBlur"
28
+ @focus="setTouched(true)"
29
+ @change="handleChange"
30
+ class="bg-background block resize-none w-full rounded-md border-0 py-1.5 text-foreground shadow-sm ring-1 ring-inset ring-border placeholder:text-foreground/50 focus:ring-1 focus:ring-inset focus:ring-primary-500 sm:text-sm sm:leading-6"
31
+ :placeholder="placeholder"
32
+ />
33
+ <ErrorMessage class="absolute -bottom-2.5 text-xs font-light text-red-600" :name="name" />
34
+ </div>
35
+ </div>
36
+ </template>
@@ -0,0 +1,27 @@
1
+ <script setup lang="ts">
2
+ import { ErrorMessage, useField } from 'vee-validate';
3
+
4
+ const props = defineProps<{
5
+ disabled?: boolean;
6
+ label?: string;
7
+ name: string;
8
+ }>();
9
+
10
+ const { handleChange, meta, value, setTouched } = useField(() => props.name);
11
+
12
+ watch(
13
+ () => value.value,
14
+ () => {
15
+ handleChange(value.value);
16
+ setTouched(true);
17
+ }
18
+ );
19
+ </script>
20
+
21
+ <template>
22
+ <div class="relative mt-3 pb-2">
23
+ <label v-if="label" :for="name" class="block text-sm font-medium leading-6 text-foreground">{{ label }}{{ meta.required ? '*' : '' }}</label>
24
+ <BaseToggle v-model:active="value" :disabled="disabled" />
25
+ <ErrorMessage class="absolute -bottom-2.5 text-xs font-light text-red-600" :name="name" />
26
+ </div>
27
+ </template>
@@ -0,0 +1,48 @@
1
+ <script setup lang="ts">
2
+ import { twMerge } from 'tailwind-merge';
3
+
4
+ defineOptions({
5
+ inheritAttrs: false,
6
+ });
7
+
8
+ const props = withDefaults(
9
+ defineProps<{
10
+ show: boolean;
11
+ showInner: boolean;
12
+ backgroundColor?: string;
13
+ size?: 'auto' | 'sm' | 'md' | 'lg';
14
+ }>(),
15
+ {
16
+ backgroundColor: '#FFF',
17
+ size: 'auto',
18
+ }
19
+ );
20
+
21
+ const emit = defineEmits<{
22
+ (event: 'cancel'): void;
23
+ }>();
24
+
25
+ const attributes = useAttrs() as { class: string };
26
+ const sizeClasses: Record<typeof props.size, string> = {
27
+ auto: 'w-4/5 md:w-auto',
28
+ sm: 'w-4/5 md:w-1/4',
29
+ md: 'w-4/5 md:w-3/6',
30
+ lg: 'w-4/5 md:w-4/5',
31
+ };
32
+ const defaultClasses = 'duration-200 w-full overflow-hidden rounded-[20px] p-4 bg-[--bg-color] bg-background flex flex-col gap-4';
33
+ const classes = twMerge(defaultClasses, sizeClasses[props.size], attributes?.class);
34
+ </script>
35
+
36
+ <template>
37
+ <div class="relative z-50" aria-labelledby="modal-title" role="dialog" aria-modal="true" :style="`--bg-color: ${props.backgroundColor};`">
38
+ <TransitionFade>
39
+ <div v-show="show" class="fixed inset-0 bg-background/30 backdrop-blur-sm transition-opacity flex justify-center items-center" @click="emit('cancel')">
40
+ <TransitionFade class="w-full flex justify-center">
41
+ <div v-show="showInner" :class="classes" @click.stop>
42
+ <slot></slot>
43
+ </div>
44
+ </TransitionFade>
45
+ </div>
46
+ </TransitionFade>
47
+ </div>
48
+ </template>
@@ -0,0 +1,38 @@
1
+ <script setup lang="ts">
2
+ import type { ModalContext } from '~/composables/use-modal';
3
+
4
+ const props = defineProps<{
5
+ context: ModalContext<{
6
+ cancelText: string;
7
+ confirmColor?: 'primary' | 'secondary' | 'green' | 'yellow' | 'lightprimary' | 'danger';
8
+ confirmText: string;
9
+ text: string;
10
+ title: string;
11
+ }>;
12
+ }>();
13
+ const { close } = useModal();
14
+ </script>
15
+
16
+ <template>
17
+ <Modal class="p-10 relative" :show="context.show" :show-inner="context.showInner" :size="context.size" @cancel="context.closable ? close() : null">
18
+ <div class="flex items-center justify-center mb-2">
19
+ <div class="font-semibold text-xl text-foreground">
20
+ {{ context?.data?.title }}
21
+ </div>
22
+ <button class="absolute top-5 right-5" @click="close()">
23
+ <span class="i-bi-x text-2xl hover:text-primary-500 duration-200"></span>
24
+ </button>
25
+ </div>
26
+ <div class="mb-5 text-foreground">
27
+ {{ context?.data?.text }}
28
+ </div>
29
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-2">
30
+ <BaseButton appearance="outline" color="primary" @click="context?.confirm?.(false)">
31
+ {{ context?.data?.cancelText || 'Abbrechen' }}
32
+ </BaseButton>
33
+ <BaseButton :color="context?.data?.confirmColor || 'primary'" @click="context?.confirm?.(true)">
34
+ {{ context?.data?.confirmText || 'Ok' }}
35
+ </BaseButton>
36
+ </div>
37
+ </Modal>
38
+ </template>
@@ -4,4 +4,4 @@ const { activeModal } = useModal();
4
4
 
5
5
  <template>
6
6
  <component :is="activeModal.component" v-if="activeModal" :context="activeModal" />
7
- </template>
7
+ </template>
@@ -0,0 +1,22 @@
1
+ <script setup lang="ts">
2
+ import type { ModalContext } from '~/composables/use-modal';
3
+
4
+ const props = defineProps<{ context: ModalContext<{ text: string; title: string }> }>();
5
+ const { close } = useModal();
6
+ </script>
7
+
8
+ <template>
9
+ <Modal class="p-10 relative" :show="context.show" :show-inner="context.showInner" :size="context.size" @cancel="context.closable ? close() : null">
10
+ <div class="flex items-center justify-center mb-2">
11
+ <div class="font-semibold text-xl text-foreground">
12
+ {{ context?.data?.title }}
13
+ </div>
14
+ <button class="absolute top-5 right-5" @click="close()">
15
+ <span class="i-bi-x text-2xl hover:text-primary-500 duration-200"></span>
16
+ </button>
17
+ </div>
18
+ <div class="text-center text-foreground mb-6">
19
+ {{ context?.data?.text }}
20
+ </div>
21
+ </Modal>
22
+ </template>
@@ -2,7 +2,7 @@
2
2
  import type { ModalContext } from '~/composables/use-modal';
3
3
  import SocialMediaBubble from '~/components/SocialMediaBubble.vue';
4
4
 
5
- const props = defineProps<{ context: ModalContext }>();
5
+ const props = defineProps<{ context: ModalContext<{ link: string; name: string }> }>();
6
6
  const { close } = useModal();
7
7
  const url = ref<string>('');
8
8
 
@@ -18,7 +18,7 @@ const copyUrl = () => {
18
18
  const shareWith = (type: 'mail' | 'whatsapp' | 'facebook' | 'linkedin' | 'twitter') => {
19
19
  switch (type) {
20
20
  case 'mail':
21
- open(`mailto:?subject=RegioKonneX&body=${encodeURIComponent(url.value)}`, '_blank');
21
+ open(`mailto:?subject=${props.context.data?.name}&body=${encodeURIComponent(url.value)}`, '_blank');
22
22
  break;
23
23
  case 'whatsapp':
24
24
  open(`https://api.whatsapp.com/send/?text=${encodeURIComponent(url.value)}`, '_blank');
@@ -39,14 +39,12 @@ const shareWith = (type: 'mail' | 'whatsapp' | 'facebook' | 'linkedin' | 'twitte
39
39
  <template>
40
40
  <Modal class="p-10 relative" :show="context.show" :show-inner="context.showInner" :size="context.size" @cancel="context.closable ? close() : null">
41
41
  <div class="flex items-center justify-center mb-4">
42
- <div class="font-semibold text-xl dark:text-white">
43
- Teilen
44
- </div>
42
+ <div class="font-semibold text-xl text-foreground">Teilen</div>
45
43
  <button class="absolute top-5 right-5" @click="close()">
46
44
  <span class="i-bi-x text-2xl hover:text-primary-500"></span>
47
45
  </button>
48
46
  </div>
49
- <div class="text-center dark:text-white">
47
+ <div class="text-center text-foreground">
50
48
  <div class="flex justify-around max-w-md mx-auto gap-3 py-2 mb-5 overflow-x-scroll">
51
49
  <SocialMediaBubble title="E-Mail" bg-color="#bbbbbb" icon="i-bi-envelope" @click="shareWith('mail')" />
52
50
  <SocialMediaBubble title="Whatsapp" bg-color="#25d366" icon="i-bi-whatsapp" @click="shareWith('whatsapp')" />
@@ -54,14 +52,12 @@ const shareWith = (type: 'mail' | 'whatsapp' | 'facebook' | 'linkedin' | 'twitte
54
52
  <SocialMediaBubble title="LinkedIn" bg-color="#0a66c2" icon="i-bi-linkedin" @click="shareWith('linkedin')" />
55
53
  <SocialMediaBubble title="X / Twitter" bg-color="#000000" icon="i-bi-twitter-x" @click="shareWith('twitter')" />
56
54
  </div>
57
- <div class="flex items-center gap-3 justify-between p-3 border border-gray-300 rounded-lg">
55
+ <div class="flex items-center gap-3 justify-between p-3 border border-border rounded-lg">
58
56
  <span class="text-ellipsis overflow-hidden">
59
57
  {{ url }}
60
58
  </span>
61
- <BaseButton size="sm" @click="copyUrl()">
62
- Kopieren
63
- </BaseButton>
59
+ <BaseButton size="sm" @click="copyUrl()"> Kopieren </BaseButton>
64
60
  </div>
65
61
  </div>
66
62
  </Modal>
67
- </template>
63
+ </template>
@@ -15,7 +15,7 @@ let durationLeft = props.duration - (500 + 130);
15
15
  onMounted(() => {
16
16
  const interval = setInterval(() => {
17
17
  durationLeft -= 30;
18
- process.value = durationLeft / props.duration * 100;
18
+ process.value = (durationLeft / props.duration) * 100;
19
19
  }, 30);
20
20
  setTimeout(() => {
21
21
  clearInterval(interval);
@@ -41,17 +41,18 @@ const accentColor: Record<typeof props.type, string> = {
41
41
  <template>
42
42
  <div
43
43
  :style="`--accent-color: ${accentColor[props.type]}`"
44
- class="pointer-events-auto relative w-full max-w-sm overflow-hidden rounded-lg bg-white dark:bg-gray-950 shadow-lg ring-1 ring-black ring-opacity-5 z-[99999px]"
44
+ class="pointer-events-auto relative w-full max-w-sm overflow-hidden rounded-lg bg-white dark:bg-gray-950 shadow-lg ring-1 ring-black ring-opacity-5 z-[99999px]"
45
45
  >
46
46
  <div
47
47
  :style="{
48
- width: `${process}%`,
49
- }" class="bg-[--accent-color] h-[5px] duration-100 transition-[width] w-[width] absolute bottom-0"
48
+ width: `${process}%`
49
+ }"
50
+ class="bg-[--accent-color] h-[5px] duration-100 transition-[width] w-[width] absolute bottom-0"
50
51
  ></div>
51
- <div class="p-4 ">
52
+ <div class="p-4">
52
53
  <div class="flex items-start">
53
54
  <div class="flex-shrink-0">
54
- <span :class="icon[props.type]" class=" h-6 w-6 text-[--accent-color]"></span>
55
+ <span :class="icon[props.type]" class="h-6 w-6 text-[--accent-color]"></span>
55
56
  </div>
56
57
  <div class="ml-3 w-0 flex-1 pt-0.5">
57
58
  <p class="text-sm font-semibold text-gray-900 dark:text-white">
@@ -78,4 +79,4 @@ const accentColor: Record<typeof props.type, string> = {
78
79
  </div>
79
80
  </div>
80
81
  </div>
81
- </template>
82
+ </template>
@@ -4,10 +4,16 @@ const { notifications, remove } = useNotification();
4
4
 
5
5
  <template>
6
6
  <div aria-live="assertive" class="pointer-events-none fixed inset-0 flex items-end px-4 py-6 sm:items-start sm:p-6 z-[99999]">
7
- <TransitionGroup
8
- tag="div" name="list" class="flex w-full flex-col items-center space-y-4 sm:items-end"
9
- >
10
- <BaseNotification v-for="notification in notifications" :key="notification.uuid" :text="notification.text" :title="notification.title" :type="notification.type" :duration="notification.duration!" @close="remove(notification.uuid)" />
7
+ <TransitionGroup tag="div" name="list" class="flex w-full flex-col items-center space-y-4 sm:items-end">
8
+ <Notification
9
+ v-for="notification in notifications"
10
+ :key="notification.uuid"
11
+ :text="notification.text"
12
+ :title="notification.title"
13
+ :type="notification.type"
14
+ :duration="notification.duration!"
15
+ @close="remove(notification.uuid)"
16
+ />
11
17
  </TransitionGroup>
12
18
  </div>
13
19
  </template>
@@ -31,4 +37,4 @@ const { notifications, remove } = useNotification();
31
37
  .list-leave-active {
32
38
  position: absolute;
33
39
  }
34
- </style>
40
+ </style>
@@ -0,0 +1,224 @@
1
+ <script setup lang="ts">
2
+ const props = withDefaults(
3
+ defineProps<{
4
+ addHomeButtonLabel?: string;
5
+ body?: string;
6
+ buttonLabel?: string;
7
+ closePrompt?: string;
8
+ debug?: boolean;
9
+ delay?: number;
10
+ iosBackgroundColor?: string;
11
+ iosBackgroundColorDark?: string;
12
+ iosBorderColor?: string;
13
+ iosBorderColorDark?: string;
14
+ iosButtonColoDark?: string;
15
+ iosButtonColor?: string;
16
+ iosOverlayColor?: string;
17
+ iosOverlayColorDark?: string;
18
+ iosTextColor?: string;
19
+ iosTextColorDark?: string;
20
+ iosTitleColor?: string;
21
+ iosTitleColorDark?: string;
22
+ title?: string;
23
+ }>(),
24
+ {
25
+ addHomeButtonLabel: '2) Drücken Sie auf "Zum Home-Bildschirm".',
26
+ body: 'Diese Website verfügt über eine App-Funktionalität. Fügen Sie sie zu Ihrem Startbildschirm hinzu, um sie im Vollbildmodus und offline zu nutzen.',
27
+ buttonLabel: '1) Drücken Sie die Schaltfläche "Teilen".',
28
+ closePrompt: 'Abbrechen',
29
+ debug: false,
30
+
31
+ delay: 1000,
32
+ iosBackgroundColor: 'rgba(255, 255, 255, 0.9)',
33
+
34
+ iosBackgroundColorDark: 'rgba(65, 65, 65, 0.7)',
35
+ iosBorderColor: 'rgba(60, 60, 67, 0.29)',
36
+
37
+ iosBorderColorDark: 'rgba(140, 140, 140, 0.7)',
38
+ iosButtonColoDark: 'rgba(9, 132, 255, 1)',
39
+
40
+ iosButtonColor: 'rgba(0, 85, 179, 1)',
41
+ iosOverlayColor: 'rgba(10, 10, 10, 0.5)',
42
+
43
+ iosOverlayColorDark: 'rgba(10, 10, 10, 0.5)',
44
+ iosTextColor: 'rgba(60, 60, 67, 0.6)',
45
+
46
+ iosTextColorDark: 'rgba(235, 235, 245, 0.6)',
47
+ iosTitleColor: 'rgba(0, 0, 0, 1)',
48
+
49
+ iosTitleColorDark: 'rgba(255, 255, 255, 1)',
50
+ title: 'Zum Startbildschirm hinzufügen',
51
+ }
52
+ );
53
+
54
+ const cssVariables = [
55
+ `--ios-overlay: ${props.iosOverlayColor}`,
56
+ `--ios-overlay-dark: ${props.iosOverlayColorDark}`,
57
+ `--ios-background: ${props.iosBackgroundColor}`,
58
+ `--ios-background-dark: ${props.iosBackgroundColorDark}`,
59
+ `--ios-button: ${props.iosButtonColor}`,
60
+ `--ios-button-dark: ${props.iosButtonColor}`,
61
+ `--ios-border: ${props.iosBorderColor}`,
62
+ `--ios-border-dark: ${props.iosBorderColorDark}`,
63
+ `--ios-title: ${props.iosTitleColor}`,
64
+ `--ios-title-dark: ${props.iosTitleColorDark}`,
65
+ `--ios-text: ${props.iosTextColor}`,
66
+ `--ios-text-dark: ${props.iosTextColorDark}`,
67
+ ].join(';');
68
+
69
+ const HomeIcon = defineComponent({
70
+ render: () =>
71
+ h('svg', { fill: 'currentColor', viewBox: '0 0 578 584' }, [
72
+ h('path', {
73
+ 'clip-rule': 'evenodd',
74
+ d: 'M101 35l19-1h333c12 0 23 0 35 3 17 3 34 12 44 27 13 16 16 38 16 58v329c0 19 0 39-8 57a65 65 0 0 1-37 37c-18 7-38 7-57 7H130c-21 1-44 0-63-10-14-7-25-20-30-34-6-15-8-30-8-45V121c1-21 5-44 19-61 13-16 33-23 53-25m7 46c-10 1-19 6-24 14-7 8-9 20-9 31v334c0 12 2 25 10 34 9 10 23 12 35 12h336c14 1 30-3 38-15 6-9 8-20 8-31V125c0-12-2-24-10-33-9-9-22-12-35-12H121l-13 1z',
75
+ 'fill-rule': 'evenodd',
76
+ }),
77
+ h('path', {
78
+ 'clip-rule': 'evenodd',
79
+ d: 'M271 161c9-11 31-10 38 4 3 5 3 11 3 17v87h88c7 0 16 1 21 7 6 6 7 14 6 22a21 21 0 0 1-10 14c-5 4-11 5-17 5h-88v82c0 7-1 15-6 20-10 10-29 10-37-2-3-6-4-13-4-19v-81h-87c-8-1-17-3-23-9-5-6-6-15-4-22a21 21 0 0 1 11-14c6-3 13-3 19-3h84v-88c0-7 1-14 6-20z',
80
+ 'fill-rule': 'evenodd',
81
+ }),
82
+ ]),
83
+ });
84
+
85
+ const ShareIcon = defineComponent({
86
+ render: () =>
87
+ h('svg', { fill: 'currentColor', viewBox: '0 0 566 670' }, [
88
+ h('path', {
89
+ 'clip-rule': 'evenodd',
90
+ d: 'M255 12c4-4 10-8 16-8s12 3 16 8l94 89c3 4 6 7 8 12 2 6 0 14-5 19-7 8-20 9-28 2l-7-7-57-60 2 54v276c0 12-10 22-22 22-12 1-24-10-23-22V110l1-43-60 65c-5 5-13 8-21 6a19 19 0 0 1-16-17c-1-7 2-13 7-18l95-91z',
91
+ 'fill-rule': 'evenodd',
92
+ }),
93
+ h('path', {
94
+ 'clip-rule': 'evenodd',
95
+ d: 'M43 207c16-17 40-23 63-23h83v46h-79c-12 0-25 3-33 13-8 9-10 21-10 33v260c0 13 0 27 6 38 5 12 18 18 30 19l14 1h302c14 0 28 0 40-8 11-7 16-21 16-34V276c0-11-2-24-9-33-8-10-22-13-34-13h-78v-46h75c13 0 25 1 37 4 16 4 31 13 41 27 11 17 14 37 14 57v280c0 20-3 41-15 58a71 71 0 0 1-45 27c-11 2-23 3-34 3H109c-19-1-40-4-56-15-14-9-23-23-27-38-4-12-5-25-5-38V270c1-22 6-47 22-63z',
96
+ 'fill-rule': 'evenodd',
97
+ }),
98
+ ]),
99
+ });
100
+
101
+ const showBanner = ref(false);
102
+
103
+ watch(
104
+ () => showBanner.value,
105
+ () => {
106
+ if (showBanner.value) {
107
+ // Disable scrolling of background
108
+ document.body.style.overflowY = 'hidden';
109
+ } else {
110
+ // Deactivate scrolling of background
111
+ document.body.style.overflowY = '';
112
+ }
113
+ }
114
+ );
115
+
116
+ interface BeforeInstallPromptEvent {
117
+ prompt: () => void;
118
+ }
119
+ const { storagePrefix } = useRuntimeConfig().public;
120
+ const deferredPrompt = ref<BeforeInstallPromptEvent | null>();
121
+
122
+ const cancelCookie = () => useCookie(`${storagePrefix}_pwa_prompt_canceled`, { default: () => false });
123
+
124
+ function cancel() {
125
+ cancelCookie().value = true;
126
+ showBanner.value = false;
127
+ }
128
+
129
+ function deviceCheck() {
130
+ const isiOS = /iphone|ipad|ipod/.test(window.navigator.userAgent.toLowerCase());
131
+ const isiPadOS = navigator.platform === 'MacIntel' && navigator.maxTouchPoints >= 2;
132
+ const isStandalone = 'standalone' in window.navigator && window.navigator.standalone;
133
+
134
+ return (isiOS || isiPadOS) && !isStandalone;
135
+ }
136
+
137
+ function reactivate() {
138
+ cancelCookie().value = false;
139
+ showBanner.value = true;
140
+ }
141
+
142
+ function showInAppInstallPromotion() {
143
+ if (deferredPrompt.value) {
144
+ deferredPrompt.value.prompt();
145
+ }
146
+ }
147
+
148
+ onMounted(() => {
149
+ if (!cancelCookie().value) {
150
+ showBanner.value = deviceCheck();
151
+ }
152
+
153
+ // This variable will save the event for later use.
154
+ let deferredPrompt;
155
+ window.addEventListener('beforeinstallprompt', (e) => {
156
+ // Prevents the default mini-infobar or install dialog from appearing on mobile
157
+ e.preventDefault();
158
+ // Save the event because you'll need to trigger it later.
159
+ deferredPrompt = e;
160
+ // Show your customized install prompt for your PWA
161
+ // Your own UI doesn't have to be a single element, you
162
+ // can have buttons in different locations, or wait to prompt
163
+ // as part of a critical journey.
164
+ showInAppInstallPromotion();
165
+ });
166
+ });
167
+
168
+ defineExpose({
169
+ reactivate,
170
+ });
171
+ </script>
172
+
173
+ <template>
174
+ <Transition
175
+ enter-active-class="ease-out duration-500 delay-500"
176
+ enter-from-class="translate-y-full"
177
+ enter-to-class="translate-x-0"
178
+ leave-active-class="ease-in duration-500"
179
+ leave-from-class="translate-x-0"
180
+ leave-to-class="translate-y-full"
181
+ >
182
+ <div v-show="showBanner" :style="cssVariables" class="bottom-0 w-full fixed !z-[9998] p-2 max-w-md mx-auto">
183
+ <div class="bg-[var(--ios-background)] backdrop-blur-sm overflow-hidden dark:bg-[var(--ios-background-dark)] rounded-lg">
184
+ <div class="flex justify-between border-b border-[var(--ios-border)] dark:border-[var(--ios-border-dark)]">
185
+ <h4 class="text-[var(--ios-title)] dark:text-[var(--ios-title-dark)] text-md p-4">
186
+ {{ props.title }}
187
+ </h4>
188
+ <button class="text-[var(--ios-button)] dark:text-[var(--ios-button-dark)] text-base p-4" @click="cancel()">
189
+ {{ props.closePrompt }}
190
+ </button>
191
+ </div>
192
+ <div class="px-8 py-4">
193
+ <p class="text-[var(--ios-text)] dark:text-[var(--ios-text-dark)] text-center text-sm border-b px-4 pb-4 border-[var(--ios-border)] dark:border-[var(--ios-border-dark)]">
194
+ {{ props.body }}
195
+ </p>
196
+ <div class="flex flex-col gap-4 p-4 pt-8">
197
+ <div class="flex justify-start items-center gap-6">
198
+ <ShareIcon class="h-8 w-auto text-[var(--ios-button)] dark:text-[var(--ios-button-dark)]" />
199
+ <p class="text-sm text-left text-[var(--ios-text)] dark:text-[var(--ios-text-dark)]">
200
+ {{ props.buttonLabel }}
201
+ </p>
202
+ </div>
203
+ <div class="flex justify-start items-center gap-6">
204
+ <HomeIcon class="h-8 w-auto text-[var(--ios-button)] dark:text-[var(--ios-button-dark)]" />
205
+ <p class="text-sm text-left text-[var(--ios-text)] dark:text-[var(--ios-text-dark)]">
206
+ {{ props.addHomeButtonLabel }}
207
+ </p>
208
+ </div>
209
+ </div>
210
+ </div>
211
+ </div>
212
+ </div>
213
+ </Transition>
214
+ <Transition
215
+ enter-active-class="ease-out duration-1000"
216
+ enter-from-class="opacity-0"
217
+ enter-to-class="opacity-100"
218
+ leave-active-class="ease-in duration-1000"
219
+ leave-from-class="opacity-100"
220
+ leave-to-class="opacity-0"
221
+ >
222
+ <div v-show="showBanner" :style="cssVariables" class="absolute inset-0 bg-black/50 !z-[9997] min-h-screen w-full"></div>
223
+ </Transition>
224
+ </template>
@@ -1,11 +1,14 @@
1
1
  <script setup lang="ts">
2
- const props = withDefaults(defineProps<{
3
- startDuration?: number | `${number}`;
4
- leaveDuration?: number | `${number}`;
5
- }>(), {
6
- startDuration: 100,
7
- leaveDuration: 100,
8
- });
2
+ const props = withDefaults(
3
+ defineProps<{
4
+ startDuration?: number | `${number}`;
5
+ leaveDuration?: number | `${number}`;
6
+ }>(),
7
+ {
8
+ startDuration: 100,
9
+ leaveDuration: 100,
10
+ }
11
+ );
9
12
  </script>
10
13
 
11
14
  <template>