style: Badge color should be respected (#43304)

* style: Badge color should be respected

* test: update snapshot

* style: fix Badge color
This commit is contained in:
afc163 2023-07-01 01:30:19 +08:00 committed by GitHub
parent 6ead5ae5ef
commit 1d2f874150
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 1367 additions and 897 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
import React from 'react';
import { Badge, Space } from 'antd';
import React from 'react';
const colors = [
'pink',
@ -17,24 +17,35 @@ const colors = [
'lime',
];
const AvatarItem = ({ color }: { color: string }) => (
<div
style={{
width: 90,
height: 90,
lineHeight: '90px',
background: '#ccc',
textAlign: 'center',
}}
>
{color}
</div>
);
const App: React.FC = () => (
<Space wrap size={['large', 'middle']}>
{colors.map((color) => (
<Badge color={color} count={44} key={color}>
<div
style={{
width: 90,
height: 90,
lineHeight: '90px',
background: '#ccc',
textAlign: 'center',
}}
>
{color}
</div>
</Badge>
))}
</Space>
<>
<Space wrap size={['large', 'middle']}>
{colors.map((color) => (
<Badge color={color} count={44} key={color}>
<AvatarItem color={color} />
</Badge>
))}
</Space>
<Space wrap size={['large', 'middle']}>
{colors.map((color) => (
<Badge status="processing" color={color} text="loading" key={color} />
))}
</Space>
</>
);
export default App;

View File

@ -74,8 +74,11 @@ const genSharedBadgeStyle: GenerateStyle<BadgeToken> = (token: BadgeToken): CSSO
const ribbonWrapperPrefixCls = `${antCls}-ribbon-wrapper`;
const colorPreset = genPresetColor(token, (colorKey, { darkColor }) => ({
[`${componentCls}-color-${colorKey}`]: {
[`&${componentCls} ${componentCls}-color-${colorKey}`]: {
background: darkColor,
[`&:not(${componentCls}-count)`]: {
color: darkColor,
},
},
}));