Skip to content

Commit

Permalink
docs: update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mfuu committed Jun 19, 2024
1 parent 79dd2c7 commit a7fe198
Show file tree
Hide file tree
Showing 15 changed files with 60 additions and 108 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ defaults:
run:
working-directory: ./docs

defaults:
run:
working-directory: ./docs

permissions:
contents: write

Expand Down
4 changes: 2 additions & 2 deletions docs/.vitepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ export default defineConfig({
'/demo/': {
base: '/demo/',
items: [
{ text: 'Basic', link: 'index' },
{ text: 'Basic', link: 'basic' },
{ text: 'Group', link: 'group' },
{ text: 'Infinity', link: 'infinity' },
{ text: 'Horizontal', link: 'horizontal' },
{ text: 'Customize scroller', link: 'scroller' },
{ text: 'Scroll To', link: 'scrollto' },
{ text: 'Table Mode', link: 'table' },
{ text: 'Customize Scroller', link: 'scroller' },
],
},
},
Expand Down
8 changes: 7 additions & 1 deletion docs/components/basic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
:keeps="15"
data-key="id"
handle=".handle"
chosen-class="chosen"
class="basic-list"
>
<template v-slot:item="{ record, index, dateKey }">
Expand Down Expand Up @@ -37,9 +38,10 @@ export default {
<style scoped>
.basic-list {
height: 500px;
padding: 5px;
}
.basic-list .list-item {
.list-item {
position: relative;
border-radius: 5px;
box-shadow: 0px 2px 10px -5px #57bbb4;
Expand All @@ -59,4 +61,8 @@ export default {
cursor: grab;
text-align: right;
}
.chosen {
box-shadow: 0px 0px 0px 2px #30a46c;
}
</style>
19 changes: 13 additions & 6 deletions docs/components/group.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
data-key="id"
handle=".handle"
:group="group"
chosen-class="chosen"
class="virtual-list"
>
<template v-slot:item="{ record, index, dateKey }">
<div class="list-item">
<div class="item-title">
<span class="index">#{{ index }}</span>
<span class="index"># {{ index }}-{{ record.name }}</span>
<span class="handle">☰</span>
</div>
<p>{{ record.desc }}</p>
</div>
</template>
</virtual-list>
Expand All @@ -25,15 +25,15 @@
data-key="id"
handle=".handle"
:group="group"
chosen-class="chosen"
class="virtual-list"
>
<template v-slot:item="{ record, index, dateKey }">
<div class="list-item">
<div class="item-title">
<span class="index">#{{ index }}</span>
<span class="index"># {{ index }}-{{ record.name }}</span>
<span class="handle">☰</span>
</div>
<p>{{ record.desc }}</p>
</div>
</template>
</virtual-list>
Expand Down Expand Up @@ -64,17 +64,20 @@ export default {
justify-content: space-between;
}
.group-list .virtual-list {
.virtual-list {
height: 500px;
width: 49%;
padding: 5px;
display: inline-block;
}
.group-list .list-item {
.list-item {
position: relative;
border-radius: 5px;
box-shadow: 0px 2px 10px -5px #57bbb4;
padding: 16px;
height: 50px;
overflow: hidden;
}
.item-title {
Expand All @@ -90,4 +93,8 @@ export default {
cursor: grab;
text-align: right;
}
.chosen {
box-shadow: 0px 0px 0px 2px #30a46c;
}
</style>
9 changes: 8 additions & 1 deletion docs/components/horizontal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
handle=".handle"
direction="horizontal"
class="horizontal-list"
chosen-class="chosen"
:wrap-style="{ display: 'flex' }"
>
<template v-slot:item="{ record, index, dateKey }">
Expand Down Expand Up @@ -39,9 +40,11 @@ export default {
<style scoped>
.horizontal-list {
height: 500px;
display: flex;
padding: 5px;
}
.horizontal-list .list-item {
.list-item {
position: relative;
border-radius: 5px;
box-shadow: 0px 2px 10px -5px #57bbb4;
Expand All @@ -62,4 +65,8 @@ export default {
cursor: grab;
text-align: right;
}
.chosen {
box-shadow: 0px 0px 0px 2px #30a46c;
}
</style>
8 changes: 7 additions & 1 deletion docs/components/infinity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
data-key="id"
handle=".handle"
class="infinity-list"
chosen-class="chosen"
@bottom="bottomLoading"
>
<template v-slot:item="{ record, index, dateKey }">
Expand Down Expand Up @@ -52,9 +53,10 @@ export default {
<style scoped>
.infinity-list {
height: 500px;
padding: 5px;
}
.infinity-list .list-item {
.list-item {
position: relative;
border-radius: 5px;
box-shadow: 0px 2px 10px -5px #57bbb4;
Expand All @@ -75,6 +77,10 @@ export default {
text-align: right;
}
.chosen {
box-shadow: 0px 0px 0px 2px #30a46c;
}
.footer {
height: 50px;
display: flex;
Expand Down
7 changes: 6 additions & 1 deletion docs/components/scroller.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
data-key="id"
handle=".handle"
:scroller="scroller"
chosen-class="chosen"
class="window-scroll"
>
<template v-slot:item="{ record, index, dateKey }">
Expand Down Expand Up @@ -37,7 +38,7 @@ export default {
</script>

<style scoped>
.window-scroll .list-item {
.list-item {
position: relative;
border-radius: 5px;
box-shadow: 0px 2px 10px -5px #57bbb4;
Expand All @@ -57,4 +58,8 @@ export default {
cursor: grab;
text-align: right;
}
.chosen {
box-shadow: 0px 0px 0px 2px #30a46c;
}
</style>
8 changes: 7 additions & 1 deletion docs/components/scrollto.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
:keeps="15"
data-key="id"
handle=".handle"
chosen-class="chosen"
class="scrollto-list"
>
<template v-slot:item="{ record, index, dateKey }">
Expand Down Expand Up @@ -71,9 +72,10 @@ export default {
.scrollto-list {
height: 500px;
padding: 5px;
}
.scrollto-list .list-item {
.list-item {
position: relative;
border-radius: 5px;
box-shadow: 0px 2px 10px -5px #57bbb4;
Expand All @@ -94,6 +96,10 @@ export default {
text-align: right;
}
.chosen {
box-shadow: 0px 0px 0px 2px #30a46c;
}
input {
width: 55px;
border: 1px solid #aaa;
Expand Down
8 changes: 7 additions & 1 deletion docs/components/table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
data-key="id"
handle=".handle"
class="table-list"
chosen-class="chosen"
:table-mode="true"
>
<template v-slot:header>
Expand Down Expand Up @@ -48,9 +49,10 @@ export default {
<style scoped>
.table-list {
height: 500px;
padding: 5px;
}
.table-list .list-item {
.list-item {
position: relative;
border-radius: 5px;
box-shadow: 0px 2px 10px -5px #57bbb4;
Expand All @@ -70,4 +72,8 @@ export default {
cursor: grab;
text-align: right;
}
.chosen {
box-shadow: 0px 0px 0px 2px #30a46c;
}
</style>
17 changes: 0 additions & 17 deletions docs/demo/group.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,4 @@

Drag and drop between groups

**Key Code**
```vue
<virtual-list
...
:group="group"
>
...
</virtual-list>
<script setup>
const group = reactive({
name: 'name',
pull: true,
put: true,
});
</script>
```

<preview path="../components/group.vue" />
13 changes: 0 additions & 13 deletions docs/demo/horizontal.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
# Horizontal list

**Key Code**
```vue
<virtual-list
...
:direction="direction"
>
...
</virtual-list>
<script setup>
const direction = ref('horizontal');
</script>
```

<preview path="../components/horizontal.vue" />
15 changes: 1 addition & 14 deletions docs/demo/scroller.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
# Customize scroller
# Customize Scroller

This Demo uses `scroller: document`

**Key Code**
```vue
<virtual-list
...
:scroller="scroller"
>
...
</virtual-list>
<script setup>
const scroller = ref(document);
</script>
```

<preview path="../components/scroller.vue" />
2 changes: 1 addition & 1 deletion docs/demo/scrollto.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Scroll to ..
# Scroll to

Scroll to the specified location

Expand Down
44 changes: 0 additions & 44 deletions docs/guide/methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,47 +35,3 @@ Scroll to the specified `index` position
## `scrollToOffset(offset: number)`

Scroll to the specified offset

## Example Usage

```vue
<template>
<button @click="scrollToIndex">scroll To Index</button>
<virtual-list
ref="virtualRef"
v-model="list"
data-key="id"
>
<template v-slot:item="{ record, index, dataKey }">
item slot content
</template>
</virtual-list>
</template>
<script>
import virtualList from 'vue-virtual-draglist';
import { ref, reactive, toRefs } from 'vue';
export default {
components: {
virtualList
},
setup() {
const virtualRef = ref(null);
const data = reactive({
list: [{ id: 'a', text: 'a', id: 'b', text: 'b' }],
});
const scrollToIndex = () => {
virtualRef.value.scrollToIndex(0);
}
return {
...toRefs(data),
virtualRef,
scrollToIndex
};
},
};
```
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ hero:
actions:
- theme: brand
text: Quickstart
link: /guide/index
link: /guide/install
- theme: alt
text: GitHub
link: https://github.com/mfuu/vue-virtual-drag-list
Expand Down

0 comments on commit a7fe198

Please sign in to comment.