Skip to content

Commit

Permalink
refactor(pager): [pager] refactor pager style (#2162)
Browse files Browse the repository at this point in the history
* refactor(pager): [pager] refactor pager style

* refactor(pager): [pager] refactor pager style

* refactor(pager): [pager] refactor pager style

* refactor(pager): [pager] inline pager design config

* refactor(pager): [pager] refactor pager style

* refactor(pager): [pager] refactor pager style
  • Loading branch information
gimmyhehe authored Sep 23, 2024
1 parent 4037cb3 commit 2f4db09
Show file tree
Hide file tree
Showing 11 changed files with 292 additions and 357 deletions.
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@
"backgroundColor": "transparent",
"bold": false,
"italic": false
},
{
"tag": "--",
"color": "#FFFFFF",
"strikethrough": false,
"underline": false,
"backgroundColor": "#5CB300",
"bold": false,
"italic": false
}
],
"vue.codeActions.enabled": false
Expand Down
2 changes: 1 addition & 1 deletion examples/sites/demos/pc/app/pager/disabled-and-size.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="content">
是否禁用:<tiny-switch v-model="isDisabled"></tiny-switch>
<tiny-pager mode="number" :total="100" :disabled="isDisabled" />
<tiny-pager :total="100" size="mini" :disabled="isDisabled" />
<tiny-pager mode="number" :total="100" size="mini" :disabled="isDisabled" />
</div>
</template>

Expand Down
3 changes: 1 addition & 2 deletions packages/design/aurora/src/pager/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
export default {
state: {
showJumperSuffix: false,
align: 'right',
totalI18n: 'total',
totalFixedLeft: true
pageSizeText: null
}
}
3 changes: 1 addition & 2 deletions packages/design/saas/src/pager/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
export default {
state: {
showJumperSuffix: false,
align: 'right',
totalI18n: 'total',
totalFixedLeft: true
pageSizeText: null
}
}
2 changes: 0 additions & 2 deletions packages/design/smb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import Form from './src/form'
import FilterBox from './src/filter-box'
import Grid from './src/grid'
import Guide from './src/guide'
import Pager from './src/pager'
import Select from './src/select'
import TreeNode from './src/tree-node'
import TimeSpinner from './src/time-spinner'
Expand All @@ -35,7 +34,6 @@ export default {
FilterBox,
Grid,
Guide,
Pager,
Select,
TreeNode,
TimeSpinner,
Expand Down
6 changes: 0 additions & 6 deletions packages/design/smb/src/pager/index.ts

This file was deleted.

13 changes: 13 additions & 0 deletions packages/renderless/src/pager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,19 @@ export const computedSimplestPagerWidth =
return baseWidth + num * 8
}

export const computedPageSizeText =
({ props, designConfig }: Pick<IPagerRenderlessParams, 'props' | 'designConfig'>) =>
(): string => {
if (props.pageSizeText) {
return props.pageSizeText
}
// 默认返回空字符串,不展示"条/页", 可以通过设置pageSizeText为null来显示。亦或者自定义
if (designConfig?.state && Object.hasOwnProperty.call(designConfig.state, 'pageSizeText')) {
return designConfig.state.pageSizeText
}
return ''
}

export const handleJumperFocus =
({ state }: Pick<IPagerRenderlessParams, 'state'>) =>
(e: Event): void => {
Expand Down
6 changes: 4 additions & 2 deletions packages/renderless/src/pager/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
computedInternalPageCount,
computedSimplestPagerOption,
computedSimplestPagerWidth,
computedPageSizeText,
handleJumperFocus,
handleSizeChange,
handleJumperInput,
Expand Down Expand Up @@ -92,12 +93,12 @@ export const renderless = (
totalText: computed(() => api.computedTotalText()),
internalPageCount: computed(() => api.computedInternalPageCount()),
showJumperSuffix: designConfig?.state?.showJumperSuffix ?? true,
align: props.align || designConfig?.state?.align || 'left',
align: props.align || designConfig?.state?.align || 'right',
totalI18n: designConfig?.state?.totalI18n || 'totals',
totalFixedLeft: computed(
() => props.totalFixedLeft ?? designConfig?.state?.totalFixedLeft ?? props.mode !== 'simplest' ?? true
),
pageSizeText: props.pageSizeText ?? designConfig?.state?.pageSizeText
pageSizeText: computed(() => api.computedPageSizeText())
})

Object.assign(api, {
Expand All @@ -108,6 +109,7 @@ export const renderless = (
computedInternalPageCount: computedInternalPageCount({ props, state }),
computedSimplestPagerOption: computedSimplestPagerOption({ props, state }),
computedSimplestPagerWidth: computedSimplestPagerWidth({ state }),
computedPageSizeText: computedPageSizeText({ props, designConfig }),
getValidCurrentPage: getValidCurrentPage({ state }),
handleJumperFocus: handleJumperFocus({ state }),
handleSizeChange: handleSizeChange({ props, state, api, emit, vm }),
Expand Down
Loading

0 comments on commit 2f4db09

Please sign in to comment.