|
1 | 1 | <script setup lang="ts"> |
2 | | -const isMounted = ref(false) |
3 | | -const isVisible = ref(false) |
4 | | -const isScrollable = ref(true) |
5 | | -const lastScrollY = ref(0) |
6 | | -const footerRef = ref<HTMLElement>() |
| 2 | +const isMounted = shallowRef(false) |
| 3 | +const isVisible = shallowRef(false) |
| 4 | +const isScrollable = shallowRef(true) |
| 5 | +const lastScrollY = shallowRef(0) |
| 6 | +const footerRef = useTemplateRef('footerRef') |
7 | 7 |
|
8 | 8 | // Check if CSS scroll-state container queries are supported |
9 | 9 | // Once this becomes baseline, we can remove the JS scroll handling entirely |
10 | | -const supportsScrollStateQueries = ref(false) |
| 10 | +const supportsScrollStateQueries = useSupported(() => { |
| 11 | + return isMounted.value && CSS.supports('container-type', 'scroll-state') |
| 12 | +}) |
11 | 13 |
|
12 | 14 | function checkScrollable() { |
13 | 15 | return document.documentElement.scrollHeight > window.innerHeight |
@@ -48,26 +50,17 @@ function onResize() { |
48 | 50 | updateFooterPadding() |
49 | 51 | } |
50 | 52 |
|
51 | | -onMounted(() => { |
52 | | - // Feature detect CSS scroll-state container queries (Chrome 133+) |
53 | | - // @see https://developer.mozilla.org/en-US/docs/Web/CSS/@container#scroll-state_container_descriptors |
54 | | - supportsScrollStateQueries.value = CSS.supports('container-type', 'scroll-state') |
| 53 | +useEventListener('scroll', onScroll, { passive: true }) |
| 54 | +useEventListener('resize', onResize, { passive: true }) |
55 | 55 |
|
| 56 | +onMounted(() => { |
56 | 57 | nextTick(() => { |
57 | 58 | lastScrollY.value = window.scrollY |
58 | 59 | isScrollable.value = checkScrollable() |
59 | 60 | updateFooterPadding() |
60 | 61 | // Only apply dynamic classes after mount to avoid hydration mismatch |
61 | 62 | isMounted.value = true |
62 | 63 | }) |
63 | | -
|
64 | | - window.addEventListener('scroll', onScroll, { passive: true }) |
65 | | - window.addEventListener('resize', onResize, { passive: true }) |
66 | | -}) |
67 | | -
|
68 | | -onUnmounted(() => { |
69 | | - window.removeEventListener('scroll', onScroll) |
70 | | - window.removeEventListener('resize', onResize) |
71 | 64 | }) |
72 | 65 | </script> |
73 | 66 |
|
@@ -97,19 +90,25 @@ onUnmounted(() => { |
97 | 90 | <p class="text-xs text-fg-muted m-0 sm:hidden">not affiliated with npm, Inc.</p> |
98 | 91 | <div class="flex items-center gap-4 sm:gap-6"> |
99 | 92 | <a |
100 | | - href="https://github.com/npmx-dev/npmx.dev" |
| 93 | + href="https://repo.npmx.dev" |
101 | 94 | rel="noopener noreferrer" |
102 | | - class="link-subtle font-mono text-xs min-h-11 min-w-11 flex items-center" |
| 95 | + class="link-subtle font-mono text-xs min-h-11 min-w- flex items-center" |
103 | 96 | > |
104 | 97 | source |
105 | 98 | </a> |
106 | | - <span class="text-border">|</span> |
107 | 99 | <a |
108 | | - href="https://roe.dev" |
| 100 | + href="https://social.npmx.dev" |
| 101 | + rel="noopener noreferrer" |
| 102 | + class="link-subtle font-mono text-xs min-h-11 min-w-11 flex items-center" |
| 103 | + > |
| 104 | + social |
| 105 | + </a> |
| 106 | + <a |
| 107 | + href="https://chat.npmx.dev" |
109 | 108 | rel="noopener noreferrer" |
110 | 109 | class="link-subtle font-mono text-xs min-h-11 min-w-11 flex items-center" |
111 | 110 | > |
112 | | - @danielroe |
| 111 | + chat |
113 | 112 | </a> |
114 | 113 | </div> |
115 | 114 | </div> |
|
0 commit comments