From ae7666f8fa9fe730eb08168311364b7ad78d3785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Wed, 5 Feb 2020 14:23:21 +0800 Subject: [PATCH] fix badge (#21237) --- .../__tests__/__snapshots__/demo.test.js.snap | 60 +- components/badge/ScrollNumber.tsx | 12 +- .../__tests__/__snapshots__/demo.test.js.snap | 540 +++++------ .../__snapshots__/index.test.js.snap | 840 +++++++++--------- components/badge/style/index.less | 2 +- .../__snapshots__/components.test.js.snap | 180 ++-- 6 files changed, 819 insertions(+), 815 deletions(-) diff --git a/components/avatar/__tests__/__snapshots__/demo.test.js.snap b/components/avatar/__tests__/__snapshots__/demo.test.js.snap index 8155713478..12d2adbefc 100644 --- a/components/avatar/__tests__/__snapshots__/demo.test.js.snap +++ b/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%)" >

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

diff --git a/components/badge/ScrollNumber.tsx b/components/badge/ScrollNumber.tsx index 9917d7a52e..584e20f17f 100644 --- a/components/badge/ScrollNumber.tsx +++ b/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[] = []; for (let i = 0; i < 30; i++) { - const currentClassName = position === i ? 'current' : ''; childrenToReturn.push( -

+

{i % 10}

, ); @@ -138,7 +142,7 @@ class ScrollNumber extends React.Component }, key: i, }, - renderNumberList(position), + renderNumberList(position, `${prefixCls}-only-unit`), ); } diff --git a/components/badge/__tests__/__snapshots__/demo.test.js.snap b/components/badge/__tests__/__snapshots__/demo.test.js.snap index 83389a3f4f..96059fd720 100644 --- a/components/badge/__tests__/__snapshots__/demo.test.js.snap +++ b/components/badge/__tests__/__snapshots__/demo.test.js.snap @@ -19,152 +19,152 @@ exports[`renders ./components/badge/demo/basic.md correctly 1`] = ` style="transition:none;-ms-transform:translateY(-1500%);-webkit-transform:translateY(-1500%);transform:translateY(-1500%)" >

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

@@ -240,152 +240,152 @@ exports[`renders ./components/badge/demo/change.md correctly 1`] = ` style="transition:none;-ms-transform:translateY(-1500%);-webkit-transform:translateY(-1500%);transform:translateY(-1500%)" >

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

@@ -822,152 +822,152 @@ exports[`renders ./components/badge/demo/link.md correctly 1`] = ` style="transition:none;-ms-transform:translateY(-1500%);-webkit-transform:translateY(-1500%);transform:translateY(-1500%)" >

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

@@ -992,152 +992,152 @@ exports[`renders ./components/badge/demo/no-wrapper.md correctly 1`] = ` style="transition:none;-ms-transform:translateY(-1200%);-webkit-transform:translateY(-1200%);transform:translateY(-1200%)" >

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

@@ -1147,152 +1147,152 @@ exports[`renders ./components/badge/demo/no-wrapper.md correctly 1`] = ` style="transition:none;-ms-transform:translateY(-1500%);-webkit-transform:translateY(-1500%);transform:translateY(-1500%)" >

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

@@ -1313,152 +1313,152 @@ exports[`renders ./components/badge/demo/no-wrapper.md correctly 1`] = ` style="transition:none;-ms-transform:translateY(-1400%);-webkit-transform:translateY(-1400%);transform:translateY(-1400%)" >

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

@@ -1499,152 +1499,152 @@ exports[`renders ./components/badge/demo/overflow.md correctly 1`] = ` style="transition:none;-ms-transform:translateY(-1900%);-webkit-transform:translateY(-1900%);transform:translateY(-1900%)" >

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

@@ -1654,152 +1654,152 @@ exports[`renders ./components/badge/demo/overflow.md correctly 1`] = ` style="transition:none;-ms-transform:translateY(-1900%);-webkit-transform:translateY(-1900%);transform:translateY(-1900%)" >

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

@@ -1993,152 +1993,152 @@ exports[`renders ./components/badge/demo/title.md correctly 1`] = ` style="transition:none;-ms-transform:translateY(-1500%);-webkit-transform:translateY(-1500%);transform:translateY(-1500%)" >

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

diff --git a/components/badge/__tests__/__snapshots__/index.test.js.snap b/components/badge/__tests__/__snapshots__/index.test.js.snap index d2ca4b512e..c8e27da353 100644 --- a/components/badge/__tests__/__snapshots__/index.test.js.snap +++ b/components/badge/__tests__/__snapshots__/index.test.js.snap @@ -89,152 +89,152 @@ exports[`Badge render correct with negative number 1`] = ` style="transition:none;-ms-transform:translateY(-1100%);-webkit-transform:translateY(-1100%);transform:translateY(-1100%)" >

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

@@ -244,152 +244,152 @@ exports[`Badge render correct with negative number 1`] = ` style="transition:none;-ms-transform:translateY(-1000%);-webkit-transform:translateY(-1000%);transform:translateY(-1000%)" >

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

@@ -414,152 +414,152 @@ exports[`Badge render correct with negative number 1`] = ` style="transition:none;-ms-transform:translateY(-1100%);-webkit-transform:translateY(-1100%);transform:translateY(-1100%)" >

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

@@ -569,152 +569,152 @@ exports[`Badge render correct with negative number 1`] = ` style="transition:none;-ms-transform:translateY(-1000%);-webkit-transform:translateY(-1000%);transform:translateY(-1000%)" >

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

@@ -739,152 +739,152 @@ exports[`Badge should be compatible with borderColor style 1`] = ` style="transition:none;-ms-transform:translateY(-1400%);-webkit-transform:translateY(-1400%);transform:translateY(-1400%)" >

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

@@ -952,181 +952,181 @@ exports[`Badge should render when count is changed 1`] = ` } >

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9 @@ -1199,181 +1199,181 @@ exports[`Badge should render when count is changed 2`] = ` } >

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9 @@ -1392,181 +1392,181 @@ exports[`Badge should render when count is changed 2`] = ` } >

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9 @@ -1639,181 +1639,181 @@ exports[`Badge should render when count is changed 3`] = ` } >

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9 @@ -1832,181 +1832,181 @@ exports[`Badge should render when count is changed 3`] = ` } >

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9 @@ -2079,181 +2079,181 @@ exports[`Badge should render when count is changed 4`] = ` } >

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9 @@ -2272,181 +2272,181 @@ exports[`Badge should render when count is changed 4`] = ` } >

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9 @@ -2519,181 +2519,181 @@ exports[`Badge should render when count is changed 5`] = ` } >

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9 @@ -2712,181 +2712,181 @@ exports[`Badge should render when count is changed 5`] = ` } >

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9 diff --git a/components/badge/style/index.less b/components/badge/style/index.less index d638e0a15b..4a1e2e0c97 100644 --- a/components/badge/style/index.less +++ b/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; } diff --git a/components/config-provider/__tests__/__snapshots__/components.test.js.snap b/components/config-provider/__tests__/__snapshots__/components.test.js.snap index f3b7a87558..a6791aa0bb 100644 --- a/components/config-provider/__tests__/__snapshots__/components.test.js.snap +++ b/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%)" >

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

@@ -625,152 +625,152 @@ exports[`ConfigProvider components Badge normal 1`] = ` style="transition:none;-ms-transform:translateY(-1500%);-webkit-transform:translateY(-1500%);transform:translateY(-1500%)" >

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

@@ -805,152 +805,152 @@ exports[`ConfigProvider components Badge prefixCls 1`] = ` style="transition:none;-ms-transform:translateY(-1500%);-webkit-transform:translateY(-1500%);transform:translateY(-1500%)" >

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9