@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.
- package/.devcontainer/Dockerfile +7 -0
- package/.devcontainer/devcontainer.json +21 -0
- package/.editorconfig +43 -0
- package/.github/workflows/package.yml +73 -0
- package/.nuxtignore +6 -0
- package/.releaserc.js +132 -0
- package/.yarn/releases/yarn-4.18.0.cjs +1000 -0
- package/.yarnrc.yml +8 -0
- package/CHANGELOG.md +141 -0
- package/LICENSE +77 -0
- package/README.md +3004 -0
- package/app/app.vue +455 -0
- package/app/assets/css/animation.css +81 -0
- package/app/assets/css/backgrounds.css +57 -0
- package/app/assets/css/base.css +182 -0
- package/app/assets/css/index.css +9 -0
- package/app/assets/css/links.css +12 -0
- package/app/assets/css/multimedia.css +102 -0
- package/app/assets/css/preloader.css +68 -0
- package/app/assets/css/print.css +40 -0
- package/app/assets/css/tailwind.css +20 -0
- package/app/assets/css/theme.css +29 -0
- package/app/components/consent/GoogleMap.vue +59 -0
- package/app/components/consent/Youtube.vue +27 -0
- package/app/components/cookie/Banner.vue +70 -0
- package/app/components/cookie/ConsentWrapper.vue +71 -0
- package/app/components/cookie/PrivacyPolicy.vue +179 -0
- package/app/components/cookie/SettingsModal.vue +387 -0
- package/app/components/grid/Col.vue +262 -0
- package/app/components/grid/Container.vue +236 -0
- package/app/components/grid/Row.vue +248 -0
- package/app/components/grid/Stack.vue +233 -0
- package/app/components/myelophone/Copyright.vue +5 -0
- package/app/components/myelophone/Welcome.vue +107 -0
- package/app/components/page/FullscreenPreloader.vue +177 -0
- package/app/components/page/Preloader.vue +18 -0
- package/app/components/page/ReadyLocalized.vue +19 -0
- package/app/components/ready/.gitkeep +0 -0
- package/app/components/safe/Email.vue +52 -0
- package/app/components/safe/ImgWithLoader.vue +180 -0
- package/app/components/safe/NuxtImg.vue +25 -0
- package/app/components/safe/NuxtPicture.vue +29 -0
- package/app/components/section/.gitkeep +0 -0
- package/app/components/seo/BrandInfo.vue +76 -0
- package/app/components/seo/ContentNoIndex.vue +35 -0
- package/app/components/seo/NoIndex.vue +22 -0
- package/app/components/seo/OrgInfo.vue +130 -0
- package/app/components/seo/ProfileInfo.vue +137 -0
- package/app/components/ui/Accordion.vue +163 -0
- package/app/components/ui/Alert.vue +179 -0
- package/app/components/ui/Avatar.vue +88 -0
- package/app/components/ui/Badge.vue +150 -0
- package/app/components/ui/Banner.vue +133 -0
- package/app/components/ui/Button.vue +175 -0
- package/app/components/ui/Card.vue +66 -0
- package/app/components/ui/Checkbox.vue +134 -0
- package/app/components/ui/Chip.vue +136 -0
- package/app/components/ui/CommandPalette.vue +434 -0
- package/app/components/ui/Console.vue +583 -0
- package/app/components/ui/CursorCreative.vue +148 -0
- package/app/components/ui/FeatureAccordion.vue +165 -0
- package/app/components/ui/FileUpload.vue +705 -0
- package/app/components/ui/GeoDependent.vue +72 -0
- package/app/components/ui/Heading.vue +51 -0
- package/app/components/ui/Icon.vue +42 -0
- package/app/components/ui/Icon8.vue +39 -0
- package/app/components/ui/Input.vue +88 -0
- package/app/components/ui/LangLink.vue +34 -0
- package/app/components/ui/LangVisible.vue +33 -0
- package/app/components/ui/LanguageSelect.vue +202 -0
- package/app/components/ui/LightBox.vue +155 -0
- package/app/components/ui/LocalTime.vue +170 -0
- package/app/components/ui/Modal.vue +161 -0
- package/app/components/ui/Popup.vue +200 -0
- package/app/components/ui/PostContent.server.vue +23 -0
- package/app/components/ui/ProtectedEmail.vue +52 -0
- package/app/components/ui/RelativeTime.vue +141 -0
- package/app/components/ui/ScheduledContent.vue +150 -0
- package/app/components/ui/ScrollToTop.client.vue +48 -0
- package/app/components/ui/SegmentedControl.vue +148 -0
- package/app/components/ui/SiteSearch.vue +1191 -0
- package/app/components/ui/Skeleton.vue +91 -0
- package/app/components/ui/SmartContrast.vue +74 -0
- package/app/components/ui/SnapContainer.vue +222 -0
- package/app/components/ui/SnapSection.vue +294 -0
- package/app/components/ui/SonnerStyle.vue +7 -0
- package/app/components/ui/SplitSection.vue +99 -0
- package/app/components/ui/Steps.vue +858 -0
- package/app/components/ui/StickyWrapper.vue +46 -0
- package/app/components/ui/Table.vue +251 -0
- package/app/components/ui/Tabs.vue +451 -0
- package/app/components/ui/TextColumn.vue +36 -0
- package/app/components/ui/Textarea.vue +251 -0
- package/app/components/ui/Toggler.vue +40 -0
- package/app/components/ui/Tooltip.vue +524 -0
- package/app/components/ui/TruncateText.vue +105 -0
- package/app/components/ui/ViewportSpacer.vue +72 -0
- package/app/components/view/AnimatedCounter.vue +121 -0
- package/app/components/view/AnnouncementBar.vue +104 -0
- package/app/components/view/AvatarGroup.vue +104 -0
- package/app/components/view/Breadcrumbs.vue +97 -0
- package/app/components/view/ContentWithToc.vue +152 -0
- package/app/components/view/Copyright.vue +68 -0
- package/app/components/view/CountdownTimer.vue +184 -0
- package/app/components/view/CreativeCTA.vue +143 -0
- package/app/components/view/CurrencySelect.vue +254 -0
- package/app/components/view/FeatureBoxGrid.vue +142 -0
- package/app/components/view/HorizontalMenu.vue +97 -0
- package/app/components/view/ImageCompare.vue +141 -0
- package/app/components/view/ImgSlider.vue +333 -0
- package/app/components/view/InfiniteMarquee.vue +147 -0
- package/app/components/view/InfoBar.vue +86 -0
- package/app/components/view/LogoGrid.vue +106 -0
- package/app/components/view/LogoSlider.vue +83 -0
- package/app/components/view/NotFound.vue +81 -0
- package/app/components/view/PartialBackground.vue +313 -0
- package/app/components/view/QuoteBig.vue +111 -0
- package/app/components/view/ResponsiveMenu.vue +219 -0
- package/app/components/view/ReviewsSlider.vue +230 -0
- package/app/components/view/SocialBar.vue +78 -0
- package/app/components/view/StickyHeadingContent.vue +158 -0
- package/app/components/view/TallyForm.vue +295 -0
- package/app/components/view/WarningOutdated.vue +113 -0
- package/app/composables/useApi.ts +88 -0
- package/app/composables/useAppSeo.ts +78 -0
- package/app/composables/useBreadcrumbs.ts +106 -0
- package/app/composables/useChangeUrl.ts +73 -0
- package/app/composables/useCommand.ts +28 -0
- package/app/composables/useCookieControl.ts +111 -0
- package/app/composables/useCookieModal.ts +9 -0
- package/app/composables/useDevice.ts +109 -0
- package/app/composables/useGeoFetch.ts +139 -0
- package/app/composables/useLoadScript.ts +36 -0
- package/app/composables/useModalState.ts +37 -0
- package/app/composables/useMultiLang.ts +278 -0
- package/app/composables/useNetwork.ts +49 -0
- package/app/composables/useNuxtVersion.ts +5 -0
- package/app/composables/usePiniaStore.ts +5 -0
- package/app/composables/usePopupControl.ts +57 -0
- package/app/composables/useQuery.ts +307 -0
- package/app/composables/useReadyPage.ts +182 -0
- package/app/composables/useSafeList.ts +90 -0
- package/app/composables/useScriptLoader.ts +221 -0
- package/app/composables/useSiteSearch.ts +32 -0
- package/app/composables/useSnapScroll.ts +24 -0
- package/app/composables/useStatic.ts +5 -0
- package/app/composables/useStorage.ts +252 -0
- package/app/composables/useStoreBroadcast.ts +146 -0
- package/app/composables/useThemeSync.ts +81 -0
- package/app/constants/layout.ts +109 -0
- package/app/constants/predefinedCookieScripts.ts +1222 -0
- package/app/constants/ui-events.ts +1 -0
- package/app/error.vue +169 -0
- package/app/layouts/default-blog.vue +5 -0
- package/app/layouts/default.vue +3 -0
- package/app/locales/en/commands.json +5 -0
- package/app/locales/en/cookies.json +182 -0
- package/app/locales/en/error.json +4 -0
- package/app/locales/en/interface.json +33 -0
- package/app/locales/en/myelophone.json +8 -0
- package/app/locales/en/outdated.json +5 -0
- package/app/locales/en/times.json +18 -0
- package/app/locales/pl/commands.json +5 -0
- package/app/locales/pl/cookies.json +182 -0
- package/app/locales/pl/error.json +4 -0
- package/app/locales/pl/interface.json +33 -0
- package/app/locales/pl/myelophone.json +8 -0
- package/app/locales/pl/outdated.json +5 -0
- package/app/locales/pl/times.json +18 -0
- package/app/locales/ru/commands.json +5 -0
- package/app/locales/ru/cookies.json +182 -0
- package/app/locales/ru/error.json +4 -0
- package/app/locales/ru/interface.json +33 -0
- package/app/locales/ru/myelophone.json +8 -0
- package/app/locales/ru/outdated.json +5 -0
- package/app/locales/ru/times.json +18 -0
- package/app/middleware/blog-layout.ts +28 -0
- package/app/middleware/i18n.global.ts +17 -0
- package/app/middleware/not-found-status.ts +11 -0
- package/app/modules/default-blog/index.ts +39 -0
- package/app/modules/default-blog/posts.ts +80 -0
- package/app/modules/default-sitemap/index.ts +116 -0
- package/app/modules/default-sitemap/runtime/sitemap.get.ts +42 -0
- package/app/modules/fullscreen-preloader/module.ts +43 -0
- package/app/modules/htaccess/.htaccess +38 -0
- package/app/modules/htaccess/index.ts +23 -0
- package/app/modules/i18n-shaker.mjs +221 -0
- package/app/modules/multi18n/module.ts +71 -0
- package/app/modules/myelophone-config/module.ts +241 -0
- package/app/pages/[...all].vue +9 -0
- package/app/pages/index.vue +3 -0
- package/app/pages/post/[...slug].vue +30 -0
- package/app/plugins/bfcache-refresh.client.ts +9 -0
- package/app/plugins/canonical.ts +30 -0
- package/app/plugins/csp-nonce.server.ts +41 -0
- package/app/plugins/multi18n.client.ts +21 -0
- package/app/plugins/multi18n.server.ts +15 -0
- package/app/plugins/nuxt-version.client.ts +4 -0
- package/app/plugins/restore.client.ts +21 -0
- package/app/plugins/reveal.ts +89 -0
- package/app/plugins/url-helper.client.ts +66 -0
- package/app/server/api/exchange-rates.get.ts +216 -0
- package/app/server/api/healthz.ts +1 -0
- package/app/server/api/logout.post.ts +6 -0
- package/app/server/middleware/normalize-url.ts +14 -0
- package/app/server/middleware/security-headers.ts +147 -0
- package/app/server/middleware/url-helper.ts +43 -0
- package/app/server/plugins/clean-html-spaces.ts +15 -0
- package/app/server/plugins/clean-styles.ts +94 -0
- package/app/server/plugins/compression.ts +122 -0
- package/app/server/plugins/css-preload.ts +26 -0
- package/app/server/plugins/early-hints.ts +31 -0
- package/app/server/plugins/force-noindex.ts +43 -0
- package/app/server/plugins/html-one-line.ts +17 -0
- package/app/server/plugins/inline-style.ts +7 -0
- package/app/server/routes/healthz.get.ts +1 -0
- package/app/server/tsconfig.json +3 -0
- package/app/stores/cart.ts +945 -0
- package/app/stores/commands.ts +43 -0
- package/app/stores/device.ts +156 -0
- package/app/stores/querySync.ts +5 -0
- package/app/stores/settings.ts +145 -0
- package/app/stores/user.ts +607 -0
- package/app/types/cookie.ts +89 -0
- package/app/types/myelophone.d.ts +87 -0
- package/app/types/site-search.ts +110 -0
- package/app/utils/asyncRefresh.ts +4 -0
- package/app/utils/blog.server.ts +142 -0
- package/app/utils/jsonLd.ts +56 -0
- package/app/utils/myelophoneConfig.ts +4 -0
- package/app/utils/sortBy.ts +18 -0
- package/app/utils/transliterate.ts +75 -0
- package/app/utils/ytVideo.ts +37 -0
- package/app/workers/site-search.worker.ts +661 -0
- package/biome.json +94 -0
- package/commitlint.config.js +3 -0
- package/nuxt.config.ts +539 -0
- package/package.json +101 -0
- package/playground/content/.gitkeep +0 -0
- package/playground/locales/.gitkeep +0 -0
- package/playground/myelophone.dev.ts +45 -0
- package/playground/nuxt.config.ts +105 -0
- package/playground/package.json +5 -0
- package/playground/pages/.gitkeep +0 -0
- package/playground/tsconfig.json +3 -0
- package/playwright.config.ts +23 -0
- package/public/browsers/chrome.svg +77 -0
- package/public/browsers/edge.svg +98 -0
- package/public/browsers/firefox.svg +300 -0
- package/public/favicon.ico +0 -0
- package/public/myelophone_eng.png +0 -0
- package/public/myelophone_eng_white.png +0 -0
- package/spa-loading-template.html +72 -0
- package/tests/home.spec.ts +9 -0
- package/tests/utils.ts +23 -0
- package/tsconfig.json +16 -0
- package/vite/plugins/clean-css.ts +190 -0
- package/vite/plugins/postcss-add-viewportunits.ts +33 -0
- package/vite/plugins/postcss-viewport-fallback.ts +49 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
interface Props {
|
|
3
|
+
user: string;
|
|
4
|
+
domain: string;
|
|
5
|
+
tld?: string;
|
|
6
|
+
subject?: string;
|
|
7
|
+
class?: string;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
12
|
+
tld: "com",
|
|
13
|
+
placeholder: "[email hidden]",
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const email = ref("");
|
|
17
|
+
const href = ref("");
|
|
18
|
+
const visible = ref(false);
|
|
19
|
+
|
|
20
|
+
onMounted(() => {
|
|
21
|
+
const el = document.querySelector(
|
|
22
|
+
`[data-email-user="${props.user}"][data-email-domain="${props.domain}"]`,
|
|
23
|
+
) as HTMLElement | null;
|
|
24
|
+
if (!el) return;
|
|
25
|
+
|
|
26
|
+
const user = el.dataset.emailUser ?? "";
|
|
27
|
+
const domain = el.dataset.emailDomain ?? "";
|
|
28
|
+
const tld = el.dataset.emailTld ?? "";
|
|
29
|
+
const full = `${user}@${domain}.${tld}`;
|
|
30
|
+
|
|
31
|
+
email.value = full;
|
|
32
|
+
href.value = `mailto:${full}${props.subject ? `?subject=${encodeURIComponent(props.subject)}` : ""}`;
|
|
33
|
+
visible.value = true;
|
|
34
|
+
});
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<template>
|
|
38
|
+
<span
|
|
39
|
+
v-if="!visible"
|
|
40
|
+
:class="props.class"
|
|
41
|
+
:data-email-user="props.user"
|
|
42
|
+
:data-email-domain="props.domain"
|
|
43
|
+
:data-email-tld="props.tld"
|
|
44
|
+
>
|
|
45
|
+
<noscript>[email protected]</noscript>
|
|
46
|
+
{{ props.placeholder }}
|
|
47
|
+
</span>
|
|
48
|
+
|
|
49
|
+
<a v-else :href="href" :class="props.class" @click.stop>
|
|
50
|
+
<slot>{{ email }}</slot>
|
|
51
|
+
</a>
|
|
52
|
+
</template>
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
const props = defineProps({
|
|
3
|
+
date: {
|
|
4
|
+
type: [String, Number, Date],
|
|
5
|
+
required: true,
|
|
6
|
+
},
|
|
7
|
+
locale: { type: String, default: undefined },
|
|
8
|
+
tag: { type: String, default: "span" },
|
|
9
|
+
short: { type: Boolean, default: false },
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const settingsStore = useSettingsStore();
|
|
13
|
+
const currentLocale = computed(
|
|
14
|
+
() =>
|
|
15
|
+
props.locale ||
|
|
16
|
+
settingsStore.currentLocale ||
|
|
17
|
+
settingsStore.defaultLocale ||
|
|
18
|
+
"en",
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const getDate = (val: string | number | Date) =>
|
|
22
|
+
val instanceof Date ? val : new Date(val);
|
|
23
|
+
|
|
24
|
+
const isoString = computed(() => {
|
|
25
|
+
try {
|
|
26
|
+
return getDate(props.date).toISOString();
|
|
27
|
+
} catch (e) {
|
|
28
|
+
return "";
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const fullTitle = computed(() => {
|
|
33
|
+
try {
|
|
34
|
+
return new Intl.DateTimeFormat(currentLocale.value, {
|
|
35
|
+
dateStyle: "full",
|
|
36
|
+
timeStyle: "short",
|
|
37
|
+
}).format(getDate(props.date));
|
|
38
|
+
} catch (e) {
|
|
39
|
+
return "";
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const displayTime = ref("");
|
|
44
|
+
let timer: ReturnType<typeof setTimeout> | null = null;
|
|
45
|
+
|
|
46
|
+
const update = () => {
|
|
47
|
+
if (timer) clearTimeout(timer);
|
|
48
|
+
|
|
49
|
+
const targetDate = getDate(props.date);
|
|
50
|
+
const diffSec = (targetDate.getTime() - Date.now()) / 1000;
|
|
51
|
+
const absDiffSec = Math.abs(diffSec);
|
|
52
|
+
|
|
53
|
+
const rtf = new Intl.RelativeTimeFormat(currentLocale.value, {
|
|
54
|
+
numeric: "auto",
|
|
55
|
+
style: props.short ? "short" : "long",
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
let text = "";
|
|
59
|
+
if (absDiffSec < 60) text = rtf.format(Math.round(diffSec), "second");
|
|
60
|
+
else if (absDiffSec < 3600)
|
|
61
|
+
text = rtf.format(Math.round(diffSec / 60), "minute");
|
|
62
|
+
else if (absDiffSec < 86400)
|
|
63
|
+
text = rtf.format(Math.round(diffSec / 3600), "hour");
|
|
64
|
+
else if (absDiffSec < 604800)
|
|
65
|
+
text = rtf.format(Math.round(diffSec / 86400), "day");
|
|
66
|
+
else if (absDiffSec < 2419200)
|
|
67
|
+
text = rtf.format(Math.round(diffSec / 604800), "week");
|
|
68
|
+
else if (absDiffSec < 29030400)
|
|
69
|
+
text = rtf.format(Math.round(diffSec / 2592000), "month");
|
|
70
|
+
else text = rtf.format(Math.round(diffSec / 31536000), "year");
|
|
71
|
+
|
|
72
|
+
displayTime.value = text;
|
|
73
|
+
|
|
74
|
+
const diffMin = absDiffSec / 60;
|
|
75
|
+
let delay = 60000;
|
|
76
|
+
if (diffMin < 1) delay = 10000;
|
|
77
|
+
else if (diffMin >= 60) delay = 3600000;
|
|
78
|
+
else if (diffMin >= 15) delay = 300000;
|
|
79
|
+
|
|
80
|
+
timer = setTimeout(update, delay);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
watch(() => [props.date, currentLocale.value, props.short], update);
|
|
84
|
+
onMounted(() => update());
|
|
85
|
+
onUnmounted(() => {
|
|
86
|
+
if (timer) clearTimeout(timer);
|
|
87
|
+
});
|
|
88
|
+
</script>
|
|
89
|
+
|
|
90
|
+
<template>
|
|
91
|
+
<ClientOnly>
|
|
92
|
+
<component
|
|
93
|
+
:is="tag"
|
|
94
|
+
:datetime="tag === 'time' ? isoString : undefined"
|
|
95
|
+
:title="fullTitle"
|
|
96
|
+
class="relative-time"
|
|
97
|
+
data-nosnippet
|
|
98
|
+
>
|
|
99
|
+
{{ displayTime }}
|
|
100
|
+
</component>
|
|
101
|
+
|
|
102
|
+
<template #fallback>
|
|
103
|
+
<span class="skeleton" data-nosnippet aria-hidden="true"></span>
|
|
104
|
+
</template>
|
|
105
|
+
</ClientOnly>
|
|
106
|
+
</template>
|
|
107
|
+
|
|
108
|
+
<style scoped>
|
|
109
|
+
.relative-time {
|
|
110
|
+
white-space: nowrap;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.skeleton {
|
|
114
|
+
display: inline-block;
|
|
115
|
+
height: 0.9em;
|
|
116
|
+
width: 6ch;
|
|
117
|
+
background-color: rgba(0, 0, 0, 0.1);
|
|
118
|
+
border-radius: 4px;
|
|
119
|
+
vertical-align: middle;
|
|
120
|
+
animation: pulse 1.5s infinite ease-in-out;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.skeleton {
|
|
124
|
+
display: inline-block;
|
|
125
|
+
height: 1em;
|
|
126
|
+
width: 6ch;
|
|
127
|
+
background-color: transparent;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@keyframes pulse {
|
|
131
|
+
0% {
|
|
132
|
+
opacity: 0.6;
|
|
133
|
+
}
|
|
134
|
+
50% {
|
|
135
|
+
opacity: 0.3;
|
|
136
|
+
}
|
|
137
|
+
100% {
|
|
138
|
+
opacity: 0.6;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
</style>
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<template v-if="status === 'active'">
|
|
3
|
+
<slot />
|
|
4
|
+
</template>
|
|
5
|
+
|
|
6
|
+
<template v-else-if="status === 'upcoming'">
|
|
7
|
+
<slot name="upcoming">
|
|
8
|
+
{{ preText }}
|
|
9
|
+
</slot>
|
|
10
|
+
</template>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script setup lang="ts">
|
|
14
|
+
type RepeatType = "daily" | "weekly" | "monthly" | "yearly";
|
|
15
|
+
type ContentStatus = "active" | "upcoming" | "hidden";
|
|
16
|
+
|
|
17
|
+
interface Props {
|
|
18
|
+
from?: string | Date;
|
|
19
|
+
to?: string | Date;
|
|
20
|
+
repeat?: RepeatType;
|
|
21
|
+
timezone?: string;
|
|
22
|
+
checkInterval?: number;
|
|
23
|
+
preText?: string;
|
|
24
|
+
previewHours?: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
28
|
+
checkInterval: 1000,
|
|
29
|
+
previewHours: 0,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const componentId = useId();
|
|
33
|
+
const isMounted = ref(false);
|
|
34
|
+
const now = ref(new Date(0));
|
|
35
|
+
let timer: ReturnType<typeof setInterval> | null = null;
|
|
36
|
+
|
|
37
|
+
const parseDate = (dateInput: string | Date | undefined): Date | null => {
|
|
38
|
+
if (!dateInput) return null;
|
|
39
|
+
let date: Date;
|
|
40
|
+
if (dateInput instanceof Date) {
|
|
41
|
+
date = dateInput;
|
|
42
|
+
} else {
|
|
43
|
+
const match = dateInput.match(
|
|
44
|
+
/^(\d{2})[./-](\d{2})[./-](\d{4})(?:\s+(\d{2}):(\d{2}))?$/,
|
|
45
|
+
);
|
|
46
|
+
if (match) {
|
|
47
|
+
const [_, day, month, year, hour, minute] = match;
|
|
48
|
+
date = new Date(
|
|
49
|
+
Number(year),
|
|
50
|
+
Number(month) - 1,
|
|
51
|
+
Number(day),
|
|
52
|
+
hour ? Number(hour) : 0,
|
|
53
|
+
minute ? Number(minute) : 0,
|
|
54
|
+
);
|
|
55
|
+
} else {
|
|
56
|
+
date = new Date(dateInput);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (isNaN(date.getTime())) return null;
|
|
60
|
+
|
|
61
|
+
if (props.timezone) {
|
|
62
|
+
const formatter = new Intl.DateTimeFormat("en-US", {
|
|
63
|
+
timeZone: props.timezone,
|
|
64
|
+
year: "numeric",
|
|
65
|
+
month: "numeric",
|
|
66
|
+
day: "numeric",
|
|
67
|
+
hour: "numeric",
|
|
68
|
+
minute: "numeric",
|
|
69
|
+
second: "numeric",
|
|
70
|
+
hour12: false,
|
|
71
|
+
});
|
|
72
|
+
const parts = formatter.formatToParts(date);
|
|
73
|
+
const getPart = (type: string) =>
|
|
74
|
+
parseInt(parts.find((p) => p.type === type)?.value || "0");
|
|
75
|
+
const tzDate = new Date(
|
|
76
|
+
Date.UTC(
|
|
77
|
+
getPart("year"),
|
|
78
|
+
getPart("month") - 1,
|
|
79
|
+
getPart("day"),
|
|
80
|
+
getPart("hour"),
|
|
81
|
+
getPart("minute"),
|
|
82
|
+
getPart("second"),
|
|
83
|
+
),
|
|
84
|
+
);
|
|
85
|
+
const diff = tzDate.getTime() - date.getTime();
|
|
86
|
+
return new Date(date.getTime() - diff);
|
|
87
|
+
}
|
|
88
|
+
return date;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const resolveStatus = (current: Date): ContentStatus => {
|
|
92
|
+
const startDate = parseDate(props.from);
|
|
93
|
+
const endDate = parseDate(props.to);
|
|
94
|
+
|
|
95
|
+
if (!startDate) return "active";
|
|
96
|
+
|
|
97
|
+
let vStart = new Date(startDate);
|
|
98
|
+
let vEnd = endDate ? new Date(endDate) : new Date("2099-01-01");
|
|
99
|
+
|
|
100
|
+
if (props.repeat === "yearly") {
|
|
101
|
+
vStart.setFullYear(current.getFullYear());
|
|
102
|
+
vEnd.setFullYear(current.getFullYear());
|
|
103
|
+
if (vEnd < vStart) vEnd.setFullYear(current.getFullYear() + 1);
|
|
104
|
+
} else if (props.repeat === "daily") {
|
|
105
|
+
vStart.setFullYear(
|
|
106
|
+
current.getFullYear(),
|
|
107
|
+
current.getMonth(),
|
|
108
|
+
current.getDate(),
|
|
109
|
+
);
|
|
110
|
+
const duration =
|
|
111
|
+
(endDate ? endDate.getTime() : 0) - startDate.getTime();
|
|
112
|
+
vEnd.setTime(vStart.getTime() + duration);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (current >= vStart && current <= vEnd) return "active";
|
|
116
|
+
|
|
117
|
+
if (current < vStart) {
|
|
118
|
+
if (props.previewHours === 0) return "upcoming";
|
|
119
|
+
|
|
120
|
+
const previewMs = props.previewHours * 60 * 60 * 1000;
|
|
121
|
+
if (vStart.getTime() - current.getTime() <= previewMs) {
|
|
122
|
+
return "upcoming";
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return "hidden";
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const hydrationStatus = useState<ContentStatus>(
|
|
130
|
+
`scheduled-content:${componentId}`,
|
|
131
|
+
() => resolveStatus(new Date()),
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
const status = computed(() =>
|
|
135
|
+
isMounted.value ? resolveStatus(now.value) : hydrationStatus.value,
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
onMounted(() => {
|
|
139
|
+
now.value = new Date();
|
|
140
|
+
isMounted.value = true;
|
|
141
|
+
|
|
142
|
+
timer = setInterval(() => {
|
|
143
|
+
now.value = new Date();
|
|
144
|
+
}, props.checkInterval);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
onBeforeUnmount(() => {
|
|
148
|
+
if (timer) clearInterval(timer);
|
|
149
|
+
});
|
|
150
|
+
</script>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
const { scrollToTop } = useSnapScroll();
|
|
3
|
+
const scrollY = ref(0);
|
|
4
|
+
|
|
5
|
+
const handleScroll = () => {
|
|
6
|
+
scrollY.value = window.scrollY;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const isVisible = computed(() => {
|
|
10
|
+
return scrollY.value > 600;
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
onMounted(() => {
|
|
14
|
+
window.addEventListener("scroll", handleScroll, { passive: true });
|
|
15
|
+
handleScroll();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
onUnmounted(() => {
|
|
19
|
+
window.removeEventListener("scroll", handleScroll);
|
|
20
|
+
});
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<template>
|
|
24
|
+
<Teleport to="body">
|
|
25
|
+
<Transition name="fade-up">
|
|
26
|
+
<button
|
|
27
|
+
v-if="isVisible"
|
|
28
|
+
@click="scrollToTop"
|
|
29
|
+
type="button"
|
|
30
|
+
class="fixed bottom-8 right-8 z-100 p-4 rounded-full bg-white dark:bg-zinc-900 shadow-2xl border border-zinc-200 dark:border-zinc-800 transition-transform active:scale-90"
|
|
31
|
+
>
|
|
32
|
+
<svg
|
|
33
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
34
|
+
width="24"
|
|
35
|
+
height="24"
|
|
36
|
+
viewBox="0 0 24 24"
|
|
37
|
+
fill="none"
|
|
38
|
+
stroke="currentColor"
|
|
39
|
+
stroke-width="2.5"
|
|
40
|
+
stroke-linecap="round"
|
|
41
|
+
stroke-linejoin="round"
|
|
42
|
+
>
|
|
43
|
+
<path d="m18 15-6-6-6 6" />
|
|
44
|
+
</svg>
|
|
45
|
+
</button>
|
|
46
|
+
</Transition>
|
|
47
|
+
</Teleport>
|
|
48
|
+
</template>
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
type Value = string | number;
|
|
3
|
+
|
|
4
|
+
interface Option {
|
|
5
|
+
value: Value;
|
|
6
|
+
label: string;
|
|
7
|
+
icon?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const props = withDefaults(
|
|
11
|
+
defineProps<{
|
|
12
|
+
modelValue?: Value | Value[] | null;
|
|
13
|
+
options: Option[];
|
|
14
|
+
multiple?: boolean;
|
|
15
|
+
vertical?: boolean;
|
|
16
|
+
full?: boolean;
|
|
17
|
+
color?: "primary" | "gray" | "info" | "success" | "warning" | "error";
|
|
18
|
+
variant?: "outline" | "soft";
|
|
19
|
+
size?: "xs" | "sm" | "md" | "lg";
|
|
20
|
+
}>(),
|
|
21
|
+
{
|
|
22
|
+
multiple: false,
|
|
23
|
+
vertical: false,
|
|
24
|
+
full: false,
|
|
25
|
+
color: "gray",
|
|
26
|
+
variant: "outline",
|
|
27
|
+
size: "md",
|
|
28
|
+
},
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const emit = defineEmits<{
|
|
32
|
+
(e: "update:modelValue", value: Value | Value[] | null): void;
|
|
33
|
+
}>();
|
|
34
|
+
|
|
35
|
+
const value = computed<Value | Value[] | null>({
|
|
36
|
+
get: () => props.modelValue ?? null,
|
|
37
|
+
set: (v) => emit("update:modelValue", v),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const isActive = (v: Value) => {
|
|
41
|
+
if (props.multiple) {
|
|
42
|
+
return Array.isArray(value.value) && value.value.includes(v);
|
|
43
|
+
}
|
|
44
|
+
return value.value === v;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const toggle = (v: Value) => {
|
|
48
|
+
if (!props.multiple) {
|
|
49
|
+
value.value = v;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const arr = Array.isArray(value.value) ? [...value.value] : [];
|
|
54
|
+
const i = arr.indexOf(v);
|
|
55
|
+
|
|
56
|
+
if (i === -1) arr.push(v);
|
|
57
|
+
else arr.splice(i, 1);
|
|
58
|
+
|
|
59
|
+
value.value = arr;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const sizes = {
|
|
63
|
+
xs: "text-xs px-2 py-1",
|
|
64
|
+
sm: "text-sm px-3 py-1.5",
|
|
65
|
+
md: "text-sm px-4 py-2",
|
|
66
|
+
lg: "text-base px-5 py-2.5",
|
|
67
|
+
} as const;
|
|
68
|
+
|
|
69
|
+
const colors = {
|
|
70
|
+
gray: {
|
|
71
|
+
border: "border-gray-400 dark:border-gray-700",
|
|
72
|
+
divider: "bg-gray-400/40 dark:bg-gray-600/40",
|
|
73
|
+
hover: "hover:bg-gray-200/60 dark:hover:bg-gray-600/40",
|
|
74
|
+
active: "bg-gray-200 text-gray-900 dark:bg-gray-700 dark:text-white",
|
|
75
|
+
},
|
|
76
|
+
primary: {
|
|
77
|
+
border: "border-primary-400 dark:border-primary-500",
|
|
78
|
+
divider: "bg-primary-400/40 dark:bg-primary-500/40",
|
|
79
|
+
hover: "hover:bg-primary-500/10",
|
|
80
|
+
active: "bg-primary-600 text-white",
|
|
81
|
+
},
|
|
82
|
+
success: {
|
|
83
|
+
border: "border-emerald-400 dark:border-emerald-500",
|
|
84
|
+
divider: "bg-emerald-400/40 dark:bg-emerald-500/40",
|
|
85
|
+
hover: "hover:bg-emerald-500/10",
|
|
86
|
+
active: "bg-emerald-600 text-white",
|
|
87
|
+
},
|
|
88
|
+
info: {
|
|
89
|
+
border: "border-blue-400 dark:border-blue-500",
|
|
90
|
+
divider: "bg-blue-400/40 dark:bg-blue-500/40",
|
|
91
|
+
hover: "hover:bg-blue-500/10",
|
|
92
|
+
active: "bg-blue-600 text-white",
|
|
93
|
+
},
|
|
94
|
+
warning: {
|
|
95
|
+
border: "border-amber-400 dark:border-amber-500",
|
|
96
|
+
divider: "bg-amber-400/40 dark:bg-amber-500/40",
|
|
97
|
+
hover: "hover:bg-amber-500/10",
|
|
98
|
+
active: "bg-amber-500 text-black",
|
|
99
|
+
},
|
|
100
|
+
error: {
|
|
101
|
+
border: "border-red-400 dark:border-red-500",
|
|
102
|
+
divider: "bg-red-400/40 dark:bg-red-500/40",
|
|
103
|
+
hover: "hover:bg-red-500/10",
|
|
104
|
+
active: "bg-red-600 text-white",
|
|
105
|
+
},
|
|
106
|
+
} as const;
|
|
107
|
+
|
|
108
|
+
const wrapperClasses = computed(() => [
|
|
109
|
+
"inline-flex rounded-md overflow-hidden border",
|
|
110
|
+
colors[props.color].border,
|
|
111
|
+
props.vertical ? "flex-col" : "flex-row",
|
|
112
|
+
props.full ? "w-full" : "w-fit",
|
|
113
|
+
]);
|
|
114
|
+
|
|
115
|
+
const itemClasses = (active: boolean) => [
|
|
116
|
+
"relative flex items-center justify-center gap-2 font-medium cursor-pointer select-none transition-colors",
|
|
117
|
+
sizes[props.size],
|
|
118
|
+
!active ? colors[props.color].hover : "",
|
|
119
|
+
active ? colors[props.color].active : "",
|
|
120
|
+
props.full && !props.vertical ? "flex-1" : "",
|
|
121
|
+
];
|
|
122
|
+
</script>
|
|
123
|
+
|
|
124
|
+
<template>
|
|
125
|
+
<div :class="wrapperClasses" role="group">
|
|
126
|
+
<div
|
|
127
|
+
v-for="(opt, index) in options"
|
|
128
|
+
:key="opt.value"
|
|
129
|
+
:class="itemClasses(isActive(opt.value))"
|
|
130
|
+
:aria-pressed="isActive(opt.value) ? 'true' : 'false'"
|
|
131
|
+
@click="toggle(opt.value)"
|
|
132
|
+
>
|
|
133
|
+
<UiIcon v-if="opt.icon" :name="opt.icon" class="h-4 w-4" />
|
|
134
|
+
<span>{{ opt.label }}</span>
|
|
135
|
+
|
|
136
|
+
<span
|
|
137
|
+
v-if="!props.vertical && index < options.length - 1"
|
|
138
|
+
class="absolute right-0 top-1/2 -translate-y-1/2 w-px h-2/3 pointer-events-none"
|
|
139
|
+
:class="colors[props.color].divider"
|
|
140
|
+
/>
|
|
141
|
+
<span
|
|
142
|
+
v-if="props.vertical && index < options.length - 1"
|
|
143
|
+
class="absolute bottom-0 left-1/2 -translate-x-1/2 h-px w-2/3 pointer-events-none"
|
|
144
|
+
:class="colors[props.color].divider"
|
|
145
|
+
/>
|
|
146
|
+
</div>
|
|
147
|
+
</div>
|
|
148
|
+
</template>
|