@thinkpixellab-public/px-vue 3.0.22 → 3.0.23
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/components/PxCardGrid.vue +13 -3
- package/package.json +1 -1
|
@@ -202,6 +202,7 @@ export default {
|
|
|
202
202
|
debug: { type: Boolean, default: false },
|
|
203
203
|
getItemCountFn: { default: null },
|
|
204
204
|
getItemFn: { default: null },
|
|
205
|
+
centerSingleRow: { type: Boolean, default: true },
|
|
205
206
|
},
|
|
206
207
|
|
|
207
208
|
data() {
|
|
@@ -212,14 +213,23 @@ export default {
|
|
|
212
213
|
},
|
|
213
214
|
computed: {
|
|
214
215
|
gridStyle() {
|
|
216
|
+
let rowCount = this.rows?.length || 0;
|
|
217
|
+
let colCount = this.columnCount;
|
|
218
|
+
|
|
219
|
+
if (this.centerSingleRow && rowCount == 1) {
|
|
220
|
+
colCount = 0;
|
|
221
|
+
this.rows[0].forEach(sp => {
|
|
222
|
+
colCount += sp.name == 'wide' ? 2 : 1;
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
|
|
215
226
|
const defAspect = aspect(this.cardAspect);
|
|
216
227
|
const wideAspect = (this.cardMinWidth * 2 + this.gap) / (this.cardMinWidth / defAspect);
|
|
217
|
-
const maxGridWidth =
|
|
218
|
-
this.cardMaxWidth * this.columnCount + this.gap * (this.columnCount - 1);
|
|
228
|
+
const maxGridWidth = this.cardMaxWidth * colCount + this.gap * (this.columnCount - 1);
|
|
219
229
|
|
|
220
230
|
return {
|
|
221
231
|
// prettier-ignore
|
|
222
|
-
gridTemplateColumns: `repeat(${
|
|
232
|
+
gridTemplateColumns: `repeat(${colCount}, 1fr)`,
|
|
223
233
|
maxWidth: this.cssPx(maxGridWidth),
|
|
224
234
|
'--gap': this.cssPx(this.gap),
|
|
225
235
|
'--aspect': defAspect,
|