-
Notifications
You must be signed in to change notification settings - Fork 13.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Upgrade Badge component to Ant Design 5 #29124
Changes from all commits
f76eca5
b6efda9
56d2037
200b6e6
8c3b160
26a4035
707c2bd
f8ebb73
4763e4a
29a78fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,25 +17,22 @@ | |
* under the License. | ||
*/ | ||
import { styled } from '@superset-ui/core'; | ||
import { Badge as AntdBadge } from 'antd'; | ||
import { BadgeProps as AntdBadgeProps } from 'antd/lib/badge'; | ||
import { Badge as AntdBadge } from 'antd-v5'; | ||
import { BadgeProps as AntdBadgeProps } from 'antd-v5/lib/badge'; | ||
|
||
export interface BadgeProps extends AntdBadgeProps { | ||
textColor?: string; | ||
} | ||
export type { AntdBadgeProps as BadgeProps }; | ||
|
||
const Badge = styled( | ||
( | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
{ textColor, color, text, ...props }: BadgeProps, | ||
) => <AntdBadge text={text} color={text ? color : undefined} {...props} />, | ||
)` | ||
& > sup { | ||
padding: 0 ${({ theme }) => theme.gridUnit * 2}px; | ||
background: ${({ theme, color }) => color || theme.colors.primary.base}; | ||
color: ${({ theme, textColor }) => | ||
textColor || theme.colors.grayscale.light5}; | ||
} | ||
const Badge = styled((props: AntdBadgeProps) => <AntdBadge {...props} />)` | ||
${({ theme, color, count }) => ` | ||
& > sup, | ||
& > sup.antd5-badge-count { | ||
${ | ||
count !== undefined | ||
? `background: ${color || theme.colors.primary.base};` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an example of a necessary customization for backward compatibility. Ant Design uses |
||
: '' | ||
} | ||
} | ||
`} | ||
`; | ||
|
||
export default Badge; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This property is custom. Since it is not used in the code, it does not make sense to maintain it. Additionally, one of the goals of the proposal is to minimize the introduction of custom properties to reduce maintenance costs.