From 7de79bdfcf3938e15db166c261cb5e4a7b8fa5ba Mon Sep 17 00:00:00 2001 From: kooriookami <38392315+kooriookami@users.noreply.github.com> Date: Sun, 13 Nov 2022 14:09:26 +0800 Subject: [PATCH] style(components): [pagination] Refactor pagination style (#10563) * style(components): [pagination] --- .../pagination/src/components/jumper.ts | 17 + .../pagination/src/components/jumper.vue | 10 +- .../pagination/src/components/pager.vue | 4 +- .../components/pagination/src/pagination.ts | 4 +- packages/theme-chalk/src/common/var.scss | 8 +- packages/theme-chalk/src/pagination.scss | 372 ++++++------------ 6 files changed, 145 insertions(+), 270 deletions(-) create mode 100644 packages/components/pagination/src/components/jumper.ts diff --git a/packages/components/pagination/src/components/jumper.ts b/packages/components/pagination/src/components/jumper.ts new file mode 100644 index 0000000000..0828be0733 --- /dev/null +++ b/packages/components/pagination/src/components/jumper.ts @@ -0,0 +1,17 @@ +import { buildProps } from '@element-plus/utils' +import { componentSizes } from '@element-plus/constants' +import type { ExtractPropTypes } from 'vue' +import type Jumper from './jumper.vue' + +export const paginationJumperProps = buildProps({ + size: { + type: String, + values: componentSizes, + }, +} as const) + +export type PaginationJumperProps = ExtractPropTypes< + typeof paginationJumperProps +> + +export type PaginationJumperInstance = InstanceType diff --git a/packages/components/pagination/src/components/jumper.vue b/packages/components/pagination/src/components/jumper.vue index 97f2f3932a..c78cea9d2a 100644 --- a/packages/components/pagination/src/components/jumper.vue +++ b/packages/components/pagination/src/components/jumper.vue @@ -1,8 +1,8 @@ @@ -22,11 +24,13 @@ import { computed, ref } from 'vue' import { useLocale, useNamespace } from '@element-plus/hooks' import ElInput from '@element-plus/components/input' import { usePagination } from '../usePagination' +import { paginationJumperProps } from './jumper' defineOptions({ name: 'ElPaginationJumper', }) +defineProps(paginationJumperProps) const { t } = useLocale() const ns = useNamespace('pagination') const { pageCount, disabled, currentPage, changeEvent } = usePagination() diff --git a/packages/components/pagination/src/components/pager.vue b/packages/components/pagination/src/components/pager.vue index 40e77cdcd8..e56f4c8cc1 100644 --- a/packages/components/pagination/src/components/pager.vue +++ b/packages/components/pagination/src/components/pager.vue @@ -26,7 +26,7 @@ @focus="onFocus(true)" @blur="quickPrevFocus = false" > - +
  • - +
  • * { + @include when(first) { + margin-left: 0 !important; + } + @include when(last) { + margin-right: 0 !important; } } - .#{$namespace}-pager li.is-disabled { - color: getCssVar('text-color', 'placeholder'); - cursor: not-allowed; - } - - @include m(small) { - .btn-prev, - .btn-next, - .#{$namespace}-pager li, - .#{$namespace}-pager li.btn-quicknext, - .#{$namespace}-pager li.btn-quickprev, - .#{$namespace}-pager li:last-child { - border-color: transparent; - font-size: getCssVar('font-size-extra-small'); - line-height: getCssVar('pagination-line-height-extra-small'); - height: getCssVar('pagination-height-extra-small'); - min-width: 24px; - } - - .arrow.is-disabled { - visibility: hidden; - } - - .more::before, - li.more::before { - line-height: getCssVar('pagination-line-height-extra-small'); - } - - span:not([class*='suffix']), - button { - height: getCssVar('pagination-height-extra-small'); - line-height: getCssVar('pagination-line-height-extra-small'); - font-size: getCssVar('font-size-extra-small'); - } - - @include e(editor) { - height: getCssVar('pagination-line-height-extra-small'); - &.#{$namespace}-input .#{$namespace}-input__inner { - height: getCssVar('pagination-height-extra-small'); - } - } - - .#{$namespace}-input__inner, - .#{$namespace}-input--small { - height: getCssVar('pagination-height-extra-small') !important; - line-height: getCssVar('pagination-line-height-extra-small'); - } - - .#{$namespace}-input__suffix { - line-height: getCssVar('pagination-line-height-extra-small'); - .#{$namespace}-input__suffix-inner { - line-height: getCssVar('pagination-line-height-extra-small'); - i.#{$namespace}-select__caret { - line-height: getCssVar('pagination-line-height-extra-small'); - } - } - } - - .#{$namespace}-select .#{$namespace}-input { - width: 100px; - } + .btn-prev { + margin-left: getCssVar('pagination-item-gap'); } @include e(sizes) { - margin: 0 16px 0 0; + margin-left: getCssVar('pagination-item-gap'); font-weight: normal; color: getCssVar('text-color', 'regular'); - @include remove-margin(); } @include e(total) { - margin-right: 16px; + margin-left: getCssVar('pagination-item-gap'); font-weight: normal; color: getCssVar('text-color', 'regular'); - @include remove-margin(); + &[disabled='true'] { color: getCssVar('text-color', 'placeholder'); } } @include e(jump) { - margin-left: 16px; + display: flex; + align-items: center; + margin-left: getCssVar('pagination-item-gap'); font-weight: normal; color: getCssVar('text-color', 'regular'); - .#{$namespace}-input__inner { - padding: 0 3px; - } - &[disabled='true'] { color: getCssVar('text-color', 'placeholder'); } + + @include e(editor) { + margin-left: 8px; + text-align: center; + box-sizing: border-box; + + &.#{$namespace}-input { + width: 56px; + } + + .#{$namespace}-input__inner::-webkit-inner-spin-button, + .#{$namespace}-input__inner::-webkit-outer-spin-button { + -webkit-appearance: none; + margin: 0; + } + } + } + + @include b(pager) { + user-select: none; + list-style: none; + font-size: 0; + padding: 0; + margin: 0; + display: flex; + align-items: center; + + li { + @include pagination-button; + } } @include e(rightwrapper) { @@ -202,41 +168,19 @@ justify-content: flex-end; } - @include e(editor) { - line-height: 18px; - margin: 0 8px; - height: getCssVar('pagination-button-height'); - min-width: 56px; - - text-align: center; - box-sizing: border-box; - border-radius: getCssVar('pagination-border-radius'); - - &.#{$namespace}-input { - width: 50px; - } - - &.#{$namespace}-input .#{$namespace}-input__inner { - height: getCssVar('pagination-button-height'); - } - - .#{$namespace}-input__inner::-webkit-inner-spin-button, - .#{$namespace}-input__inner::-webkit-outer-spin-button { - -webkit-appearance: none; - margin: 0; - } - } - @include when(background) { .btn-prev, .btn-next, .#{$namespace}-pager li { margin: 0 4px; background-color: getCssVar('pagination-button-bg-color'); - color: getCssVar('text-color', 'regular'); - min-width: 32px; - border-radius: 2px; + &.is-active { + background-color: getCssVar('color-primary'); + color: getCssVar('color-white'); + } + + &:disabled, &.is-disabled { color: getCssVar('text-color', 'placeholder'); background-color: getCssVar('disabled-bg-color'); @@ -246,124 +190,30 @@ background-color: getCssVar('fill-color', 'dark'); } } - @include when(first) { - margin-left: 0; - } - @include when(last) { - margin-right: 0; - } } + .btn-prev { + margin-left: getCssVar('pagination-item-gap'); + } + } + + @include m(small) { .btn-prev, - .btn-next { - padding: 0; - - &:disabled { - color: getCssVar('text-color', 'placeholder'); - background-color: getCssVar('disabled-bg-color'); - } - &:hover:not([disabled]) { - color: getCssVar('pagination-hover-color'); - } + .btn-next, + .#{$namespace}-pager li { + height: getCssVar('pagination-button-height-small'); + line-height: getCssVar('pagination-button-height-small'); + font-size: getCssVar('pagination-font-size-small'); + min-width: getCssVar('pagination-button-width-small'); } - .#{$namespace}-pager li:not(.is-disabled) { - &:hover { - color: getCssVar('pagination-hover-color'); - } - - &.is-active { - background-color: getCssVar('color-primary'); - color: getCssVar('color-white'); - font-weight: bold; - } + span:not([class*='suffix']), + button { + font-size: getCssVar('pagination-font-size-small'); } - &.#{$namespace}-pagination--small { - .btn-prev, - .btn-next, - .#{$namespace}-pager li { - min-width: 24px; - } - } - - @include e(sizes) { - @include when(last) { - margin-left: 16px; - } + .#{$namespace}-select .#{$namespace}-input { + width: 100px; } } } - -@include b(pager) { - user-select: none; - list-style: none; - font-size: 0; - padding: 0; - margin: 0; - display: flex; - align-items: center; - - li { - padding: 0 4px; - background: getCssVar('pagination-bg-color'); - @include pagination-button; - cursor: pointer; - text-align: center; - margin: 0 1px; - - &.btn-quickprev:hover { - cursor: pointer; - } - - &.btn-quicknext:hover { - cursor: pointer; - } - - &.btn-quicknext, - &.btn-quickprev { - line-height: 32px; - color: getCssVar('pagination-button-color'); - - &.is-disabled { - color: getCssVar('text-color', 'placeholder'); - cursor: not-allowed; - } - - svg { - pointer-events: none; - } - - &:focus-visible { - outline: 1px solid getCssVar('pagination-hover-color'); - color: getCssVar('pagination-hover-color'); - } - } - - &.is-active + li { - border-left: 0; - } - - &:focus-visible { - outline: 1px solid getCssVar('pagination-hover-color'); - } - - &:hover { - color: getCssVar('pagination-hover-color'); - } - - &.is-active { - color: getCssVar('pagination-hover-color'); - cursor: default; - - &.is-disabled { - font-weight: bold; - color: getCssVar('text-color', 'secondary'); - } - } - } - - & + button.btn-next[type='button'] { - margin-right: 0; - } -}