Skip to content
This repository was archived by the owner on Nov 5, 2023. It is now read-only.

Commit 94961da

Browse files
committed
build: remove unnecessary entries from .npmignore
1 parent 025df65 commit 94961da

File tree

5 files changed

+35
-61
lines changed

5 files changed

+35
-61
lines changed

.npmignore

-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
11
*
22
!/dist/
3-
!package.json
4-
!LICENSE
5-
!README.md

README.md

+5-11
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ npm istall vue-virtual-scroll-grid
3131
<!-- pageProvider: The callback that returns a page of items as a promise. -->
3232
<Grid :length="1000" :pageSize="2" :pageProvider="pageProvider" class="grid">
3333
<!-- When the item is not loaded, a placeholder is rendered -->
34-
<template v-slot:placeholder="{ index, style, className }">
35-
<div :class="[className, 'item']" :style="style">
34+
<template v-slot:placeholder="{ index, style }">
35+
<div class="item" :style="style">
3636
Placeholder {{ index }}
3737
</div>
3838
</template>
3939
4040
<!-- Render a loaded item -->
41-
<template v-slot:default="{ item, style, index, className }">
42-
<div :class="[className, 'item']" :style="style">
41+
<template v-slot:default="{ item, style, index }">
42+
<div class="item" :style="style">
4343
{{ item }} {{ index }}
4444
</div>
4545
</template>
@@ -66,15 +66,12 @@ export default {
6666
</script>
6767
6868
<style>
69-
/* Import the style from the library */
70-
@import "vue-virtual-scroll-grid/dist/style.css";
71-
7269
.grid {
7370
display: grid;
7471
grid-gap: 20px;
7572
grid-template-rows: 200px;
7673
grid-template-columns: repeat(2, 1fr);
77-
place-items: strech;
74+
place-items: stretch;
7875
}
7976
8077
@media (min-width: 768px) {
@@ -123,7 +120,6 @@ export default {
123120
box-sizing: border-box;
124121
border: 1px solid black;
125122
display: flex;
126-
flex-flow: row nowrap;
127123
justify-content: center;
128124
align-items: center;
129125
}
@@ -160,8 +156,6 @@ following slot props:
160156
- `index`: the index of current item within the list.
161157
- `style`: the style object provided by the library that need to be set on the
162158
item element/component.
163-
- `class`: the class name provided by the library that need to be set on the
164-
item element/component.
165159

166160
The `default` slot has an extra prop `item`, which is the loaded item that is
167161
used for rendering your item element/component.

src/App.vue

+6-14
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,11 @@
55
:pageProvider="pageProvider"
66
:class="$style.grid"
77
>
8-
<template v-slot:placeholder="{ index, style, className }">
9-
<ProductItem :index="index" :class="className" :style="style" />
8+
<template v-slot:placeholder="{ index, style }">
9+
<ProductItem :index="index" :style="style" />
1010
</template>
11-
<template v-slot:default="{ item, style, index, className }">
12-
<ProductItem
13-
:index="index"
14-
:item="item"
15-
:class="className"
16-
:style="style"
17-
/>
11+
<template v-slot:default="{ item, style, index }">
12+
<ProductItem :index="index" :item="item" :style="style" />
1813
</template>
1914
</Grid>
2015
</template>
@@ -27,10 +22,7 @@ import ProductItem from "./ProductItem.vue";
2722
2823
export default defineComponent({
2924
name: "App",
30-
components: {
31-
Grid,
32-
ProductItem,
33-
},
25+
components: { Grid, ProductItem },
3426
setup: () => ({
3527
pageProvider: (pageNumber: number, pageSize: number): Promise<number[]> =>
3628
new Promise((resolve) =>
@@ -55,7 +47,7 @@ export default defineComponent({
5547
grid-gap: 20px;
5648
grid-template-rows: 200px;
5749
grid-template-columns: repeat(2, 1fr);
58-
place-items: strech;
50+
place-items: stretch;
5951
}
6052
6153
@media (min-width: 768px) {

src/Grid.vue

+21-28
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,38 @@
22
<div
33
v-if="length > 0"
44
ref="root"
5-
:class="$style.root"
6-
:style="{ height: `${contentHeight}px` }"
5+
:style="{
6+
height: `${contentHeight}px`,
7+
minHeight: '100%',
8+
overflow: 'hidden',
9+
}"
710
>
811
<div ref="grid" v-bind="$attrs">
9-
<div :class="$style.probe" ref="probe"></div>
12+
<div
13+
:style="{
14+
opacity: 0,
15+
visibility: 'hidden',
16+
gridArea: '1/1',
17+
pointerEvents: 'none',
18+
zIndex: '-1',
19+
placeSelf: 'stretch',
20+
}"
21+
ref="probe"
22+
/>
1023

1124
<template v-for="(internalItem, index) in buffer" :key="index">
1225
<slot
1326
v-if="internalItem.value === undefined"
1427
name="placeholder"
1528
:index="internalItem.index"
1629
:style="internalItem.style"
17-
:className="$style.item"
1830
/>
1931
<slot
2032
v-else
2133
name="default"
2234
:item="internalItem.value"
2335
:index="internalItem.index"
2436
:style="internalItem.style"
25-
:className="$style.item"
2637
/>
2738
</template>
2839
</div>
@@ -69,7 +80,7 @@ import { mapIndexed } from "ramda-adjunct";
6980
interface InternalItem {
7081
index: number;
7182
value: unknown | undefined;
72-
style?: { transform: string };
83+
style?: { transform: string; gridArea: string };
7384
}
7485
7586
export default defineComponent({
@@ -265,7 +276,10 @@ export default defineComponent({
265276
return {
266277
index,
267278
value,
268-
style: { transform: `translate(${x}px, ${y}px)` },
279+
style: {
280+
gridArea: "1/1",
281+
transform: `translate(${x}px, ${y}px)`,
282+
},
269283
} as InternalItem;
270284
})
271285
)(allItems)
@@ -311,24 +325,3 @@ export default defineComponent({
311325
},
312326
});
313327
</script>
314-
315-
<style module>
316-
.root {
317-
min-height: 100%;
318-
overflow: hidden;
319-
}
320-
321-
.probe {
322-
opacity: 0;
323-
visibility: hidden;
324-
grid-area: 1/1;
325-
pointer-events: none;
326-
z-index: -1;
327-
place-self: stretch;
328-
}
329-
330-
.item {
331-
grid-area: 1/1;
332-
will-change: transform;
333-
}
334-
</style>

vite.config.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ export default ({ mode }: ConfigEnv): UserConfig => {
1717
: false,
1818
},
1919
optimizeDeps: { exclude: ["prettier"] },
20-
build: {
21-
cssCodeSplit: false,
22-
...(mode === "demo"
20+
build:
21+
mode === "demo"
2322
? {}
2423
: {
2524
lib: {
@@ -38,7 +37,6 @@ export default ({ mode }: ConfigEnv): UserConfig => {
3837
},
3938
},
4039
},
41-
}),
42-
},
40+
},
4341
};
4442
};

0 commit comments

Comments
 (0)