Skip to content

Commit 25d2b3f

Browse files
SonTT19J-Sek
andauthored
docs(VLazy): update playground example (#20632)
resolves #20579 Co-authored-by: J-Sek <[email protected]>
1 parent 4446ebf commit 25d2b3f

File tree

1 file changed

+50
-26
lines changed

1 file changed

+50
-26
lines changed

packages/docs/src/examples/v-lazy/usage.vue

Lines changed: 50 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
:code="code"
55
:name="name"
66
:options="options"
7+
:script="script"
78
>
8-
<v-responsive
9-
ref="responsive"
10-
class="overflow-y-auto"
11-
max-height="300"
9+
<v-sheet
10+
ref="sheetRef"
11+
:max-height="300"
12+
class="overflow-y-auto ma-4"
13+
elevation="5"
1214
>
1315
<div class="pa-6 text-center position-sticky">
1416
Scroll down
@@ -22,31 +24,23 @@
2224

2325
<v-lazy
2426
v-model="isActive"
25-
:options="{
26-
threshold: .5
27-
}"
27+
:options="{ threshold: .5 }"
2828
min-height="200"
2929
transition="fade-transition"
3030
>
3131
<v-card
3232
class="mx-auto"
33+
color="primary"
3334
max-width="336"
35+
text="This card was rendered later"
36+
title="Lazy card"
3437
>
35-
<v-card-title>Card title</v-card-title>
36-
37-
<v-card-text>
38-
Phasellus magna. Quisque rutrum. Nunc egestas, augue at pellentesque laoreet, felis eros vehicula leo, at malesuada velit leo quis pede. Aliquam lobortis. Quisque libero metus, condimentum nec, tempor a, commodo mollis, magna.
39-
40-
In turpis. In dui magna, posuere eget, vestibulum et, tempor auctor, justo. In turpis. Pellentesque dapibus hendrerit tortor. Ut varius tincidunt libero.
41-
</v-card-text>
42-
4338
<v-card-actions class="justify-center">
4439
<v-btn @click="reset">Reset Demo</v-btn>
4540
</v-card-actions>
4641
</v-card>
4742
</v-lazy>
48-
<br>
49-
</v-responsive>
43+
</v-sheet>
5044
</ExamplesUsageExample>
5145
</template>
5246

@@ -56,17 +50,18 @@
5650
const name = 'v-lazy'
5751
const model = shallowRef('default')
5852
const isActive = shallowRef(false)
59-
const responsive = ref()
53+
const sheetRef = ref()
6054
const options = []
6155
6256
async function reset () {
63-
await goTo(0, { container: responsive.value.$el })
57+
await goTo(0, { container: sheetRef.value.$el })
6458
6559
isActive.value = false
6660
}
6761
6862
const props = computed(() => {
6963
return {
64+
'v-model': 'isActive',
7065
'min-height': 200,
7166
options: { threshold: 0.5 },
7267
transition: 'fade-transition',
@@ -75,15 +70,12 @@
7570
7671
const slots = computed(() => {
7772
return `
78-
<div class="text-center text-body-2 mb-12">
79-
The card will appear below:
80-
</div>
81-
8273
<v-card
8374
class="mx-auto"
75+
color="primary"
8476
max-width="336"
85-
text="Phasellus magna. Quisque rutrum. Nunc egestas, augue at pellentesque laoreet."
86-
title="Card title"
77+
text="This card was rendered later"
78+
title="Lazy card"
8779
>
8880
<v-card-actions class="justify-center">
8981
<v-btn @click="reset">Reset Demo</v-btn>
@@ -92,7 +84,39 @@
9284
`
9385
})
9486
87+
const script = computed(() => {
88+
return `<script setup>
89+
import { ref, shallowRef } from 'vue'
90+
import { useGoTo } from 'vuetify'
91+
92+
const goTo = useGoTo()
93+
94+
const isActive = shallowRef(false)
95+
const sheetRef = ref()
96+
97+
async function reset () {
98+
await goTo(0, { container: sheetRef.value.$el })
99+
100+
isActive.value = false
101+
}
102+
<` + '/script>'
103+
})
104+
95105
const code = computed(() => {
96-
return `<v-lazy${propsToString(props.value)}>${slots.value}</v-lazy>`
106+
return `<v-sheet
107+
ref="sheetRef"
108+
class="overflow-y-auto ma-4"
109+
:max-height="300"
110+
elevation="5"
111+
>
112+
<div class="pa-6 text-center position-sticky">Scroll down</div>
113+
<v-responsive min-height="100vh"></v-responsive>
114+
115+
<div class="text-center text-body-2 mb-12">
116+
The card will appear below:
117+
</div>
118+
119+
<${name}${propsToString(props.value)}>${slots.value}</${name}>
120+
</v-sheet>`
97121
})
98122
</script>

0 commit comments

Comments
 (0)