@resee-movies/nuxt-ux 0.13.1 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.json +1 -1
- package/dist/runtime/components/Card.vue +23 -15
- package/dist/runtime/components/Card.vue.d.ts +8 -5
- package/dist/runtime/components/CardScroller.vue +189 -0
- package/dist/runtime/components/CardScroller.vue.d.ts +36 -0
- package/dist/runtime/components/GlobalHeader.vue +107 -0
- package/dist/runtime/components/GlobalHeader.vue.d.ts +15 -0
- package/dist/runtime/components/GlobalHeaderAnnouncement.vue +49 -0
- package/dist/runtime/components/GlobalHeaderAnnouncement.vue.d.ts +14 -0
- package/dist/runtime/components/Image.vue +70 -127
- package/dist/runtime/components/Image.vue.d.ts +4 -35
- package/dist/runtime/components/ImageBase.vue +114 -0
- package/dist/runtime/components/ImageBase.vue.d.ts +41 -0
- package/dist/runtime/components/LayoutPageRoot.vue +55 -0
- package/dist/runtime/components/LayoutPageRoot.vue.d.ts +21 -0
- package/dist/runtime/components/Message.vue +31 -11
- package/dist/runtime/components/Message.vue.d.ts +4 -3
- package/dist/runtime/components/NotificationContainer.vue +2 -2
- package/dist/runtime/components/ReseeWordLogo.vue +53 -0
- package/dist/runtime/components/ReseeWordLogo.vue.d.ts +12 -0
- package/dist/runtime/components/ScrollPinnedContainer.vue +33 -0
- package/dist/runtime/components/ScrollPinnedContainer.vue.d.ts +14 -0
- package/dist/runtime/components/SuccessSplash.vue +47 -0
- package/dist/runtime/components/SuccessSplash.vue.d.ts +6 -0
- package/dist/runtime/components/form/Form.vue +55 -21
- package/dist/runtime/components/form/Form.vue.d.ts +5 -0
- package/dist/runtime/composables/use-global-header-state.d.ts +10 -0
- package/dist/runtime/composables/use-global-header-state.js +20 -0
- package/dist/runtime/composables/use-load-image.d.ts +3 -0
- package/dist/runtime/composables/use-load-image.js +26 -44
- package/dist/runtime/composables/use-mutable-intersection-observer.d.ts +44 -0
- package/dist/runtime/composables/use-mutable-intersection-observer.js +68 -0
- package/dist/runtime/composables/use-resee-ux.d.ts +5 -0
- package/dist/runtime/composables/use-resee-ux.js +11 -1
- package/dist/runtime/composables/use-two-frame-ref-toggle.d.ts +25 -0
- package/dist/runtime/composables/use-two-frame-ref-toggle.js +24 -0
- package/dist/runtime/utils/validation.d.ts +2 -2
- package/dist/runtime/utils/validation.js +2 -2
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<Component
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
<Component
|
|
3
|
+
:is = "props.is"
|
|
4
|
+
:class = "[
|
|
5
|
+
'card',
|
|
6
|
+
{
|
|
7
|
+
loading: props.loading,
|
|
8
|
+
interactive: props.interactive,
|
|
9
|
+
colorful: props.colorful,
|
|
10
|
+
bordered: props.bordered,
|
|
11
|
+
beveled: props.beveled,
|
|
12
|
+
raised: props.raised
|
|
13
|
+
}
|
|
14
|
+
]"
|
|
15
|
+
>
|
|
16
|
+
<slot />
|
|
12
17
|
</Component>
|
|
13
18
|
</template>
|
|
14
19
|
|
|
@@ -17,14 +22,17 @@
|
|
|
17
22
|
</script>
|
|
18
23
|
|
|
19
24
|
<script setup>
|
|
20
|
-
import { useSlots } from "#imports";
|
|
21
25
|
const props = defineProps({
|
|
22
|
-
is: { type:
|
|
23
|
-
|
|
26
|
+
is: { type: null, required: false, default: "div" },
|
|
27
|
+
loading: { type: Boolean, required: false, default: false },
|
|
28
|
+
interactive: { type: Boolean, required: false, default: false },
|
|
29
|
+
colorful: { type: Boolean, required: false, default: false },
|
|
30
|
+
bordered: { type: Boolean, required: false, default: false },
|
|
31
|
+
beveled: { type: Boolean, required: false, default: false },
|
|
32
|
+
raised: { type: Boolean, required: false, default: false }
|
|
24
33
|
});
|
|
25
|
-
const slots = useSlots();
|
|
26
34
|
</script>
|
|
27
35
|
|
|
28
36
|
<style scoped>
|
|
29
|
-
@reference "tailwindcss";@layer components{
|
|
37
|
+
@reference "tailwindcss";@layer components{@property --resee-card-border-coverage{syntax:"<percentage>";inherits:false;initial-value:0%}@property --resee-card-bg-color{syntax:"<color>";inherits:false;initial-value:transparent}@keyframes resee-card-bg-color-pulse{0%{background-color:var(--resee-card-bg-load-color-1)}50%{background-color:var(--resee-card-bg-load-color-2)}to{background-color:var(--resee-card-bg-load-color-1)}}.card{--resee-card-bg-color:var(--color-global-background);--resee-card-bg-load-color-1:#fff;--resee-card-bg-load-color-2:#f0f0f0;--resee-card-border-color:var(--color-global-background-accent);--resee-card-border-highlight:var(--color-global-foreground-accent) 0% 100%;--resee-card-border-angle:225deg;--resee-card-border-coverage:100%;--resee-card-border-weight:2px;@variant dark{--resee-card-bg-load-color-1:#000;--resee-card-bg-load-color-2:#0f0f0f}}.card.loading{animation-duration:2.5s;animation-fill-mode:both;animation-iteration-count:infinite;animation-name:resee-card-bg-color-pulse;animation-timing-function:ease-out}.card.beveled{border-bottom-left-radius:var(--radius-xl);border-top-right-radius:var(--radius-xl);overflow:clip}.card.raised{box-shadow:var(--shadow-heavy)}.card.bordered.loading,.card.bordered:not(.interactive){background-color:var(--resee-card-bg-color);border:solid var(--resee-card-border-weight) var(--resee-card-border-color)}.card.bordered.interactive:not(.loading){--resee-card-bg-gradient:linear-gradient(var(--resee-card-bg-color),var(--resee-card-bg-color));--resee-card-border-gradient:linear-gradient(225deg,var(--resee-card-border-color) 0 var(--resee-card-border-coverage),var(--resee-card-border-highlight));background-clip:padding-box,border-box;background-image:var(--resee-card-bg-gradient),var(--resee-card-border-gradient);background-origin:border-box;border:var(--resee-card-border-weight) solid transparent}.card.bordered.interactive:not(.loading).colorful{--resee-card-border-highlight:var(--colorscale-resee-linear);@variant dark{--resee-card-border-highlight:var(--colorscale-resee-lite-linear)}}.card.interactive:not(.loading){transition-duration:calc(var(--default-transition-duration)*3);transition-property:border-radius,box-shadow,--resee-card-border-coverage;transition-timing-function:var(--default-transition-timing-function);-webkit-user-select:none;-moz-user-select:none;user-select:none}.card.interactive:not(.loading):focus-within.bordered,.card.interactive:not(.loading):hover.bordered{--resee-card-border-coverage:0%}.card.interactive:not(.loading):focus-within.beveled,.card.interactive:not(.loading):hover.beveled{border-radius:0}.card.interactive:not(.loading):focus-within,.card.interactive:not(.loading):hover{box-shadow:var(--shadow-heavy)}}
|
|
30
38
|
</style>
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
import type { Component } from 'vue';
|
|
2
|
+
import type { HintedString } from '../types/index.js';
|
|
1
3
|
export interface CardProps {
|
|
2
|
-
is?:
|
|
4
|
+
is?: HintedString<'div'> | Component;
|
|
5
|
+
loading?: boolean;
|
|
3
6
|
interactive?: boolean;
|
|
7
|
+
colorful?: boolean;
|
|
8
|
+
bordered?: boolean;
|
|
9
|
+
beveled?: boolean;
|
|
10
|
+
raised?: boolean;
|
|
4
11
|
}
|
|
5
12
|
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<CardProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<CardProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
6
13
|
default?: (props: {}) => any;
|
|
7
|
-
} & {
|
|
8
|
-
image?: (props: {}) => any;
|
|
9
|
-
} & {
|
|
10
|
-
content?: (props: {}) => any;
|
|
11
14
|
}>;
|
|
12
15
|
declare const _default: typeof __VLS_export;
|
|
13
16
|
export default _default;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="['scroller', { 'to-edge': props.toPageContainerEdge }]">
|
|
3
|
+
<div ref="ruler" :class="props.rulerClasses" />
|
|
4
|
+
|
|
5
|
+
<div
|
|
6
|
+
ref = "scrollBox"
|
|
7
|
+
class = "scroll-box styled-scroll transition-opacity duration-300"
|
|
8
|
+
:class = "[
|
|
9
|
+
props.scrollBoxClasses,
|
|
10
|
+
{
|
|
11
|
+
'opacity-0': !displayBounds.s0,
|
|
12
|
+
'justify-start': displayBounds.s1 || !props.centerAlign,
|
|
13
|
+
'justify-center': !displayBounds.s1 || props.centerAlign
|
|
14
|
+
}
|
|
15
|
+
]"
|
|
16
|
+
>
|
|
17
|
+
<div
|
|
18
|
+
v-if = "slots.firstItem"
|
|
19
|
+
ref = "firstItem"
|
|
20
|
+
:class = "[props.itemClasses, props.itemSizeClasses]"
|
|
21
|
+
>
|
|
22
|
+
<slot name="firstItem" />
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<div
|
|
26
|
+
v-for = "(item, index) in props.items"
|
|
27
|
+
ref = "scrollItems"
|
|
28
|
+
:key = "identify(item, index)"
|
|
29
|
+
:class = "[props.itemClasses, props.itemSizeClasses]"
|
|
30
|
+
>
|
|
31
|
+
<slot name="item" :item="item" :index="index" />
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
<div
|
|
35
|
+
v-if = "props.loading"
|
|
36
|
+
:class = "[props.itemClasses, props.itemSizeClasses]"
|
|
37
|
+
>
|
|
38
|
+
<slot name="loading" />
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<div
|
|
42
|
+
v-if = "slots.finalItem"
|
|
43
|
+
ref = "finalItem"
|
|
44
|
+
:class = "[props.itemClasses, props.itemSizeClasses]"
|
|
45
|
+
>
|
|
46
|
+
<slot name="finalItem" />
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
</template>
|
|
51
|
+
|
|
52
|
+
<script>
|
|
53
|
+
import { isObjectLike } from "@resee-movies/utilities/objects/is-object-like";
|
|
54
|
+
import { isString } from "@resee-movies/utilities/strings/is-string";
|
|
55
|
+
import { defaultWindow, useElementBounding, useDebounceFn, useScroll, watchDebounced } from "@vueuse/core";
|
|
56
|
+
import { computed, ref, watch } from "vue";
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<script setup>
|
|
60
|
+
const props = defineProps({
|
|
61
|
+
items: { type: null, required: true },
|
|
62
|
+
rulerClasses: { type: null, required: false, default: void 0 },
|
|
63
|
+
scrollBoxClasses: { type: null, required: false, default: void 0 },
|
|
64
|
+
itemClasses: { type: null, required: false, default: void 0 },
|
|
65
|
+
itemSizeClasses: { type: null, required: false, default: "w-32 md:w-36 lg:w-42" },
|
|
66
|
+
loading: { type: Boolean, required: false, default: false },
|
|
67
|
+
centerAlign: { type: Boolean, required: false, default: false },
|
|
68
|
+
toPageContainerEdge: { type: Boolean, required: false, default: true },
|
|
69
|
+
styleWhenTransiting: { type: String, required: false, default: "right" }
|
|
70
|
+
});
|
|
71
|
+
const slots = defineSlots();
|
|
72
|
+
const ruler = ref();
|
|
73
|
+
const scrollBox = ref();
|
|
74
|
+
const scrollItems = ref([]);
|
|
75
|
+
const firstItem = ref();
|
|
76
|
+
const finalItem = ref();
|
|
77
|
+
const rulerBounds = useElementBounding(ruler);
|
|
78
|
+
const scrollItemElements = computed(() => {
|
|
79
|
+
const result = [];
|
|
80
|
+
if (firstItem.value) {
|
|
81
|
+
result.push(firstItem.value);
|
|
82
|
+
}
|
|
83
|
+
result.push(...scrollItems.value);
|
|
84
|
+
if (finalItem.value) {
|
|
85
|
+
result.push(finalItem.value);
|
|
86
|
+
}
|
|
87
|
+
return result;
|
|
88
|
+
});
|
|
89
|
+
const displayBounds = computed(() => {
|
|
90
|
+
const rulerEl = ruler.value;
|
|
91
|
+
if (!rulerEl) {
|
|
92
|
+
return { s0: false, s1: false, x1: 0, x2: 0, x3: 0, x4: 0, x1_2: "0px", x3_4: "0px" };
|
|
93
|
+
}
|
|
94
|
+
const rulerStyles = defaultWindow?.getComputedStyle(rulerEl);
|
|
95
|
+
const rulerLeft = rulerBounds.left.value;
|
|
96
|
+
const rulerWidth = rulerBounds.width.value;
|
|
97
|
+
const rulerPadLeft = parseFloat(rulerStyles?.paddingLeft || "0");
|
|
98
|
+
const rulerPadRight = parseFloat(rulerStyles?.paddingRight || "0");
|
|
99
|
+
const scrollBoxWidth = scrollBox.value?.scrollWidth ?? 0;
|
|
100
|
+
const bounds = {
|
|
101
|
+
s0: true,
|
|
102
|
+
// Has layout occurred
|
|
103
|
+
s1: rulerWidth < scrollBoxWidth,
|
|
104
|
+
// Is the scroll box overflowing
|
|
105
|
+
x1: rulerLeft,
|
|
106
|
+
x2: rulerLeft + rulerPadLeft,
|
|
107
|
+
x3: rulerLeft + rulerPadLeft + rulerWidth,
|
|
108
|
+
x4: rulerLeft + rulerPadLeft + rulerWidth + rulerPadRight
|
|
109
|
+
};
|
|
110
|
+
bounds.x1_2 = `${bounds.x2 - bounds.x1}px`;
|
|
111
|
+
bounds.x3_4 = `${bounds.x4 - bounds.x3}px`;
|
|
112
|
+
return bounds;
|
|
113
|
+
});
|
|
114
|
+
watchDebounced([displayBounds], () => {
|
|
115
|
+
scrollBox.value?.scrollTo({ left: 0, behavior: "instant" });
|
|
116
|
+
}, { debounce: 500 });
|
|
117
|
+
const scrollState = useScroll(scrollBox);
|
|
118
|
+
watch([scrollState.x, displayBounds], () => {
|
|
119
|
+
queueStyleChanges();
|
|
120
|
+
debouncedQueueStyleChanges();
|
|
121
|
+
}, { flush: "sync" });
|
|
122
|
+
const debouncedQueueStyleChanges = useDebounceFn(() => queueStyleChanges(), 100);
|
|
123
|
+
let queuedFrame = void 0;
|
|
124
|
+
function queueStyleChanges() {
|
|
125
|
+
if (queuedFrame) {
|
|
126
|
+
cancelAnimationFrame(queuedFrame);
|
|
127
|
+
queuedFrame = void 0;
|
|
128
|
+
}
|
|
129
|
+
queuedFrame = requestAnimationFrame(() => {
|
|
130
|
+
applyStyleChanges();
|
|
131
|
+
queuedFrame = void 0;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function applyStyleChanges() {
|
|
135
|
+
const styleLeft = props.styleWhenTransiting === "left" || props.styleWhenTransiting === "both";
|
|
136
|
+
const styleRight = props.styleWhenTransiting === "right" || props.styleWhenTransiting === "both";
|
|
137
|
+
for (const element of scrollItemElements.value) {
|
|
138
|
+
const [percentage, direction] = percentInBounds(element, displayBounds.value);
|
|
139
|
+
if (direction === "none") {
|
|
140
|
+
element.style.opacity = "1";
|
|
141
|
+
element.style.scale = "1";
|
|
142
|
+
} else if (direction === "left" && styleLeft || direction === "right" && styleRight) {
|
|
143
|
+
element.style.opacity = percentage.toString();
|
|
144
|
+
if (element.firstElementChild instanceof HTMLElement) {
|
|
145
|
+
element.firstElementChild.style.transformOrigin = `center ${direction === "left" ? "right" : "left"}`;
|
|
146
|
+
element.firstElementChild.style.scale = (1 - 0.2 * (1 - percentage)).toString();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function percentInBounds(element, { x1, x2, x3, x4 }) {
|
|
152
|
+
const {
|
|
153
|
+
left: elementStart,
|
|
154
|
+
width: elementWidth
|
|
155
|
+
} = element.getBoundingClientRect();
|
|
156
|
+
const elementEnd = elementStart + elementWidth;
|
|
157
|
+
if (elementEnd <= x1) {
|
|
158
|
+
return [0, "left"];
|
|
159
|
+
}
|
|
160
|
+
if (elementStart >= x4) {
|
|
161
|
+
return [0, "right"];
|
|
162
|
+
}
|
|
163
|
+
if (elementStart >= x2 && elementEnd <= x3) {
|
|
164
|
+
return [1, "none"];
|
|
165
|
+
}
|
|
166
|
+
if (elementStart < x2) {
|
|
167
|
+
return [easeInSine((elementEnd - x1) / (x2 - x1 + elementWidth)), "left"];
|
|
168
|
+
}
|
|
169
|
+
const stopA = x3 - elementWidth;
|
|
170
|
+
const stopB = x4 - stopA;
|
|
171
|
+
return [easeInSine(1 - (elementStart - stopA) / stopB), "right"];
|
|
172
|
+
}
|
|
173
|
+
function easeInSine(t) {
|
|
174
|
+
return roundHundredth(-1 * Math.cos(t * (Math.PI / 2)) + 1);
|
|
175
|
+
}
|
|
176
|
+
function roundHundredth(value) {
|
|
177
|
+
return Math.round(value * 100) / 100;
|
|
178
|
+
}
|
|
179
|
+
function identify(item, fallback) {
|
|
180
|
+
if (isObjectLike(item) && "id" in item && isString(item.id)) {
|
|
181
|
+
return item.id;
|
|
182
|
+
}
|
|
183
|
+
return fallback;
|
|
184
|
+
}
|
|
185
|
+
</script>
|
|
186
|
+
|
|
187
|
+
<style scoped>
|
|
188
|
+
@reference "tailwindcss";.scroller .scroll-box{display:flex;gap:--spacing(3);overflow-x:scroll;padding-block-end:var(--page-column-gutter);scroll-padding-left:v-bind("displayBounds.x1_2");scroll-padding-right:v-bind("displayBounds.x3_4");scroll-snap-type:inline;touch-action:pan-x pan-y;width:100%;@variant sm{gap:--spacing(4)}}.scroller .scroll-box>:deep(*){flex-shrink:0;scroll-snap-align:start}.scroller .scroll-box>:deep(:first-child){margin-left:v-bind("displayBounds.x1_2")}.scroller .scroll-box>:deep(:last-child){margin-right:v-bind("displayBounds.x3_4");scroll-snap-align:end}.scroller.to-edge{margin-inline:calc(var(--page-column-gutter)*-1)}.scroller.to-edge>:first-child{padding-inline:var(--page-column-gutter)}.scroller.to-edge{@variant sm{margin-inline:calc(var(--page-container-pad-x)*-1);&>:first-child{padding-inline:var(--page-container-pad-x)}}}
|
|
189
|
+
</style>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { HTMLElementClassNames } from '../types/index.js';
|
|
2
|
+
export type CardScrollerProps<T> = {
|
|
3
|
+
items: T[] | null | undefined;
|
|
4
|
+
rulerClasses?: HTMLElementClassNames;
|
|
5
|
+
scrollBoxClasses?: HTMLElementClassNames;
|
|
6
|
+
itemClasses?: HTMLElementClassNames;
|
|
7
|
+
itemSizeClasses?: HTMLElementClassNames;
|
|
8
|
+
loading?: boolean;
|
|
9
|
+
centerAlign?: boolean;
|
|
10
|
+
toPageContainerEdge?: boolean;
|
|
11
|
+
styleWhenTransiting?: 'left' | 'right' | 'both';
|
|
12
|
+
};
|
|
13
|
+
declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
14
|
+
props: __VLS_PrettifyLocal<CardScrollerProps<T>> & import("vue").PublicProps & (typeof globalThis extends {
|
|
15
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
16
|
+
} ? P : {});
|
|
17
|
+
expose: (exposed: {}) => void;
|
|
18
|
+
attrs: any;
|
|
19
|
+
slots: {
|
|
20
|
+
item: (slotProps: {
|
|
21
|
+
item: T;
|
|
22
|
+
index: number;
|
|
23
|
+
}) => unknown;
|
|
24
|
+
firstItem: () => unknown;
|
|
25
|
+
finalItem: () => unknown;
|
|
26
|
+
loading: () => unknown;
|
|
27
|
+
};
|
|
28
|
+
emit: {};
|
|
29
|
+
}>) => import("vue").VNode & {
|
|
30
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
31
|
+
};
|
|
32
|
+
declare const _default: typeof __VLS_export;
|
|
33
|
+
export default _default;
|
|
34
|
+
type __VLS_PrettifyLocal<T> = {
|
|
35
|
+
[K in keyof T as K]: T[K];
|
|
36
|
+
} & {};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div ref="rulerElement" :class="{ placeholder: isHeaderAffixed }" />
|
|
3
|
+
|
|
4
|
+
<header
|
|
5
|
+
ref = "headerElement"
|
|
6
|
+
v-bind = "$attrs"
|
|
7
|
+
:class = "{
|
|
8
|
+
'header-affixed': isHeaderAffixed,
|
|
9
|
+
'header-transit': doTransitions,
|
|
10
|
+
'header-hidden': hideDrawerContent
|
|
11
|
+
}"
|
|
12
|
+
>
|
|
13
|
+
<div
|
|
14
|
+
ref = "drawerElement"
|
|
15
|
+
:class = "slots.subheader ? 'border-b border-b-global-background-accent' : void 0"
|
|
16
|
+
>
|
|
17
|
+
<LayoutPageColumn>
|
|
18
|
+
<slot name="default" />
|
|
19
|
+
</LayoutPageColumn>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<div v-if="slots.subheader" ref="subheadElement">
|
|
23
|
+
<LayoutPageColumn>
|
|
24
|
+
<slot name="subheader" />
|
|
25
|
+
</LayoutPageColumn>
|
|
26
|
+
</div>
|
|
27
|
+
</header>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<script>
|
|
31
|
+
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<script setup>
|
|
35
|
+
import { ref, useSlots, watch } from "vue";
|
|
36
|
+
import { useElementSize, useWindowScroll } from "@vueuse/core";
|
|
37
|
+
import { useGlobalHeaderState } from "../composables/use-global-header-state";
|
|
38
|
+
import { useTwoFrameRefToggle } from "../composables/use-two-frame-ref-toggle";
|
|
39
|
+
import LayoutPageColumn from "./LayoutPageColumn.vue";
|
|
40
|
+
defineOptions({
|
|
41
|
+
inheritAttrs: false
|
|
42
|
+
});
|
|
43
|
+
const props = defineProps({
|
|
44
|
+
drawer: { type: Boolean, required: false, default: true }
|
|
45
|
+
});
|
|
46
|
+
const slots = useSlots();
|
|
47
|
+
const rulerElement = ref();
|
|
48
|
+
const headerElement = ref();
|
|
49
|
+
const drawerElement = ref();
|
|
50
|
+
const subheadElement = ref();
|
|
51
|
+
const { height: headerHeight } = useElementSize(headerElement);
|
|
52
|
+
const { height: drawerHeight } = useElementSize(drawerElement);
|
|
53
|
+
const { height: subheadHeight } = useElementSize(subheadElement);
|
|
54
|
+
const { y: windowScrollY } = useWindowScroll();
|
|
55
|
+
const [isHeaderAffixed, doTransitions, updateAffixState] = useTwoFrameRefToggle();
|
|
56
|
+
const hideDrawerContent = ref(false);
|
|
57
|
+
let backscrollCounter = 0;
|
|
58
|
+
function disableAffix() {
|
|
59
|
+
updateAffixState(false);
|
|
60
|
+
hideDrawerContent.value = false;
|
|
61
|
+
backscrollCounter = 0;
|
|
62
|
+
}
|
|
63
|
+
function enableAffix() {
|
|
64
|
+
updateAffixState(true);
|
|
65
|
+
hideDrawerContent.value = true;
|
|
66
|
+
}
|
|
67
|
+
const { pause, resume } = watch(windowScrollY, (newScrollY, oldScrollY) => {
|
|
68
|
+
const scrollCeiling = rulerElement.value?.offsetTop ?? 0;
|
|
69
|
+
const rawDrawerHeight = drawerHeight.value;
|
|
70
|
+
if (newScrollY <= scrollCeiling || newScrollY <= scrollCeiling + rawDrawerHeight && hideDrawerContent.value) {
|
|
71
|
+
return disableAffix();
|
|
72
|
+
}
|
|
73
|
+
if (!isHeaderAffixed.value && newScrollY > scrollCeiling + rawDrawerHeight) {
|
|
74
|
+
return enableAffix();
|
|
75
|
+
}
|
|
76
|
+
const scrollDelta = newScrollY - oldScrollY;
|
|
77
|
+
const isScrollDown = scrollDelta > 0;
|
|
78
|
+
const negDrawerHeight = rawDrawerHeight * -1;
|
|
79
|
+
backscrollCounter = isScrollDown ? Math.min(rawDrawerHeight, backscrollCounter + scrollDelta) : Math.max(negDrawerHeight, backscrollCounter + scrollDelta);
|
|
80
|
+
if (backscrollCounter === rawDrawerHeight) {
|
|
81
|
+
hideDrawerContent.value = true;
|
|
82
|
+
} else if (backscrollCounter === negDrawerHeight) {
|
|
83
|
+
hideDrawerContent.value = false;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
const headerState = useGlobalHeaderState();
|
|
87
|
+
watch(
|
|
88
|
+
[() => props.drawer, headerHeight, subheadHeight, hideDrawerContent, isHeaderAffixed],
|
|
89
|
+
() => {
|
|
90
|
+
if (props.drawer) {
|
|
91
|
+
resume();
|
|
92
|
+
} else {
|
|
93
|
+
pause();
|
|
94
|
+
disableAffix();
|
|
95
|
+
}
|
|
96
|
+
headerState.isHeaderDrawerEnabled.value = props.drawer;
|
|
97
|
+
headerState.headerHeight.value = headerHeight.value;
|
|
98
|
+
headerState.subheaderHeight.value = subheadHeight.value;
|
|
99
|
+
headerState.isHeaderPulledDown.value = isHeaderAffixed.value && !hideDrawerContent.value;
|
|
100
|
+
},
|
|
101
|
+
{ immediate: true }
|
|
102
|
+
);
|
|
103
|
+
</script>
|
|
104
|
+
|
|
105
|
+
<style scoped>
|
|
106
|
+
.placeholder{height:calc(v-bind(headerHeight)*1px)}.header-affixed{box-shadow:var(--shadow-heavy);left:0;position:fixed;right:0;top:0;transform:translateY(0);z-index:100}.header-affixed.header-transit{transition-duration:calc(var(--default-transition-duration)*2);transition-property:transform,box-shadow;transition-timing-function:var(--default-transition-timing-function)}.header-affixed.header-hidden{box-shadow:none;transform:translateY(calc(v-bind(drawerHeight)*-1px))}
|
|
107
|
+
</style>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface GlobalHeaderProps {
|
|
2
|
+
drawer?: boolean;
|
|
3
|
+
}
|
|
4
|
+
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<GlobalHeaderProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<GlobalHeaderProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
5
|
+
default?: (props: {}) => any;
|
|
6
|
+
} & {
|
|
7
|
+
subheader?: (props: {}) => any;
|
|
8
|
+
}>;
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
export default _default;
|
|
11
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
12
|
+
new (): {
|
|
13
|
+
$slots: S;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
v-if = "!isDismissed"
|
|
4
|
+
:class = "['announcement', { dismissable: props.dismissable }]"
|
|
5
|
+
role = "alert"
|
|
6
|
+
aria-live = "polite"
|
|
7
|
+
>
|
|
8
|
+
<LayoutPageColumn :class="{ 'relative': props.dismissable }">
|
|
9
|
+
<slot />
|
|
10
|
+
|
|
11
|
+
<CloseButton
|
|
12
|
+
v-if = "props.dismissable"
|
|
13
|
+
class = "absolute right-3 top-1/2 -translate-y-1/2"
|
|
14
|
+
size = "sm"
|
|
15
|
+
@click = "dismissAnnouncement()"
|
|
16
|
+
/>
|
|
17
|
+
</LayoutPageColumn>
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script>
|
|
22
|
+
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<script setup>
|
|
26
|
+
import { computed, ref } from "vue";
|
|
27
|
+
import CloseButton from "./CloseButton.vue";
|
|
28
|
+
import LayoutPageColumn from "./LayoutPageColumn.vue";
|
|
29
|
+
import { useReseeUx } from "../composables/use-resee-ux";
|
|
30
|
+
const props = defineProps({
|
|
31
|
+
announcementId: { type: String, required: false, default: void 0 },
|
|
32
|
+
dismissable: { type: Boolean, required: false, default: true }
|
|
33
|
+
});
|
|
34
|
+
const { preferences } = useReseeUx();
|
|
35
|
+
const isLocallyDismissed = ref(false);
|
|
36
|
+
const isDismissed = computed(() => {
|
|
37
|
+
return isLocallyDismissed.value || props.announcementId && preferences.value.dismissNotification === props.announcementId;
|
|
38
|
+
});
|
|
39
|
+
function dismissAnnouncement() {
|
|
40
|
+
if (props.announcementId) {
|
|
41
|
+
preferences.value.dismissNotification = props.announcementId;
|
|
42
|
+
}
|
|
43
|
+
isLocallyDismissed.value = true;
|
|
44
|
+
}
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<style scoped>
|
|
48
|
+
@reference "tailwindcss";.announcement{--announcement-bg-color:#fff;@variant dark{--announcement-bg-color:#000}background-image:linear-gradient(to bottom,var(--announcement-bg-color) 0 calc(100% - 10px),transparent),linear-gradient(to right,var(--colorscale-resee-linear));padding-bottom:6px}.announcement.dismissable>div{padding-right:12rem}
|
|
49
|
+
</style>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface GlobalHeaderAnnouncementProps {
|
|
2
|
+
announcementId?: string;
|
|
3
|
+
dismissable?: boolean;
|
|
4
|
+
}
|
|
5
|
+
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<GlobalHeaderAnnouncementProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<GlobalHeaderAnnouncementProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
6
|
+
default?: (props: {}) => any;
|
|
7
|
+
}>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
10
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
11
|
+
new (): {
|
|
12
|
+
$slots: S;
|
|
13
|
+
};
|
|
14
|
+
};
|