@myelophone/nuxt 0.18.2

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 (259) hide show
  1. package/.devcontainer/Dockerfile +7 -0
  2. package/.devcontainer/devcontainer.json +21 -0
  3. package/.editorconfig +43 -0
  4. package/.github/workflows/package.yml +73 -0
  5. package/.nuxtignore +6 -0
  6. package/.releaserc.js +132 -0
  7. package/.yarn/releases/yarn-4.18.0.cjs +1000 -0
  8. package/.yarnrc.yml +8 -0
  9. package/CHANGELOG.md +141 -0
  10. package/LICENSE +77 -0
  11. package/README.md +3004 -0
  12. package/app/app.vue +455 -0
  13. package/app/assets/css/animation.css +81 -0
  14. package/app/assets/css/backgrounds.css +57 -0
  15. package/app/assets/css/base.css +182 -0
  16. package/app/assets/css/index.css +9 -0
  17. package/app/assets/css/links.css +12 -0
  18. package/app/assets/css/multimedia.css +102 -0
  19. package/app/assets/css/preloader.css +68 -0
  20. package/app/assets/css/print.css +40 -0
  21. package/app/assets/css/tailwind.css +20 -0
  22. package/app/assets/css/theme.css +29 -0
  23. package/app/components/consent/GoogleMap.vue +59 -0
  24. package/app/components/consent/Youtube.vue +27 -0
  25. package/app/components/cookie/Banner.vue +70 -0
  26. package/app/components/cookie/ConsentWrapper.vue +71 -0
  27. package/app/components/cookie/PrivacyPolicy.vue +179 -0
  28. package/app/components/cookie/SettingsModal.vue +387 -0
  29. package/app/components/grid/Col.vue +262 -0
  30. package/app/components/grid/Container.vue +236 -0
  31. package/app/components/grid/Row.vue +248 -0
  32. package/app/components/grid/Stack.vue +233 -0
  33. package/app/components/myelophone/Copyright.vue +5 -0
  34. package/app/components/myelophone/Welcome.vue +107 -0
  35. package/app/components/page/FullscreenPreloader.vue +177 -0
  36. package/app/components/page/Preloader.vue +18 -0
  37. package/app/components/page/ReadyLocalized.vue +19 -0
  38. package/app/components/ready/.gitkeep +0 -0
  39. package/app/components/safe/Email.vue +52 -0
  40. package/app/components/safe/ImgWithLoader.vue +180 -0
  41. package/app/components/safe/NuxtImg.vue +25 -0
  42. package/app/components/safe/NuxtPicture.vue +29 -0
  43. package/app/components/section/.gitkeep +0 -0
  44. package/app/components/seo/BrandInfo.vue +76 -0
  45. package/app/components/seo/ContentNoIndex.vue +35 -0
  46. package/app/components/seo/NoIndex.vue +22 -0
  47. package/app/components/seo/OrgInfo.vue +130 -0
  48. package/app/components/seo/ProfileInfo.vue +137 -0
  49. package/app/components/ui/Accordion.vue +163 -0
  50. package/app/components/ui/Alert.vue +179 -0
  51. package/app/components/ui/Avatar.vue +88 -0
  52. package/app/components/ui/Badge.vue +150 -0
  53. package/app/components/ui/Banner.vue +133 -0
  54. package/app/components/ui/Button.vue +175 -0
  55. package/app/components/ui/Card.vue +66 -0
  56. package/app/components/ui/Checkbox.vue +134 -0
  57. package/app/components/ui/Chip.vue +136 -0
  58. package/app/components/ui/CommandPalette.vue +434 -0
  59. package/app/components/ui/Console.vue +583 -0
  60. package/app/components/ui/CursorCreative.vue +148 -0
  61. package/app/components/ui/FeatureAccordion.vue +165 -0
  62. package/app/components/ui/FileUpload.vue +705 -0
  63. package/app/components/ui/GeoDependent.vue +72 -0
  64. package/app/components/ui/Heading.vue +51 -0
  65. package/app/components/ui/Icon.vue +42 -0
  66. package/app/components/ui/Icon8.vue +39 -0
  67. package/app/components/ui/Input.vue +88 -0
  68. package/app/components/ui/LangLink.vue +34 -0
  69. package/app/components/ui/LangVisible.vue +33 -0
  70. package/app/components/ui/LanguageSelect.vue +202 -0
  71. package/app/components/ui/LightBox.vue +155 -0
  72. package/app/components/ui/LocalTime.vue +170 -0
  73. package/app/components/ui/Modal.vue +161 -0
  74. package/app/components/ui/Popup.vue +200 -0
  75. package/app/components/ui/PostContent.server.vue +23 -0
  76. package/app/components/ui/ProtectedEmail.vue +52 -0
  77. package/app/components/ui/RelativeTime.vue +141 -0
  78. package/app/components/ui/ScheduledContent.vue +150 -0
  79. package/app/components/ui/ScrollToTop.client.vue +48 -0
  80. package/app/components/ui/SegmentedControl.vue +148 -0
  81. package/app/components/ui/SiteSearch.vue +1191 -0
  82. package/app/components/ui/Skeleton.vue +91 -0
  83. package/app/components/ui/SmartContrast.vue +74 -0
  84. package/app/components/ui/SnapContainer.vue +222 -0
  85. package/app/components/ui/SnapSection.vue +294 -0
  86. package/app/components/ui/SonnerStyle.vue +7 -0
  87. package/app/components/ui/SplitSection.vue +99 -0
  88. package/app/components/ui/Steps.vue +858 -0
  89. package/app/components/ui/StickyWrapper.vue +46 -0
  90. package/app/components/ui/Table.vue +251 -0
  91. package/app/components/ui/Tabs.vue +451 -0
  92. package/app/components/ui/TextColumn.vue +36 -0
  93. package/app/components/ui/Textarea.vue +251 -0
  94. package/app/components/ui/Toggler.vue +40 -0
  95. package/app/components/ui/Tooltip.vue +524 -0
  96. package/app/components/ui/TruncateText.vue +105 -0
  97. package/app/components/ui/ViewportSpacer.vue +72 -0
  98. package/app/components/view/AnimatedCounter.vue +121 -0
  99. package/app/components/view/AnnouncementBar.vue +104 -0
  100. package/app/components/view/AvatarGroup.vue +104 -0
  101. package/app/components/view/Breadcrumbs.vue +97 -0
  102. package/app/components/view/ContentWithToc.vue +152 -0
  103. package/app/components/view/Copyright.vue +68 -0
  104. package/app/components/view/CountdownTimer.vue +184 -0
  105. package/app/components/view/CreativeCTA.vue +143 -0
  106. package/app/components/view/CurrencySelect.vue +254 -0
  107. package/app/components/view/FeatureBoxGrid.vue +142 -0
  108. package/app/components/view/HorizontalMenu.vue +97 -0
  109. package/app/components/view/ImageCompare.vue +141 -0
  110. package/app/components/view/ImgSlider.vue +333 -0
  111. package/app/components/view/InfiniteMarquee.vue +147 -0
  112. package/app/components/view/InfoBar.vue +86 -0
  113. package/app/components/view/LogoGrid.vue +106 -0
  114. package/app/components/view/LogoSlider.vue +83 -0
  115. package/app/components/view/NotFound.vue +81 -0
  116. package/app/components/view/PartialBackground.vue +313 -0
  117. package/app/components/view/QuoteBig.vue +111 -0
  118. package/app/components/view/ResponsiveMenu.vue +219 -0
  119. package/app/components/view/ReviewsSlider.vue +230 -0
  120. package/app/components/view/SocialBar.vue +78 -0
  121. package/app/components/view/StickyHeadingContent.vue +158 -0
  122. package/app/components/view/TallyForm.vue +295 -0
  123. package/app/components/view/WarningOutdated.vue +113 -0
  124. package/app/composables/useApi.ts +88 -0
  125. package/app/composables/useAppSeo.ts +78 -0
  126. package/app/composables/useBreadcrumbs.ts +106 -0
  127. package/app/composables/useChangeUrl.ts +73 -0
  128. package/app/composables/useCommand.ts +28 -0
  129. package/app/composables/useCookieControl.ts +111 -0
  130. package/app/composables/useCookieModal.ts +9 -0
  131. package/app/composables/useDevice.ts +109 -0
  132. package/app/composables/useGeoFetch.ts +139 -0
  133. package/app/composables/useLoadScript.ts +36 -0
  134. package/app/composables/useModalState.ts +37 -0
  135. package/app/composables/useMultiLang.ts +278 -0
  136. package/app/composables/useNetwork.ts +49 -0
  137. package/app/composables/useNuxtVersion.ts +5 -0
  138. package/app/composables/usePiniaStore.ts +5 -0
  139. package/app/composables/usePopupControl.ts +57 -0
  140. package/app/composables/useQuery.ts +307 -0
  141. package/app/composables/useReadyPage.ts +182 -0
  142. package/app/composables/useSafeList.ts +90 -0
  143. package/app/composables/useScriptLoader.ts +221 -0
  144. package/app/composables/useSiteSearch.ts +32 -0
  145. package/app/composables/useSnapScroll.ts +24 -0
  146. package/app/composables/useStatic.ts +5 -0
  147. package/app/composables/useStorage.ts +252 -0
  148. package/app/composables/useStoreBroadcast.ts +146 -0
  149. package/app/composables/useThemeSync.ts +81 -0
  150. package/app/constants/layout.ts +109 -0
  151. package/app/constants/predefinedCookieScripts.ts +1222 -0
  152. package/app/constants/ui-events.ts +1 -0
  153. package/app/error.vue +169 -0
  154. package/app/layouts/default-blog.vue +5 -0
  155. package/app/layouts/default.vue +3 -0
  156. package/app/locales/en/commands.json +5 -0
  157. package/app/locales/en/cookies.json +182 -0
  158. package/app/locales/en/error.json +4 -0
  159. package/app/locales/en/interface.json +33 -0
  160. package/app/locales/en/myelophone.json +8 -0
  161. package/app/locales/en/outdated.json +5 -0
  162. package/app/locales/en/times.json +18 -0
  163. package/app/locales/pl/commands.json +5 -0
  164. package/app/locales/pl/cookies.json +182 -0
  165. package/app/locales/pl/error.json +4 -0
  166. package/app/locales/pl/interface.json +33 -0
  167. package/app/locales/pl/myelophone.json +8 -0
  168. package/app/locales/pl/outdated.json +5 -0
  169. package/app/locales/pl/times.json +18 -0
  170. package/app/locales/ru/commands.json +5 -0
  171. package/app/locales/ru/cookies.json +182 -0
  172. package/app/locales/ru/error.json +4 -0
  173. package/app/locales/ru/interface.json +33 -0
  174. package/app/locales/ru/myelophone.json +8 -0
  175. package/app/locales/ru/outdated.json +5 -0
  176. package/app/locales/ru/times.json +18 -0
  177. package/app/middleware/blog-layout.ts +28 -0
  178. package/app/middleware/i18n.global.ts +17 -0
  179. package/app/middleware/not-found-status.ts +11 -0
  180. package/app/modules/default-blog/index.ts +39 -0
  181. package/app/modules/default-blog/posts.ts +80 -0
  182. package/app/modules/default-sitemap/index.ts +116 -0
  183. package/app/modules/default-sitemap/runtime/sitemap.get.ts +42 -0
  184. package/app/modules/fullscreen-preloader/module.ts +43 -0
  185. package/app/modules/htaccess/.htaccess +38 -0
  186. package/app/modules/htaccess/index.ts +23 -0
  187. package/app/modules/i18n-shaker.mjs +221 -0
  188. package/app/modules/multi18n/module.ts +71 -0
  189. package/app/modules/myelophone-config/module.ts +241 -0
  190. package/app/pages/[...all].vue +9 -0
  191. package/app/pages/index.vue +3 -0
  192. package/app/pages/post/[...slug].vue +30 -0
  193. package/app/plugins/bfcache-refresh.client.ts +9 -0
  194. package/app/plugins/canonical.ts +30 -0
  195. package/app/plugins/csp-nonce.server.ts +41 -0
  196. package/app/plugins/multi18n.client.ts +21 -0
  197. package/app/plugins/multi18n.server.ts +15 -0
  198. package/app/plugins/nuxt-version.client.ts +4 -0
  199. package/app/plugins/restore.client.ts +21 -0
  200. package/app/plugins/reveal.ts +89 -0
  201. package/app/plugins/url-helper.client.ts +66 -0
  202. package/app/server/api/exchange-rates.get.ts +216 -0
  203. package/app/server/api/healthz.ts +1 -0
  204. package/app/server/api/logout.post.ts +6 -0
  205. package/app/server/middleware/normalize-url.ts +14 -0
  206. package/app/server/middleware/security-headers.ts +147 -0
  207. package/app/server/middleware/url-helper.ts +43 -0
  208. package/app/server/plugins/clean-html-spaces.ts +15 -0
  209. package/app/server/plugins/clean-styles.ts +94 -0
  210. package/app/server/plugins/compression.ts +122 -0
  211. package/app/server/plugins/css-preload.ts +26 -0
  212. package/app/server/plugins/early-hints.ts +31 -0
  213. package/app/server/plugins/force-noindex.ts +43 -0
  214. package/app/server/plugins/html-one-line.ts +17 -0
  215. package/app/server/plugins/inline-style.ts +7 -0
  216. package/app/server/routes/healthz.get.ts +1 -0
  217. package/app/server/tsconfig.json +3 -0
  218. package/app/stores/cart.ts +945 -0
  219. package/app/stores/commands.ts +43 -0
  220. package/app/stores/device.ts +156 -0
  221. package/app/stores/querySync.ts +5 -0
  222. package/app/stores/settings.ts +145 -0
  223. package/app/stores/user.ts +607 -0
  224. package/app/types/cookie.ts +89 -0
  225. package/app/types/myelophone.d.ts +87 -0
  226. package/app/types/site-search.ts +110 -0
  227. package/app/utils/asyncRefresh.ts +4 -0
  228. package/app/utils/blog.server.ts +142 -0
  229. package/app/utils/jsonLd.ts +56 -0
  230. package/app/utils/myelophoneConfig.ts +4 -0
  231. package/app/utils/sortBy.ts +18 -0
  232. package/app/utils/transliterate.ts +75 -0
  233. package/app/utils/ytVideo.ts +37 -0
  234. package/app/workers/site-search.worker.ts +661 -0
  235. package/biome.json +94 -0
  236. package/commitlint.config.js +3 -0
  237. package/nuxt.config.ts +539 -0
  238. package/package.json +101 -0
  239. package/playground/content/.gitkeep +0 -0
  240. package/playground/locales/.gitkeep +0 -0
  241. package/playground/myelophone.dev.ts +45 -0
  242. package/playground/nuxt.config.ts +105 -0
  243. package/playground/package.json +5 -0
  244. package/playground/pages/.gitkeep +0 -0
  245. package/playground/tsconfig.json +3 -0
  246. package/playwright.config.ts +23 -0
  247. package/public/browsers/chrome.svg +77 -0
  248. package/public/browsers/edge.svg +98 -0
  249. package/public/browsers/firefox.svg +300 -0
  250. package/public/favicon.ico +0 -0
  251. package/public/myelophone_eng.png +0 -0
  252. package/public/myelophone_eng_white.png +0 -0
  253. package/spa-loading-template.html +72 -0
  254. package/tests/home.spec.ts +9 -0
  255. package/tests/utils.ts +23 -0
  256. package/tsconfig.json +16 -0
  257. package/vite/plugins/clean-css.ts +190 -0
  258. package/vite/plugins/postcss-add-viewportunits.ts +33 -0
  259. package/vite/plugins/postcss-viewport-fallback.ts +49 -0
@@ -0,0 +1,97 @@
1
+ <template>
2
+ <div class="relative w-full" :style="maskStyle">
3
+ <div
4
+ ref="scrollContainer"
5
+ @wheel.prevent="handleWheel"
6
+ @scroll="updateScrollState"
7
+ class="flex items-center overflow-x-auto gap-x-2 lg:gap-x-4 scrollbar-none [&::-webkit-scrollbar]:hidden"
8
+ >
9
+ <NuxtLink
10
+ v-for="item in items"
11
+ :key="item.path"
12
+ :to="item.path"
13
+ class="py-2 px-3 rounded-md text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors duration-200 whitespace-nowrap"
14
+ active-class="bg-gray-200 dark:bg-gray-700 !text-gray-900 dark:!text-white font-semibold"
15
+ >
16
+ {{ item.label }}
17
+ </NuxtLink>
18
+ </div>
19
+ </div>
20
+ </template>
21
+
22
+ <script setup lang="ts">
23
+ defineProps({
24
+ items: {
25
+ type: Array as () => { label: string; path: string }[],
26
+ required: true,
27
+ default: () => [],
28
+ },
29
+ });
30
+
31
+ const scrollContainer = ref<HTMLElement | null>(null);
32
+ const handleWheel = (event: WheelEvent) => {
33
+ if (scrollContainer.value) {
34
+ scrollContainer.value.scrollLeft += event.deltaY;
35
+ }
36
+ };
37
+
38
+ const hasOverflow = ref(false);
39
+ const isScrolledToStart = ref(true);
40
+ const isScrolledToEnd = ref(false);
41
+
42
+ const updateScrollState = () => {
43
+ const el = scrollContainer.value;
44
+ if (!el) return;
45
+
46
+ const overflow = el.scrollWidth > el.clientWidth;
47
+ hasOverflow.value = overflow;
48
+
49
+ if (overflow) {
50
+ isScrolledToStart.value = el.scrollLeft < 1;
51
+ isScrolledToEnd.value =
52
+ Math.abs(el.scrollWidth - el.clientWidth - el.scrollLeft) < 1;
53
+ } else {
54
+ isScrolledToStart.value = true;
55
+ isScrolledToEnd.value = true;
56
+ }
57
+ };
58
+
59
+ const maskStyle = computed(() => {
60
+ if (!hasOverflow.value) {
61
+ return {};
62
+ }
63
+
64
+ const fadeWidth = "2rem";
65
+ let gradient: string;
66
+
67
+ if (isScrolledToStart.value) {
68
+ gradient = `linear-gradient(to right, black calc(100% - ${fadeWidth}), transparent)`;
69
+ } else if (isScrolledToEnd.value) {
70
+ gradient = `linear-gradient(to left, black calc(100% - ${fadeWidth}), transparent)`;
71
+ } else {
72
+ gradient = `linear-gradient(to right, transparent, black ${fadeWidth}, black calc(100% - ${fadeWidth}), transparent)`;
73
+ }
74
+
75
+ return {
76
+ "mask-image": gradient,
77
+ "-webkit-mask-image": gradient,
78
+ };
79
+ });
80
+
81
+ onMounted(() => {
82
+ nextTick(() => {
83
+ updateScrollState();
84
+ window.addEventListener("resize", updateScrollState);
85
+ });
86
+ });
87
+
88
+ onUnmounted(() => {
89
+ window.removeEventListener("resize", updateScrollState);
90
+ });
91
+ </script>
92
+
93
+ <style scoped>
94
+ div {
95
+ scrollbar-width: none;
96
+ }
97
+ </style>
@@ -0,0 +1,141 @@
1
+ <template>
2
+ <div
3
+ ref="container"
4
+ class="relative w-full h-full select-none touch-none isolate rounded-xl overflow-hidden cursor-ew-resize group bg-(--ui-bg) transform-gpu"
5
+ @mousedown="startSliding"
6
+ @touchstart="startSliding"
7
+ >
8
+ <div class="absolute inset-0 w-full h-full z-0">
9
+ <ImgWithLoader
10
+ :src="afterImage"
11
+ class="block w-full h-full object-cover pointer-events-none select-none"
12
+ draggable="false"
13
+ />
14
+
15
+ <div class="absolute bottom-4 right-4 z-40 pointer-events-none">
16
+ <span
17
+ class="bg-black/60 backdrop-blur-md text-white px-3 py-1 text-xs font-bold rounded whitespace-nowrap shadow-lg"
18
+ >
19
+ {{ afterLabel }}
20
+ </span>
21
+ </div>
22
+ </div>
23
+
24
+ <div
25
+ class="absolute inset-0 w-full h-full z-10 will-change-[clip-path]"
26
+ :style="{ clipPath: `inset(0 ${100 - position}% 0 0)` }"
27
+ >
28
+ <div class="relative w-full h-full z-0">
29
+ <ImgWithLoader
30
+ :src="beforeImage"
31
+ class="block w-full h-full object-cover pointer-events-none select-none"
32
+ draggable="false"
33
+ />
34
+ </div>
35
+
36
+ <div class="absolute bottom-4 left-4 z-40 pointer-events-none">
37
+ <span
38
+ class="bg-black/60 backdrop-blur-md text-white px-3 py-1 text-xs font-bold rounded whitespace-nowrap shadow-lg"
39
+ >
40
+ {{ beforeLabel }}
41
+ </span>
42
+ </div>
43
+ </div>
44
+
45
+ <div
46
+ class="absolute top-0 bottom-0 z-30 w-0.5 bg-white cursor-ew-resize pointer-events-none"
47
+ :style="{ left: `${position}%` }"
48
+ >
49
+ <div
50
+ class="absolute inset-0 bg-white shadow-[0_0_10px_rgba(0,0,0,0.5)]"
51
+ ></div>
52
+ <div
53
+ class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-8 h-8 bg-white text-gray-900 rounded-full flex items-center justify-center shadow-[0_4px_12px_rgba(0,0,0,0.3)] transform transition-transform group-active:scale-110"
54
+ >
55
+ <svg
56
+ xmlns="http://www.w3.org/2000/svg"
57
+ width="16"
58
+ height="16"
59
+ viewBox="0 0 24 24"
60
+ fill="none"
61
+ stroke="currentColor"
62
+ stroke-width="2.5"
63
+ stroke-linecap="round"
64
+ stroke-linejoin="round"
65
+ >
66
+ <path d="m15 18-6-6 6-6" />
67
+ </svg>
68
+ <svg
69
+ xmlns="http://www.w3.org/2000/svg"
70
+ width="16"
71
+ height="16"
72
+ viewBox="0 0 24 24"
73
+ fill="none"
74
+ stroke="currentColor"
75
+ stroke-width="2.5"
76
+ stroke-linecap="round"
77
+ stroke-linejoin="round"
78
+ >
79
+ <path d="m9 18 6-6-6-6" />
80
+ </svg>
81
+ </div>
82
+ </div>
83
+
84
+ <div
85
+ class="absolute inset-0 z-50 rounded-xl pointer-events-none ring-1 ring-inset ring-(--ui-text)/20"
86
+ ></div>
87
+ </div>
88
+ </template>
89
+
90
+ <script setup>
91
+ const props = defineProps({
92
+ beforeImage: String,
93
+ afterImage: String,
94
+ beforeLabel: String,
95
+ afterLabel: String,
96
+ });
97
+
98
+ const container = ref(null);
99
+ const position = ref(50);
100
+ const isSliding = ref(false);
101
+
102
+ const startSliding = (e) => {
103
+ isSliding.value = true;
104
+ move(e);
105
+ window.addEventListener("mousemove", move);
106
+ window.addEventListener("mouseup", stopSliding);
107
+ window.addEventListener("touchmove", move, { passive: false });
108
+ window.addEventListener("touchend", stopSliding);
109
+ };
110
+
111
+ const stopSliding = () => {
112
+ isSliding.value = false;
113
+ window.removeEventListener("mousemove", move);
114
+ window.removeEventListener("mouseup", stopSliding);
115
+ window.removeEventListener("touchmove", move);
116
+ window.removeEventListener("touchend", stopSliding);
117
+ };
118
+
119
+ const move = (e) => {
120
+ if (!isSliding.value || !container.value) return;
121
+
122
+ let pageX;
123
+ if (e.touches && e.touches.length > 0) {
124
+ pageX = e.touches[0].clientX;
125
+ } else {
126
+ pageX = e.clientX;
127
+ }
128
+
129
+ const rect = container.value.getBoundingClientRect();
130
+ let x = pageX - rect.left;
131
+
132
+ if (x < 0) x = 0;
133
+ if (x > rect.width) x = rect.width;
134
+
135
+ position.value = (x / rect.width) * 100;
136
+ };
137
+
138
+ onUnmounted(() => {
139
+ stopSliding();
140
+ });
141
+ </script>
@@ -0,0 +1,333 @@
1
+ <script setup lang="ts">
2
+ export type ImageItem = { type: "image"; uri: string };
3
+ export type VideoItem = { type: "video"; uri: string; poster?: string };
4
+ export type MediaItem = ImageItem | VideoItem;
5
+
6
+ const props = withDefaults(
7
+ defineProps<{
8
+ media: MediaItem[];
9
+ autoScroll?: boolean;
10
+ autoScrollInterval?: number;
11
+ vertical?: boolean;
12
+ }>(),
13
+ {
14
+ autoScroll: true,
15
+ autoScrollInterval: 4000,
16
+ vertical: false,
17
+ },
18
+ );
19
+
20
+ const activeIndex = ref(0);
21
+ const scrollerRef = ref<HTMLElement | null>(null);
22
+ const videoRefs = ref<(HTMLVideoElement | null)[]>([]);
23
+ const scrollIntervalId = ref<any>(null);
24
+ const isAutoScrollDisabled = ref(false);
25
+
26
+ const stopAutoScrollPermanently = () => {
27
+ isAutoScrollDisabled.value = true;
28
+ if (scrollIntervalId.value) {
29
+ clearInterval(scrollIntervalId.value);
30
+ scrollIntervalId.value = null;
31
+ }
32
+ };
33
+
34
+ const onScroll = () => {
35
+ if (!scrollerRef.value) return;
36
+ const scrollLeft = scrollerRef.value.scrollLeft;
37
+ const width = scrollerRef.value.clientWidth;
38
+ const index = Math.round(scrollLeft / width);
39
+
40
+ if (
41
+ index !== activeIndex.value &&
42
+ index >= 0 &&
43
+ index < props.media.length
44
+ ) {
45
+ activeIndex.value = index;
46
+ }
47
+ };
48
+
49
+ const scrollToSlide = (index: number, isManual = false) => {
50
+ if (isManual) stopAutoScrollPermanently();
51
+
52
+ if (!scrollerRef.value) return;
53
+ const width = scrollerRef.value.clientWidth;
54
+ scrollerRef.value.scrollTo({
55
+ left: index * width,
56
+ behavior: "smooth",
57
+ });
58
+ };
59
+
60
+ const nextSlide = (isManual = false) => {
61
+ const nextIndex = (activeIndex.value + 1) % props.media.length;
62
+ scrollToSlide(nextIndex, isManual);
63
+ };
64
+
65
+ const prevSlide = (isManual = false) => {
66
+ const prevIndex =
67
+ (activeIndex.value - 1 + props.media.length) % props.media.length;
68
+ scrollToSlide(prevIndex, isManual);
69
+ };
70
+
71
+ const manageVideos = async () => {
72
+ await nextTick();
73
+ props.media.forEach((item, i) => {
74
+ if (item.type !== "video") return;
75
+ const videoEl = videoRefs.value[i];
76
+ if (!videoEl) return;
77
+
78
+ if (i === activeIndex.value) {
79
+ videoEl.play().catch(() => {});
80
+ } else {
81
+ videoEl.pause();
82
+ videoEl.currentTime = 0;
83
+ }
84
+ });
85
+ };
86
+
87
+ const handleTouchStart = () => {
88
+ stopAutoScrollPermanently();
89
+ };
90
+
91
+ watch(activeIndex, () => {
92
+ manageVideos();
93
+ });
94
+
95
+ onMounted(() => {
96
+ manageVideos();
97
+
98
+ if (
99
+ props.autoScroll &&
100
+ props.media.length > 1 &&
101
+ !isAutoScrollDisabled.value
102
+ ) {
103
+ scrollIntervalId.value = setInterval(() => {
104
+ nextSlide(false);
105
+ }, props.autoScrollInterval);
106
+ }
107
+ });
108
+
109
+ onUnmounted(() => {
110
+ if (scrollIntervalId.value) clearInterval(scrollIntervalId.value);
111
+ });
112
+
113
+ const setVideoRef = (el: any, index: number) => {
114
+ videoRefs.value[index] = el as HTMLVideoElement;
115
+ };
116
+ </script>
117
+
118
+ <template>
119
+ <div
120
+ class="slider-root"
121
+ :class="{ 'is-vertical-mode': vertical }"
122
+ @touchstart.passive="handleTouchStart"
123
+ @mousedown="handleTouchStart"
124
+ >
125
+ <div ref="scrollerRef" class="scroller" @scroll.passive="onScroll">
126
+ <div v-for="(item, index) in media" :key="index" class="slide">
127
+ <ImgWithLoader
128
+ v-if="item.type === 'image'"
129
+ :src="item.uri"
130
+ class="media-content"
131
+ loading="lazy"
132
+ draggable="false"
133
+ />
134
+
135
+ <video
136
+ v-else
137
+ :ref="(el) => setVideoRef(el, index)"
138
+ :src="item.uri"
139
+ :poster="item.poster"
140
+ class="media-content"
141
+ playsinline
142
+ loop
143
+ muted
144
+ preload="metadata"
145
+ ></video>
146
+ </div>
147
+ </div>
148
+
149
+ <template v-if="media.length > 1">
150
+ <button
151
+ class="nav-btn prev"
152
+ @click.stop="prevSlide(true)"
153
+ aria-label="Previous slide"
154
+ >
155
+ <svg
156
+ xmlns="http://www.w3.org/2000/svg"
157
+ fill="none"
158
+ viewBox="0 0 24 24"
159
+ stroke-width="2.5"
160
+ stroke="currentColor"
161
+ >
162
+ <path
163
+ stroke-linecap="round"
164
+ stroke-linejoin="round"
165
+ d="M15.75 19.5L8.25 12l7.5-7.5"
166
+ />
167
+ </svg>
168
+ </button>
169
+
170
+ <button
171
+ class="nav-btn next"
172
+ @click.stop="nextSlide(true)"
173
+ aria-label="Next slide"
174
+ >
175
+ <svg
176
+ xmlns="http://www.w3.org/2000/svg"
177
+ fill="none"
178
+ viewBox="0 0 24 24"
179
+ stroke-width="2.5"
180
+ stroke="currentColor"
181
+ >
182
+ <path
183
+ stroke-linecap="round"
184
+ stroke-linejoin="round"
185
+ d="M8.25 4.5l7.5 7.5-7.5 7.5"
186
+ />
187
+ </svg>
188
+ </button>
189
+ </template>
190
+
191
+ <div class="dots-container">
192
+ <div
193
+ v-for="(_, i) in media"
194
+ :key="i"
195
+ class="dot"
196
+ :class="{ active: i === activeIndex }"
197
+ @click.stop="scrollToSlide(i, true)"
198
+ ></div>
199
+ </div>
200
+ </div>
201
+ </template>
202
+
203
+ <style scoped>
204
+ .slider-root {
205
+ position: relative;
206
+ width: 100%;
207
+ overflow: hidden;
208
+ touch-action: pan-x;
209
+ height: 230px;
210
+ max-height: 90vh;
211
+ }
212
+
213
+ @media (min-width: 769px) {
214
+ .slider-root {
215
+ height: 500px;
216
+ }
217
+ }
218
+
219
+ .slider-root.is-vertical-mode {
220
+ width: 500px;
221
+ max-width: 100%;
222
+ height: 90vh;
223
+ margin: 0 auto;
224
+ }
225
+
226
+ @media (min-width: 769px) {
227
+ .slider-root.is-vertical-mode {
228
+ height: 720px;
229
+ }
230
+ }
231
+
232
+ .scroller {
233
+ display: flex;
234
+ width: 100%;
235
+ height: 100%;
236
+ overflow-x: auto;
237
+ overflow-y: hidden;
238
+ scroll-snap-type: x mandatory;
239
+ scroll-behavior: smooth;
240
+ scrollbar-width: none;
241
+ }
242
+ .scroller::-webkit-scrollbar {
243
+ display: none;
244
+ }
245
+
246
+ .slide {
247
+ flex: 0 0 100%;
248
+ width: 100%;
249
+ height: 100%;
250
+ scroll-snap-align: center;
251
+ position: relative;
252
+ scroll-snap-stop: always;
253
+ }
254
+
255
+ .media-content {
256
+ width: 100%;
257
+ height: 100%;
258
+ object-fit: cover;
259
+ display: block;
260
+ border-radius: 0.5rem;
261
+ }
262
+
263
+ .nav-btn {
264
+ position: absolute;
265
+ top: 50%;
266
+ transform: translateY(-50%);
267
+ width: 44px;
268
+ height: 44px;
269
+ border-radius: 50%;
270
+ color: white;
271
+ display: flex;
272
+ align-items: center;
273
+ justify-content: center;
274
+ cursor: pointer;
275
+ z-index: 20;
276
+ transition: all 0.2s ease;
277
+ opacity: 0;
278
+ }
279
+
280
+ .nav-btn svg {
281
+ width: 24px;
282
+ height: 24px;
283
+ }
284
+
285
+ .slider-root:hover .nav-btn {
286
+ opacity: 1;
287
+ }
288
+
289
+ .nav-btn:hover {
290
+ opacity: 1;
291
+ }
292
+
293
+ .prev {
294
+ left: 16px;
295
+ }
296
+
297
+ .next {
298
+ right: 16px;
299
+ }
300
+
301
+ .dots-container {
302
+ position: absolute;
303
+ bottom: 16px;
304
+ width: 100%;
305
+ display: flex;
306
+ justify-content: center;
307
+ gap: 8px;
308
+ z-index: 10;
309
+ pointer-events: none;
310
+ }
311
+
312
+ .dot {
313
+ height: 6px;
314
+ width: 6px;
315
+ border-radius: 3px;
316
+ background-color: rgba(255, 255, 255, 0.5);
317
+ transition: all 0.3s ease;
318
+ cursor: pointer;
319
+ pointer-events: auto;
320
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
321
+ }
322
+
323
+ .dot.active {
324
+ background-color: #fff;
325
+ width: 16px;
326
+ }
327
+
328
+ @media (max-width: 768px) {
329
+ .nav-btn {
330
+ display: none !important;
331
+ }
332
+ }
333
+ </style>
@@ -0,0 +1,147 @@
1
+ <template>
2
+ <div
3
+ ref="container"
4
+ class="relative w-full overflow-hidden group fade-mask"
5
+ :class="containerClass"
6
+ >
7
+ <div
8
+ ref="track"
9
+ class="marquee-track group-hover:!paused"
10
+ :class="{ 'is-running': isStarted }"
11
+ :style="trackStyle"
12
+ >
13
+ <div ref="source" class="marquee-content">
14
+ <span
15
+ v-for="(item, i) in items"
16
+ :key="i"
17
+ class="px-8 uppercase"
18
+ >
19
+ {{ item }}
20
+ </span>
21
+ </div>
22
+ </div>
23
+ </div>
24
+ </template>
25
+
26
+ <script setup lang="ts">
27
+ const props = defineProps<{
28
+ items: string[];
29
+ duration?: number;
30
+ delay?: number;
31
+ containerClass?: string;
32
+ }>();
33
+
34
+ const container = ref<HTMLElement>();
35
+ const track = ref<HTMLElement>();
36
+ const source = ref<HTMLElement>();
37
+ const isStarted = ref(false);
38
+
39
+ let resizeObserver: ResizeObserver | null = null;
40
+ let startTimeout: number | null = null;
41
+
42
+ function rebuild() {
43
+ if (!container.value || !track.value || !source.value) return;
44
+
45
+ isStarted.value = false;
46
+ track.value.innerHTML = "";
47
+ track.value.appendChild(source.value);
48
+
49
+ const containerWidth = container.value.offsetWidth;
50
+ const sourceWidth = source.value.offsetWidth;
51
+ if (!sourceWidth) return;
52
+
53
+ const copies = Math.ceil((containerWidth * 2) / sourceWidth);
54
+ for (let i = 0; i < copies; i++) {
55
+ const clone = source.value.cloneNode(true) as HTMLElement;
56
+ clone.setAttribute("aria-hidden", "true");
57
+ clone.classList.add("clone-fade-in");
58
+ track.value.appendChild(clone);
59
+ }
60
+
61
+ track.value.style.setProperty("--marquee-distance", `${sourceWidth}px`);
62
+
63
+ startTimeout && clearTimeout(startTimeout);
64
+ startTimeout = window.setTimeout(() => {
65
+ isStarted.value = true;
66
+ }, props.delay ?? 1000);
67
+ }
68
+
69
+ onMounted(async () => {
70
+ await nextTick();
71
+ rebuild();
72
+ resizeObserver = new ResizeObserver(() => rebuild());
73
+ resizeObserver.observe(container.value!);
74
+ });
75
+
76
+ onBeforeUnmount(() => {
77
+ resizeObserver?.disconnect();
78
+ startTimeout && clearTimeout(startTimeout);
79
+ });
80
+
81
+ const trackStyle = computed(() => ({
82
+ animationDuration: `${props.duration ?? 30}s`,
83
+ }));
84
+ </script>
85
+
86
+ <style scoped>
87
+ @keyframes marquee {
88
+ from {
89
+ transform: translate3d(0, 0, 0);
90
+ }
91
+ to {
92
+ transform: translate3d(calc(-1 * var(--marquee-distance)), 0, 0);
93
+ }
94
+ }
95
+
96
+ @keyframes fadeIn {
97
+ from {
98
+ opacity: 0;
99
+ }
100
+ to {
101
+ opacity: 1;
102
+ }
103
+ }
104
+
105
+ .marquee-track {
106
+ display: flex;
107
+ width: max-content;
108
+ will-change: transform;
109
+ animation: marquee linear infinite;
110
+ animation-play-state: paused;
111
+ }
112
+
113
+ .marquee-track.is-running {
114
+ animation-play-state: running;
115
+ }
116
+
117
+ .group:hover .marquee-track {
118
+ animation-play-state: paused !important;
119
+ }
120
+
121
+ .marquee-content {
122
+ display: flex;
123
+ white-space: nowrap;
124
+ flex-shrink: 0;
125
+ }
126
+
127
+ .clone-fade-in {
128
+ animation: fadeIn 0.5s ease-out forwards;
129
+ }
130
+
131
+ .fade-mask {
132
+ mask-image: linear-gradient(
133
+ to right,
134
+ transparent,
135
+ black 2rem,
136
+ black calc(100% - 2rem),
137
+ transparent
138
+ );
139
+ -webkit-mask-image: linear-gradient(
140
+ to right,
141
+ transparent,
142
+ black 2rem,
143
+ black calc(100% - 2rem),
144
+ transparent
145
+ );
146
+ }
147
+ </style>