srcdev-nuxt-components 9.4.5 → 9.4.7
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/.claude/commands/migrate-component.md +74 -5
- package/.claude/component-ledger/audit.json +1 -1
- package/.claude/component-ledger/build.mjs +27 -0
- package/.claude/component-ledger/output.html +8 -3
- package/.claude/component-ledger/template.html +7 -2
- package/.claude/skills/components/breadcrumb.md +1 -0
- package/.claude/skills/components/column-flow-grid.md +93 -0
- package/.claude/skills/components/content-docs.md +2 -0
- package/.claude/skills/components/display-tooltip-defined.md +3 -0
- package/.claude/skills/components/display-tooltip.md +1 -0
- package/.claude/skills/components/entry-animation.md +88 -0
- package/.claude/skills/components/input-copy.md +2 -0
- package/.claude/skills/components/input-text-core.md +186 -0
- package/.claude/skills/components/marquee-scroller.md +130 -0
- package/.claude/skills/components/masonry-grid.md +153 -0
- package/.claude/skills/components/navigation-items.md +1 -0
- package/.claude/skills/components/pop-over.md +100 -0
- package/.claude/skills/components/responsive-header.md +3 -0
- package/.claude/skills/components/site-header.md +4 -0
- package/.claude/skills/components/site-navigation.md +1 -0
- package/.claude/skills/components/tab-navigation.md +1 -0
- package/.claude/skills/index.md +7 -1
- package/.vscode/srcdev-component-breadcrumb.code-snippets +13 -0
- package/.vscode/srcdev-component-column-flow-grid.code-snippets +39 -0
- package/.vscode/srcdev-component-content-docs.code-snippets +18 -0
- package/.vscode/srcdev-component-display-tooltip-defined.code-snippets +15 -0
- package/.vscode/srcdev-component-display-tooltip.code-snippets +11 -0
- package/.vscode/srcdev-component-entry-animation.code-snippets +29 -0
- package/.vscode/srcdev-component-input-text.code-snippets +107 -0
- package/.vscode/srcdev-component-marquee-scroller.code-snippets +93 -0
- package/.vscode/srcdev-component-masonry-grid.code-snippets +51 -0
- package/.vscode/srcdev-component-pop-over.code-snippets +44 -0
- package/.vscode/srcdev-component-responsive-header.code-snippets +12 -0
- package/.vscode/srcdev-component-site-header.code-snippets +17 -0
- package/.vscode/srcdev-component-site-navigation.code-snippets +30 -0
- package/.vscode/srcdev-component-slider-gallery.code-snippets +38 -0
- package/.vscode/srcdev-component-tab-navigation.code-snippets +30 -0
- package/app/components/01.atoms/animations/entry/EntryAnimation.vue +7 -1
- package/app/components/01.atoms/animations/entry/stories/EntryAnimation.stories.ts +47 -0
- package/app/components/01.atoms/animations/entry/tests/EntryAnimation.spec.ts +57 -0
- package/app/components/01.atoms/animations/marquee-scroller/CONSUMER-STYLING.md +94 -0
- package/app/components/01.atoms/animations/marquee-scroller/MarqueeScroller.vue +331 -0
- package/app/components/01.atoms/animations/marquee-scroller/stories/MarqueeScroller.stories.ts +151 -0
- package/app/components/01.atoms/animations/marquee-scroller/tests/MarqueeScroller.spec.ts +315 -0
- package/app/components/01.atoms/animations/marquee-scroller/tests/__snapshots__/MarqueeScroller.spec.ts.snap +28 -0
- package/app/components/01.atoms/canvas-switcher/stories/CanvasSwitcher.stories.ts +9 -10
- package/app/components/01.atoms/content-wrappers/docs-pages/ContentDocs.vue +8 -2
- package/app/components/01.atoms/content-wrappers/docs-pages/stories/ContentDocs.stories.ts +12 -13
- package/app/components/01.atoms/display-tooltip/DisplayTooltip.vue +4 -1
- package/app/components/01.atoms/grids/column-flow-grid/CONSUMER-STYLING.md +33 -0
- package/app/components/01.atoms/grids/column-flow-grid/ColumnFlowGrid.vue +55 -0
- package/app/components/01.atoms/grids/column-flow-grid/stories/ColumnFlowGrid.stories.ts +178 -0
- package/app/components/01.atoms/grids/column-flow-grid/tests/ColumnFlowGrid.spec.ts +75 -0
- package/app/components/01.atoms/grids/masonry-grid/CONSUMER-STYLING.md +35 -0
- package/app/components/01.atoms/grids/masonry-grid/MasonryGrid.vue +178 -0
- package/app/components/01.atoms/grids/masonry-grid/stories/MasonryGrid.stories.ts +199 -0
- package/app/components/01.atoms/grids/masonry-grid/tests/MasonryGrid.spec.ts +158 -0
- package/app/components/01.atoms/navigation/breadcrumb/Breadcrumb.vue +4 -1
- package/app/components/01.atoms/pop-over/CONSUMER-STYLING.md +54 -0
- package/app/components/01.atoms/pop-over/PopOver.vue +201 -0
- package/app/components/01.atoms/pop-over/stories/PopOver.stories.ts +141 -0
- package/app/components/01.atoms/pop-over/tests/PopOver.spec.ts +195 -0
- package/app/components/01.atoms/pop-over/tests/__snapshots__/PopOver.spec.ts.snap +11 -0
- package/app/components/02.molecules/action-menu/stories/ActionMenu.stories.ts +8 -2
- package/app/components/02.molecules/display-tooltip-defined/DisplayTooltipDefined.vue +16 -3
- package/app/components/02.molecules/display-tooltip-defined/tests/__snapshots__/DisplayTooltipDefined.spec.ts.snap +1 -1
- package/app/components/02.molecules/input-copy/InputCopy.vue +14 -0
- package/app/components/02.molecules/input-copy/stories/InputCopy.stories.ts +15 -0
- package/app/components/02.molecules/input-copy/tests/InputCopy.spec.ts +41 -0
- package/app/components/02.molecules/navigation/site-navigation/SiteNavigation.vue +4 -1
- package/app/components/02.molecules/navigation/tab-navigation/TabNavigation.vue +4 -1
- package/app/components/03.organisms/image-galleries/slider-gallery/SliderGallery.vue +16 -4
- package/app/components/03.organisms/responsive-header/NavigationItems.vue +4 -1
- package/app/components/03.organisms/responsive-header/ResponsiveHeader.vue +16 -3
- package/app/components/03.organisms/site-header/SiteHeader.vue +16 -1
- package/app/components/03.organisms/site-header/tests/__snapshots__/SiteHeader.spec.ts.snap +1 -1
- package/app/components/05.forms/input-select/InputSelectCore.vue +1 -1
- package/app/components/05.forms/input-text/InputTextCore.vue +6 -0
- package/app/components/05.forms/input-text/stories/InputPasswordWithLabel.stories.ts +49 -20
- package/app/components/05.forms/input-text/stories/InputTextAsNumberWithLabel.stories.ts +41 -22
- package/app/components/05.forms/input-text/stories/InputTextCore.stories.ts +48 -22
- package/app/components/05.forms/input-text/stories/InputTextWithLabel.stories.ts +43 -17
- package/app/components/05.forms/input-text/tests/InputPasswordWithLabel.spec.ts +56 -0
- package/app/components/05.forms/input-text/tests/InputTextAsNumberWithLabel.spec.ts +61 -0
- package/app/components/05.forms/input-text/tests/InputTextCore.spec.ts +60 -0
- package/app/components/05.forms/input-text/tests/InputTextWithLabel.spec.ts +46 -0
- package/app/components/05.forms/input-text/variants/InputPasswordWithLabel.vue +7 -1
- package/app/components/05.forms/input-text/variants/InputTextAsNumberWithLabel.vue +8 -2
- package/app/components/05.forms/input-text/variants/InputTextWithLabel.vue +6 -0
- package/app/components/05.forms/input-textarea/stories/InputTextareaCore.stories.ts +20 -20
- package/app/components/05.forms/input-textarea/stories/InputTextareaWithLabel.stories.ts +32 -26
- package/app/types/components/index.ts +1 -0
- package/app/types/components/marquee-scroller.d.ts +10 -0
- package/app/types/forms/types.forms.d.ts +1 -1
- package/package.json +1 -1
- package/app/components/marquee-scroller/MarqueeScroller.vue +0 -289
- package/app/components/masonry-grid/MasonryGrid.vue +0 -68
- package/app/components/masonry-grid-ordered/MasonryGridOrdered.vue +0 -163
- package/app/components/masonry-grid-ordered/MasonryGridOrderedGridExperiment.vue +0 -259
- package/app/components/masonry-grid-ordered/stories/MasonryGridOrdered.stories.ts +0 -354
- package/app/components/masonry-grid-sorted/MasonryGridSorted.vue +0 -120
- package/app/components/pop-over/PopOver.vue +0 -90
- package/app/layouts/default.vue +0 -308
- package/app/layouts/site-navigation-demo.vue +0 -188
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
v-if="displayComponent"
|
|
4
|
-
class="marquee-scroller"
|
|
5
|
-
:class="{ reverse: reverse, paused: isPaused, 'reduced-motion': prefersReducedMotion }"
|
|
6
|
-
role="region"
|
|
7
|
-
:aria-label="ariaLabel || 'Scrolling content'"
|
|
8
|
-
:aria-live="isPaused ? 'polite' : 'off'"
|
|
9
|
-
tabindex="0"
|
|
10
|
-
@keydown="handleKeydown"
|
|
11
|
-
@focus="handleFocus"
|
|
12
|
-
@blur="handleBlur"
|
|
13
|
-
>
|
|
14
|
-
<!-- Screen reader instructions -->
|
|
15
|
-
<div class="sr-only">
|
|
16
|
-
{{ ariaDescription || "Use spacebar to pause/play animation, arrow keys when focused for manual control" }}
|
|
17
|
-
</div>
|
|
18
|
-
|
|
19
|
-
<!-- Pause/Play button -->
|
|
20
|
-
<button
|
|
21
|
-
v-if="showControls"
|
|
22
|
-
class="control-btn"
|
|
23
|
-
@click="togglePause"
|
|
24
|
-
:aria-label="isPaused ? 'Play animation' : 'Pause animation'"
|
|
25
|
-
type="button"
|
|
26
|
-
>
|
|
27
|
-
<span aria-hidden="true">{{ isPaused ? "▶" : "⏸" }}</span>
|
|
28
|
-
</button>
|
|
29
|
-
|
|
30
|
-
<div class="marquee-track" :aria-hidden="!isPaused">
|
|
31
|
-
<div class="marquee-group">
|
|
32
|
-
<div v-for="item in marqueeData" :key="item.id" class="item">
|
|
33
|
-
<slot :name="item.id"></slot>
|
|
34
|
-
</div>
|
|
35
|
-
</div>
|
|
36
|
-
<div class="marquee-group" aria-hidden="true">
|
|
37
|
-
<div v-for="item in marqueeData" :key="`duplicate-${item.id}`" class="item">
|
|
38
|
-
<slot :name="item.id"></slot>
|
|
39
|
-
</div>
|
|
40
|
-
</div>
|
|
41
|
-
</div>
|
|
42
|
-
</div>
|
|
43
|
-
</template>
|
|
44
|
-
|
|
45
|
-
<script setup lang="ts">
|
|
46
|
-
const props = defineProps({
|
|
47
|
-
animationRuntime: {
|
|
48
|
-
type: String,
|
|
49
|
-
default: "40s",
|
|
50
|
-
},
|
|
51
|
-
reverse: {
|
|
52
|
-
type: Boolean,
|
|
53
|
-
default: false,
|
|
54
|
-
},
|
|
55
|
-
marqueeData: {
|
|
56
|
-
type: Array as PropType<Array<{ id: number; content: string }>>,
|
|
57
|
-
default: () => [],
|
|
58
|
-
},
|
|
59
|
-
itemConfig: {
|
|
60
|
-
type: Object,
|
|
61
|
-
default: () => ({
|
|
62
|
-
width: "50px",
|
|
63
|
-
height: "50px",
|
|
64
|
-
gap: "16px",
|
|
65
|
-
}),
|
|
66
|
-
required: true,
|
|
67
|
-
},
|
|
68
|
-
// Accessibility props
|
|
69
|
-
ariaLabel: {
|
|
70
|
-
type: String,
|
|
71
|
-
default: null,
|
|
72
|
-
},
|
|
73
|
-
ariaDescription: {
|
|
74
|
-
type: String,
|
|
75
|
-
default: null,
|
|
76
|
-
},
|
|
77
|
-
showControls: {
|
|
78
|
-
type: Boolean,
|
|
79
|
-
default: false,
|
|
80
|
-
},
|
|
81
|
-
respectReducedMotion: {
|
|
82
|
-
type: Boolean,
|
|
83
|
-
default: true,
|
|
84
|
-
},
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
const displayComponent = ref(false);
|
|
88
|
-
const isPaused = ref(false);
|
|
89
|
-
const isFocused = ref(false);
|
|
90
|
-
const prefersReducedMotion = ref(false);
|
|
91
|
-
|
|
92
|
-
const height = computed(() => props.itemConfig.height);
|
|
93
|
-
const width = computed(() => props.itemConfig.width);
|
|
94
|
-
const gap = computed(() => props.itemConfig.gap || "16px");
|
|
95
|
-
|
|
96
|
-
// Check for reduced motion preference
|
|
97
|
-
const checkReducedMotion = () => {
|
|
98
|
-
if (typeof window !== "undefined" && props.respectReducedMotion) {
|
|
99
|
-
const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
100
|
-
prefersReducedMotion.value = mediaQuery.matches;
|
|
101
|
-
|
|
102
|
-
// Listen for changes
|
|
103
|
-
mediaQuery.addEventListener("change", (e) => {
|
|
104
|
-
prefersReducedMotion.value = e.matches;
|
|
105
|
-
if (e.matches) {
|
|
106
|
-
isPaused.value = true;
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
const togglePause = () => {
|
|
113
|
-
isPaused.value = !isPaused.value;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const handleKeydown = (event: KeyboardEvent) => {
|
|
117
|
-
switch (event.key) {
|
|
118
|
-
case " ":
|
|
119
|
-
case "Spacebar":
|
|
120
|
-
event.preventDefault();
|
|
121
|
-
togglePause();
|
|
122
|
-
break;
|
|
123
|
-
case "ArrowLeft":
|
|
124
|
-
case "ArrowRight":
|
|
125
|
-
// Could add manual stepping functionality here
|
|
126
|
-
event.preventDefault();
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const handleFocus = () => {
|
|
132
|
-
isFocused.value = true;
|
|
133
|
-
if (props.respectReducedMotion) {
|
|
134
|
-
isPaused.value = true;
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
const handleBlur = () => {
|
|
139
|
-
isFocused.value = false;
|
|
140
|
-
if (!prefersReducedMotion.value) {
|
|
141
|
-
isPaused.value = false;
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
onMounted(() => {
|
|
146
|
-
displayComponent.value = true;
|
|
147
|
-
checkReducedMotion();
|
|
148
|
-
|
|
149
|
-
// Auto-pause if user prefers reduced motion
|
|
150
|
-
if (prefersReducedMotion.value) {
|
|
151
|
-
isPaused.value = true;
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
</script>
|
|
155
|
-
|
|
156
|
-
<style lang="css">
|
|
157
|
-
@layer components {
|
|
158
|
-
.marquee-scroller {
|
|
159
|
-
width: 100%;
|
|
160
|
-
height: v-bind(height);
|
|
161
|
-
overflow: hidden;
|
|
162
|
-
mask-image: linear-gradient(to right, transparent, #000 10% 90%, transparent);
|
|
163
|
-
position: relative;
|
|
164
|
-
|
|
165
|
-
/* Focus styles */
|
|
166
|
-
&:focus {
|
|
167
|
-
outline: 2px solid var(--color-focus, #0066cc);
|
|
168
|
-
outline-offset: 2px;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/* Paused state */
|
|
172
|
-
&.paused .marquee-track {
|
|
173
|
-
animation-play-state: paused;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/* Reduced motion - disable animation completely */
|
|
177
|
-
&.reduced-motion .marquee-track {
|
|
178
|
-
animation: none !important;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
&:hover .marquee-track {
|
|
182
|
-
animation-play-state: paused;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
&:hover .item {
|
|
186
|
-
filter: grayscale(1);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/* Screen reader only text */
|
|
190
|
-
.sr-only {
|
|
191
|
-
position: absolute;
|
|
192
|
-
width: 1px;
|
|
193
|
-
height: 1px;
|
|
194
|
-
padding: 0;
|
|
195
|
-
margin: -1px;
|
|
196
|
-
overflow: hidden;
|
|
197
|
-
clip: rect(0, 0, 0, 0);
|
|
198
|
-
white-space: nowrap;
|
|
199
|
-
border: 0;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/* Control button */
|
|
203
|
-
.control-btn {
|
|
204
|
-
position: absolute;
|
|
205
|
-
inset-block-start: 8px;
|
|
206
|
-
inset-inline-end: 8px;
|
|
207
|
-
z-index: 10;
|
|
208
|
-
background: rgba(0, 0, 0, 0.7);
|
|
209
|
-
color: white;
|
|
210
|
-
border: none;
|
|
211
|
-
border-radius: 4px;
|
|
212
|
-
padding: 8px;
|
|
213
|
-
cursor: pointer;
|
|
214
|
-
font-size: 14px;
|
|
215
|
-
transition: background-color 0.2s;
|
|
216
|
-
|
|
217
|
-
&:hover {
|
|
218
|
-
background-color: rgba(0, 0, 0, 0.9);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
&:focus {
|
|
222
|
-
outline: 2px solid var(--color-focus, #0066cc);
|
|
223
|
-
outline-offset: 2px;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
.marquee-track {
|
|
228
|
-
display: flex;
|
|
229
|
-
width: fit-content;
|
|
230
|
-
gap: v-bind(gap);
|
|
231
|
-
animation: marqueeMove v-bind(animationRuntime) linear infinite;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
&.reverse .marquee-track {
|
|
235
|
-
animation-direction: reverse;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
.marquee-group {
|
|
239
|
-
display: flex;
|
|
240
|
-
gap: v-bind(gap);
|
|
241
|
-
flex-shrink: 0;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
.item {
|
|
245
|
-
width: v-bind(width);
|
|
246
|
-
height: v-bind(height);
|
|
247
|
-
display: grid;
|
|
248
|
-
place-items: center;
|
|
249
|
-
aspect-ratio: 1 / 1;
|
|
250
|
-
transition: filter 0.5s;
|
|
251
|
-
flex-shrink: 0;
|
|
252
|
-
|
|
253
|
-
border: 1px solid light-dark(var(--slate-10), var(--slate-00));
|
|
254
|
-
border-radius: 4px;
|
|
255
|
-
|
|
256
|
-
&:hover {
|
|
257
|
-
filter: grayscale(0);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
@keyframes marqueeMove {
|
|
263
|
-
from {
|
|
264
|
-
transform: translateX(0);
|
|
265
|
-
}
|
|
266
|
-
to {
|
|
267
|
-
transform: translateX(-50%);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
/* High contrast mode support */
|
|
272
|
-
@media (prefers-contrast: high) {
|
|
273
|
-
.marquee-scroller {
|
|
274
|
-
.control-btn {
|
|
275
|
-
background: ButtonFace;
|
|
276
|
-
color: ButtonText;
|
|
277
|
-
border: 1px solid ButtonText;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
/* Respect user's motion preferences */
|
|
283
|
-
@media (prefers-reduced-motion: reduce) {
|
|
284
|
-
.marquee-scroller .marquee-track {
|
|
285
|
-
animation: none !important;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
</style>
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
class="masonry-grid-wrapper"
|
|
4
|
-
:class="[elementClasses]"
|
|
5
|
-
:style="`--_masonry-grid-gap: ${gap}${unit}; --_item-min-width: ${itemMinWidth}px`"
|
|
6
|
-
>
|
|
7
|
-
<template v-for="item in gridData" :key="item.id">
|
|
8
|
-
<div class="masonry-grid-item">
|
|
9
|
-
<slot :name="item.id"></slot>
|
|
10
|
-
</div>
|
|
11
|
-
</template>
|
|
12
|
-
</div>
|
|
13
|
-
</template>
|
|
14
|
-
|
|
15
|
-
<script setup lang="ts">
|
|
16
|
-
const props = defineProps({
|
|
17
|
-
gridData: {
|
|
18
|
-
type: Object,
|
|
19
|
-
default: () => ({}),
|
|
20
|
-
},
|
|
21
|
-
itemMinWidth: {
|
|
22
|
-
type: Number,
|
|
23
|
-
default: 300,
|
|
24
|
-
},
|
|
25
|
-
gap: {
|
|
26
|
-
type: Number,
|
|
27
|
-
default: 1.2,
|
|
28
|
-
},
|
|
29
|
-
unit: {
|
|
30
|
-
type: String,
|
|
31
|
-
default: "rem",
|
|
32
|
-
},
|
|
33
|
-
styleClassPassthrough: {
|
|
34
|
-
type: [String, Array] as PropType<string | string[]>,
|
|
35
|
-
default: () => [],
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
const { elementClasses, resetElementClasses } = useStyleClassPassthrough(props.styleClassPassthrough);
|
|
40
|
-
|
|
41
|
-
const gridData = toRef(() => props.gridData);
|
|
42
|
-
|
|
43
|
-
watch(
|
|
44
|
-
() => props.styleClassPassthrough,
|
|
45
|
-
() => {
|
|
46
|
-
resetElementClasses(props.styleClassPassthrough);
|
|
47
|
-
}
|
|
48
|
-
);
|
|
49
|
-
</script>
|
|
50
|
-
|
|
51
|
-
<style lang="css">
|
|
52
|
-
@layer components {
|
|
53
|
-
.masonry-grid-wrapper {
|
|
54
|
-
--_border-color: light-dark(hsl(0, 29%, 3%), hsl(0, 0%, 92%));
|
|
55
|
-
--_color: light-dark(hsl(0, 29%, 3%), hsl(0, 0%, 92%));
|
|
56
|
-
|
|
57
|
-
columns: auto var(--_item-min-width);
|
|
58
|
-
column-gap: var(--_masonry-grid-gap);
|
|
59
|
-
|
|
60
|
-
.masonry-grid-item {
|
|
61
|
-
break-inside: avoid;
|
|
62
|
-
outline: 0.1rem solid var(--_border-color);
|
|
63
|
-
padding: 1.2rem;
|
|
64
|
-
margin-block-end: var(--_masonry-grid-gap);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
</style>
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="masonry-grid-ordered" :class="[elementClasses]">
|
|
3
|
-
<div class="masonry-grid-ordered-wrapper" ref="gridWrapper">
|
|
4
|
-
<div v-for="item in gridData" :key="item.id" class="masonry-grid-ordered-item" ref="gridItemsRefs">
|
|
5
|
-
<slot :name="item.id"></slot>
|
|
6
|
-
</div>
|
|
7
|
-
</div>
|
|
8
|
-
</div>
|
|
9
|
-
</template>
|
|
10
|
-
|
|
11
|
-
<script setup lang="ts">
|
|
12
|
-
import { useElementSize, useResizeObserver } from "@vueuse/core"
|
|
13
|
-
|
|
14
|
-
const props = defineProps({
|
|
15
|
-
gridData: {
|
|
16
|
-
type: Object,
|
|
17
|
-
default: () => ({}),
|
|
18
|
-
},
|
|
19
|
-
minTileWidth: {
|
|
20
|
-
type: Number,
|
|
21
|
-
default: 312,
|
|
22
|
-
},
|
|
23
|
-
gap: {
|
|
24
|
-
type: Number,
|
|
25
|
-
default: 12,
|
|
26
|
-
},
|
|
27
|
-
styleClassPassthrough: {
|
|
28
|
-
type: [String, Array] as PropType<string | string[]>,
|
|
29
|
-
default: () => [],
|
|
30
|
-
},
|
|
31
|
-
mobilePreferredColCount: {
|
|
32
|
-
type: Number,
|
|
33
|
-
default: 1,
|
|
34
|
-
},
|
|
35
|
-
fixedWidth: {
|
|
36
|
-
type: Boolean,
|
|
37
|
-
default: false,
|
|
38
|
-
},
|
|
39
|
-
justify: {
|
|
40
|
-
type: String as PropType<String>,
|
|
41
|
-
default: "left",
|
|
42
|
-
validator: (val: string) => ["left", "center", "right"].includes(val),
|
|
43
|
-
},
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
const { elementClasses, resetElementClasses } = useStyleClassPassthrough(props.styleClassPassthrough)
|
|
47
|
-
|
|
48
|
-
const gridData = toRef(() => props.gridData)
|
|
49
|
-
|
|
50
|
-
const minTileWidth = toRef(() => props.minTileWidth)
|
|
51
|
-
const gridWrapper = ref<null | HTMLDivElement>(null)
|
|
52
|
-
const gridItemsRefs = ref<HTMLDivElement[]>([])
|
|
53
|
-
const { width } = useElementSize(gridWrapper)
|
|
54
|
-
const columnCount = computed(() => {
|
|
55
|
-
return Math.floor(width.value / minTileWidth.value)
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
const gapNum = toRef(props.gap)
|
|
59
|
-
const gapStr = toRef(props.gap + "px")
|
|
60
|
-
|
|
61
|
-
const fixedWidth = toRef(() => props.fixedWidth)
|
|
62
|
-
const minTileWidthStr = toRef(props.minTileWidth + "px")
|
|
63
|
-
const maxTileWidth = computed(() => {
|
|
64
|
-
return fixedWidth.value ? minTileWidth.value + "px" : "1fr"
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
const justify = computed(() => {
|
|
68
|
-
return fixedWidth.value ? props.justify : "stretch"
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
const updateGrid = () => {
|
|
72
|
-
if (gridWrapper.value !== null) {
|
|
73
|
-
const wrapperWidth = gridWrapper.value?.offsetWidth ?? 0
|
|
74
|
-
const itemWidth = fixedWidth.value
|
|
75
|
-
? minTileWidth.value
|
|
76
|
-
: Math.floor((wrapperWidth - (columnCount.value - 1) * gapNum.value) / columnCount.value)
|
|
77
|
-
|
|
78
|
-
const colHeights = Array(columnCount.value).fill(0)
|
|
79
|
-
|
|
80
|
-
gridItemsRefs.value.forEach((item) => {
|
|
81
|
-
const minHeight = Math.min(...colHeights)
|
|
82
|
-
const minIndex = colHeights.indexOf(minHeight)
|
|
83
|
-
|
|
84
|
-
item?.style.setProperty("--_position", "absolute")
|
|
85
|
-
item?.style.setProperty("--_position-top", minHeight + "px")
|
|
86
|
-
item?.style.setProperty("--_position-left", minIndex * (100 / columnCount.value) + "%")
|
|
87
|
-
item?.style.setProperty("--_element-width", itemWidth + "px")
|
|
88
|
-
|
|
89
|
-
colHeights[minIndex] += Math.floor(item.offsetHeight + gapNum.value)
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
const maxHeight = Math.max(...colHeights)
|
|
93
|
-
gridWrapper.value?.style.setProperty("--_wrapper-height", maxHeight + "px")
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
useResizeObserver(gridWrapper, () => {
|
|
98
|
-
updateGrid()
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
watch(
|
|
102
|
-
() => fixedWidth.value,
|
|
103
|
-
() => {
|
|
104
|
-
updateGrid()
|
|
105
|
-
}
|
|
106
|
-
)
|
|
107
|
-
|
|
108
|
-
watch(
|
|
109
|
-
() => props.styleClassPassthrough,
|
|
110
|
-
() => {
|
|
111
|
-
resetElementClasses(props.styleClassPassthrough)
|
|
112
|
-
}
|
|
113
|
-
)
|
|
114
|
-
</script>
|
|
115
|
-
|
|
116
|
-
<style scoped lang="css">
|
|
117
|
-
@layer components {
|
|
118
|
-
.masonry-grid-ordered {
|
|
119
|
-
--_border-color: light-dark(hsl(0, 29%, 3%), hsl(0, 0%, 92%));
|
|
120
|
-
--_transition-duration: 0.3s;
|
|
121
|
-
|
|
122
|
-
container-type: inline-size;
|
|
123
|
-
position: relative;
|
|
124
|
-
|
|
125
|
-
transition: max-width var(--_transition-duration) ease;
|
|
126
|
-
|
|
127
|
-
.masonry-grid-ordered-wrapper {
|
|
128
|
-
display: grid;
|
|
129
|
-
justify-self: v-bind(justify);
|
|
130
|
-
grid-gap: v-bind(gapStr);
|
|
131
|
-
grid-template-columns: repeat(1, minmax(v-bind(minTileWidthStr), v-bind(maxTileWidth)));
|
|
132
|
-
position: relative;
|
|
133
|
-
|
|
134
|
-
height: var(--_wrapper-height);
|
|
135
|
-
|
|
136
|
-
@container (min-width: 768px) {
|
|
137
|
-
grid-template-columns: repeat(2, minmax(v-bind(minTileWidthStr), v-bind(maxTileWidth)));
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
@container (min-width: 1024px) {
|
|
141
|
-
grid-template-columns: repeat(3, minmax(v-bind(minTileWidthStr), v-bind(maxTileWidth)));
|
|
142
|
-
}
|
|
143
|
-
@container (min-width: 1280px) {
|
|
144
|
-
grid-template-columns: repeat(4, minmax(v-bind(minTileWidthStr), v-bind(maxTileWidth)));
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
.masonry-grid-ordered-item {
|
|
148
|
-
transition: position var(--_transition-duration) ease, top var(--_transition-duration) ease,
|
|
149
|
-
left var(--_transition-duration) ease;
|
|
150
|
-
|
|
151
|
-
position: var(--_position);
|
|
152
|
-
top: var(--_position-top);
|
|
153
|
-
left: var(--_position-left);
|
|
154
|
-
width: var(--_element-width);
|
|
155
|
-
|
|
156
|
-
outline: 0.1rem solid var(--_border-color);
|
|
157
|
-
padding: 1.2rem;
|
|
158
|
-
border-radius: 4px;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
</style>
|