Skip to content

Commit f7d37d9

Browse files
committed
feat(ui): add $enable-gap
1 parent 24159a1 commit f7d37d9

File tree

3 files changed

+29
-15
lines changed

3 files changed

+29
-15
lines changed

packages/ui/src/components/pagination/Pagination.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ export function DPagination(props: DPaginationProps): JSX.Element | null {
8787

8888
const [jumpValue, setJumpValue] = useState('');
8989
const lastPage = Math.max(Math.ceil(dTotal / pageSize), 1);
90-
const paginationSpace = dMini ? 8 : 16;
9190

9291
return (
9392
<nav
@@ -100,7 +99,7 @@ export function DPagination(props: DPaginationProps): JSX.Element | null {
10099
role="navigation"
101100
aria-label={restProps['aria-label'] ?? 'Pagination Navigation'}
102101
>
103-
{dCompose.map((item, index) => {
102+
{dCompose.map((item) => {
104103
if (item === 'total') {
105104
const totalNode = (() => {
106105
const range: [number, number] = [Math.min((active - 1) * pageSize + 1, dTotal), Math.min(active * pageSize, dTotal)];
@@ -116,7 +115,7 @@ export function DPagination(props: DPaginationProps): JSX.Element | null {
116115
})();
117116

118117
return (
119-
<div key="total" className={`${dPrefix}pagination__total`} style={{ marginLeft: index === 0 ? undefined : paginationSpace }}>
118+
<div key="total" className={`${dPrefix}pagination__total`}>
120119
{totalNode}
121120
</div>
122121
);
@@ -132,7 +131,6 @@ export function DPagination(props: DPaginationProps): JSX.Element | null {
132131
'is-disabled': active === 1,
133132
[`${dPrefix}pagination__button--border`]: !(dCustomRender && dCustomRender.prev),
134133
})}
135-
style={{ marginLeft: index === 0 ? undefined : paginationSpace }}
136134
title={t('Pagination', 'Previous page')}
137135
>
138136
{dCustomRender && dCustomRender.prev ? dCustomRender.prev : <LeftOutlined />}
@@ -291,7 +289,6 @@ export function DPagination(props: DPaginationProps): JSX.Element | null {
291289
<DSelect
292290
key="page-size"
293291
className={`${dPrefix}pagination__page-size`}
294-
style={{ marginLeft: index === 0 ? undefined : paginationSpace }}
295292
dList={list}
296293
dModel={pageSize}
297294
dCustomItem={(item) => (dCustomRender && dCustomRender.pageSize ? dCustomRender.pageSize(item.value) : item.label)}
@@ -350,8 +347,10 @@ export function DPagination(props: DPaginationProps): JSX.Element | null {
350347
})();
351348

352349
return (
353-
<div key="jump" className={`${dPrefix}pagination__jump`} style={{ marginLeft: index === 0 ? undefined : paginationSpace }}>
354-
{jumpNode}
350+
<div key="jump">
351+
<div key="jump" className={`${dPrefix}pagination__jump`}>
352+
{jumpNode}
353+
</div>
355354
</div>
356355
);
357356
}

packages/ui/src/styles/_variables.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ $rd-placeholder-color: rgb(var(--#{$rd-prefix}text-color-rgb) / 24%) !default;
1818
$rd-placeholder-disabled-color: rgb(var(--#{$rd-prefix}text-color-rgb) / 8%) !default;
1919

2020
$rd-font-weight-bold: 600 !default;
21+
22+
$enable-gap: false !default;
Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,32 @@
11
@mixin polyfill-gap($row-gap, $column-gap) {
2-
row-gap: #{$row-gap};
3-
4-
& > * + * {
5-
margin-left: #{$column-gap};
2+
@if $enable-gap == true {
3+
gap: #{$row-gap} #{$column-gap};
4+
} @else {
5+
@include polyfill-row-gap($row-gap);
6+
@include polyfill-column-gap($row-gap);
67
}
78
}
89

910
@mixin polyfill-row-gap($row-gap) {
10-
& > * + * {
11-
margin-top: #{$row-gap};
11+
@if $enable-gap == true {
12+
row-gap: #{$row-gap};
13+
} @else {
14+
& {
15+
margin-top: -#{$row-gap};
16+
}
17+
18+
& > * {
19+
margin-top: #{$row-gap};
20+
}
1221
}
1322
}
1423

1524
@mixin polyfill-column-gap($column-gap) {
16-
& > * + * {
17-
margin-left: #{$column-gap};
25+
@if $enable-gap == true {
26+
column-gap: #{$column-gap};
27+
} @else {
28+
& > *:not(:last-child) {
29+
margin-right: #{$column-gap};
30+
}
1831
}
1932
}

0 commit comments

Comments
 (0)