Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(VPagination): adapt button width for large values #21139

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

J-Sek
Copy link
Contributor

@J-Sek J-Sek commented Mar 22, 2025

Description

fixes #20120

Markup:

<template>
  <v-app>
    <v-container>
      <v-row>
        <v-col>
          <v-number-input v-model="page" label="page" />
        </v-col>
        <v-col>
          <v-select v-model="density" :items="densityOptions" label="density" return-object />
        </v-col>
        <v-col>
          <v-select v-model="rounded" :items="roundedOptions" label="rounded" return-object />
        </v-col>
      </v-row>

      <v-pagination
        v-model="page"
        :density="density.value"
        :length="244444"
        :rounded="rounded.value"
        :total-visible="page > 10000 ? 4 : page > 1000 ? 5 : page > 100 ? 6 : 7"
        class="my-12"
      />
    </v-container>
  </v-app>
</template>

<script setup lang="ts">
  import { ref } from 'vue'
  const page = ref(1)

  interface DensityOption { title: string, value: 'compact' | 'comfortable' | undefined }
  const densityOptions = [...['compact', 'comfortable'].map(x => ({ title: x, value: x } as DensityOption)), { title: '(default)', value: undefined }]
  const density = ref<DensityOption>(densityOptions.at(-1)!)

  interface RoundedOption { title: string, value: 'sm' | 'xl' | 'pill' | undefined }
  const roundedOptions = [...['sm', 'xl', 'pill'].map(x => ({ title: x, value: x } as RoundedOption)), { title: '(default)', value: undefined }]
  const rounded = ref<RoundedOption>(roundedOptions.at(-1)!)
</script>

@J-Sek J-Sek self-assigned this Mar 22, 2025
@J-Sek J-Sek added T: bug Functionality that does not work as intended/expected C: VPagination labels Mar 22, 2025
@J-Sek
Copy link
Contributor Author

J-Sek commented Mar 22, 2025

Introduces

$button-pagination-padding-inline: .75em !default;

It looks better with .5em when using density="compact" and we could possibly bake this into those styles, but I don't want to over-complicate them, so let's leave it on the developers.

@J-Sek J-Sek requested a review from johnleider March 22, 2025 10:59
@KaelWD
Copy link
Member

KaelWD commented Mar 24, 2025

Going even smaller with 5px looks fine to me and keeps the square ratio for 2 digits at comfortable and 3 digits at default.

Out of scope for this PR but we could do with a feedback loop for sizing, this should drop an item:
Screenshot_20250324_153019

@J-Sek
Copy link
Contributor Author

J-Sek commented Mar 24, 2025

I agree, it looks much better with 5px default.

image

@J-Sek J-Sek force-pushed the fix/20120-pagination-btn-width branch from e1970ee to 3e17a43 Compare March 24, 2025 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VPagination T: bug Functionality that does not work as intended/expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug Report][3.6.11] If the length is too large in the v-pagination component
2 participants