- Add tailwindcss v4 + @tailwindcss/vite to mall, shop-admin, admin - Add @vmall/shared/theme.css tokens with html[data-accent] presets - Add @vmall/ui kit (VBtn/VBadge/VField/VInput/VCard/VPanel/VTable/VPage, VAccentSwatch, useAccent) as a Nuxt module - Convert all three apps to kit + utilities; delete ui.css/mall.css and every <style scoped>; consoles get accent presets, mall locked to red - Fix VCard boolean prop default (padding) and PDP/store stale useAsyncData keys on param navigation - Archive adopt-tailwind-design-system; new frontend-ui capability spec
44 lines
1.6 KiB
Vue
44 lines
1.6 KiB
Vue
<script setup lang="ts">
|
|
const props = defineProps<{ page: number; total: number; perPage: number }>();
|
|
const emit = defineEmits<{ change: [page: number] }>();
|
|
|
|
const pages = computed(() => Math.max(1, Math.ceil(props.total / props.perPage)));
|
|
const window_ = computed(() => {
|
|
const p = props.page;
|
|
const n = pages.value;
|
|
const start = Math.max(1, Math.min(p - 2, n - 4));
|
|
const out: number[] = [];
|
|
for (let i = start; i <= Math.min(n, start + 4); i++) out.push(i);
|
|
return out;
|
|
});
|
|
|
|
function go(p: number): void {
|
|
if (p >= 1 && p <= pages.value && p !== props.page) emit("change", p);
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<nav v-if="pages > 1" class="my-[30px] flex justify-center gap-1.5">
|
|
<button
|
|
type="button"
|
|
class="h-[34px] min-w-[34px] rounded-sm border border-border bg-surface px-2 text-[13px] transition-colors disabled:cursor-not-allowed disabled:opacity-40"
|
|
:disabled="page <= 1"
|
|
@click="go(page - 1)"
|
|
>{{ $t("common.prev") }}</button>
|
|
<button
|
|
v-for="p in window_"
|
|
:key="p"
|
|
type="button"
|
|
class="h-[34px] min-w-[34px] rounded-sm border border-border px-2 text-[13px] transition-colors"
|
|
:class="p === page ? 'border-primary bg-primary text-white' : 'bg-surface hover:border-primary hover:text-primary'"
|
|
@click="go(p)"
|
|
>{{ p }}</button>
|
|
<button
|
|
type="button"
|
|
class="h-[34px] min-w-[34px] rounded-sm border border-border bg-surface px-2 text-[13px] transition-colors disabled:cursor-not-allowed disabled:opacity-40"
|
|
:disabled="page >= pages"
|
|
@click="go(page + 1)"
|
|
>{{ $t("common.next") }}</button>
|
|
</nav>
|
|
</template>
|