Browse Source

fix badge (#21237)

pull/21265/head
二货机器人 5 years ago
committed by GitHub
parent
commit
ae7666f8fa
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 60
      components/avatar/__tests__/__snapshots__/demo.test.js.snap
  2. 12
      components/badge/ScrollNumber.tsx
  3. 540
      components/badge/__tests__/__snapshots__/demo.test.js.snap
  4. 840
      components/badge/__tests__/__snapshots__/index.test.js.snap
  5. 2
      components/badge/style/index.less
  6. 180
      components/config-provider/__tests__/__snapshots__/components.test.js.snap

60
components/avatar/__tests__/__snapshots__/demo.test.js.snap

@ -41,152 +41,152 @@ exports[`renders ./components/avatar/demo/badge.md correctly 1`] = `
style="transition:none;-ms-transform:translateY(-1100%);-webkit-transform:translateY(-1100%);transform:translateY(-1100%)"
>
<p
class=""
class="ant-scroll-number-only-unit"
>
0
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
1
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
2
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
3
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
4
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
5
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
6
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
7
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
8
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
9
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
0
</p>
<p
class="current"
class="ant-scroll-number-only-unit current"
>
1
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
2
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
3
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
4
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
5
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
6
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
7
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
8
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
9
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
0
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
1
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
2
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
3
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
4
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
5
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
6
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
7
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
8
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
9
</p>

12
components/badge/ScrollNumber.tsx

@ -17,12 +17,16 @@ function getNumberArray(num: string | number | undefined | null) {
: [];
}
function renderNumberList(position: number) {
function renderNumberList(position: number, className: string) {
const childrenToReturn: React.ReactElement<any>[] = [];
for (let i = 0; i < 30; i++) {
const currentClassName = position === i ? 'current' : '';
childrenToReturn.push(
<p key={i.toString()} className={currentClassName}>
<p
key={i.toString()}
className={classNames(className, {
current: position === i,
})}
>
{i % 10}
</p>,
);
@ -138,7 +142,7 @@ class ScrollNumber extends React.Component<ScrollNumberProps, ScrollNumberState>
},
key: i,
},
renderNumberList(position),
renderNumberList(position, `${prefixCls}-only-unit`),
);
}

540
components/badge/__tests__/__snapshots__/demo.test.js.snap

File diff suppressed because it is too large

840
components/badge/__tests__/__snapshots__/index.test.js.snap

File diff suppressed because it is too large

2
components/badge/style/index.less

@ -159,7 +159,7 @@
display: inline-block;
height: @badge-height;
transition: all 0.3s @ease-in-out;
> p {
> p.@{number-prefix-cls}-only-unit {
height: @badge-height;
margin: 0;
}

180
components/config-provider/__tests__/__snapshots__/components.test.js.snap

@ -445,152 +445,152 @@ exports[`ConfigProvider components Badge configProvider 1`] = `
style="transition:none;-ms-transform:translateY(-1500%);-webkit-transform:translateY(-1500%);transform:translateY(-1500%)"
>
<p
class=""
class="config-scroll-number-only-unit"
>
0
</p>
<p
class=""
class="config-scroll-number-only-unit"
>
1
</p>
<p
class=""
class="config-scroll-number-only-unit"
>
2
</p>
<p
class=""
class="config-scroll-number-only-unit"
>
3
</p>
<p
class=""
class="config-scroll-number-only-unit"
>
4
</p>
<p
class=""
class="config-scroll-number-only-unit"
>
5
</p>
<p
class=""
class="config-scroll-number-only-unit"
>
6
</p>
<p
class=""
class="config-scroll-number-only-unit"
>
7
</p>
<p
class=""
class="config-scroll-number-only-unit"
>
8
</p>
<p
class=""
class="config-scroll-number-only-unit"
>
9
</p>
<p
class=""
class="config-scroll-number-only-unit"
>
0
</p>
<p
class=""
class="config-scroll-number-only-unit"
>
1
</p>
<p
class=""
class="config-scroll-number-only-unit"
>
2
</p>
<p
class=""
class="config-scroll-number-only-unit"
>
3
</p>
<p
class=""
class="config-scroll-number-only-unit"
>
4
</p>
<p
class="current"
class="config-scroll-number-only-unit current"
>
5
</p>
<p
class=""
class="config-scroll-number-only-unit"
>
6
</p>
<p
class=""
class="config-scroll-number-only-unit"
>
7
</p>
<p
class=""
class="config-scroll-number-only-unit"
>
8
</p>
<p
class=""
class="config-scroll-number-only-unit"
>
9
</p>
<p
class=""
class="config-scroll-number-only-unit"
>
0
</p>
<p
class=""
class="config-scroll-number-only-unit"
>
1
</p>
<p
class=""
class="config-scroll-number-only-unit"
>
2
</p>
<p
class=""
class="config-scroll-number-only-unit"
>
3
</p>
<p
class=""
class="config-scroll-number-only-unit"
>
4
</p>
<p
class=""
class="config-scroll-number-only-unit"
>
5
</p>
<p
class=""
class="config-scroll-number-only-unit"
>
6
</p>
<p
class=""
class="config-scroll-number-only-unit"
>
7
</p>
<p
class=""
class="config-scroll-number-only-unit"
>
8
</p>
<p
class=""
class="config-scroll-number-only-unit"
>
9
</p>
@ -625,152 +625,152 @@ exports[`ConfigProvider components Badge normal 1`] = `
style="transition:none;-ms-transform:translateY(-1500%);-webkit-transform:translateY(-1500%);transform:translateY(-1500%)"
>
<p
class=""
class="ant-scroll-number-only-unit"
>
0
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
1
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
2
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
3
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
4
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
5
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
6
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
7
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
8
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
9
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
0
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
1
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
2
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
3
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
4
</p>
<p
class="current"
class="ant-scroll-number-only-unit current"
>
5
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
6
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
7
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
8
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
9
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
0
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
1
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
2
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
3
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
4
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
5
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
6
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
7
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
8
</p>
<p
class=""
class="ant-scroll-number-only-unit"
>
9
</p>
@ -805,152 +805,152 @@ exports[`ConfigProvider components Badge prefixCls 1`] = `
style="transition:none;-ms-transform:translateY(-1500%);-webkit-transform:translateY(-1500%);transform:translateY(-1500%)"
>
<p
class=""
class="prefix-scroll-number-only-unit"
>
0
</p>
<p
class=""
class="prefix-scroll-number-only-unit"
>
1
</p>
<p
class=""
class="prefix-scroll-number-only-unit"
>
2
</p>
<p
class=""
class="prefix-scroll-number-only-unit"
>
3
</p>
<p
class=""
class="prefix-scroll-number-only-unit"
>
4
</p>
<p
class=""
class="prefix-scroll-number-only-unit"
>
5
</p>
<p
class=""
class="prefix-scroll-number-only-unit"
>
6
</p>
<p
class=""
class="prefix-scroll-number-only-unit"
>
7
</p>
<p
class=""
class="prefix-scroll-number-only-unit"
>
8
</p>
<p
class=""
class="prefix-scroll-number-only-unit"
>
9
</p>
<p
class=""
class="prefix-scroll-number-only-unit"
>
0
</p>
<p
class=""
class="prefix-scroll-number-only-unit"
>
1
</p>
<p
class=""
class="prefix-scroll-number-only-unit"
>
2
</p>
<p
class=""
class="prefix-scroll-number-only-unit"
>
3
</p>
<p
class=""
class="prefix-scroll-number-only-unit"
>
4
</p>
<p
class="current"
class="prefix-scroll-number-only-unit current"
>
5
</p>
<p
class=""
class="prefix-scroll-number-only-unit"
>
6
</p>
<p
class=""
class="prefix-scroll-number-only-unit"
>
7
</p>
<p
class=""
class="prefix-scroll-number-only-unit"
>
8
</p>
<p
class=""
class="prefix-scroll-number-only-unit"
>
9
</p>
<p
class=""
class="prefix-scroll-number-only-unit"
>
0
</p>
<p
class=""
class="prefix-scroll-number-only-unit"
>
1
</p>
<p
class=""
class="prefix-scroll-number-only-unit"
>
2
</p>
<p
class=""
class="prefix-scroll-number-only-unit"
>
3
</p>
<p
class=""
class="prefix-scroll-number-only-unit"
>
4
</p>
<p
class=""
class="prefix-scroll-number-only-unit"
>
5
</p>
<p
class=""
class="prefix-scroll-number-only-unit"
>
6
</p>
<p
class=""
class="prefix-scroll-number-only-unit"
>
7
</p>
<p
class=""
class="prefix-scroll-number-only-unit"
>
8
</p>
<p
class=""
class="prefix-scroll-number-only-unit"
>
9
</p>

Loading…
Cancel
Save