diff --git a/superset-frontend/cypress-base/cypress/e2e/dashboard/nativeFilters.test.ts b/superset-frontend/cypress-base/cypress/e2e/dashboard/nativeFilters.test.ts
index 4e0309a2d..f2e88b139 100644
--- a/superset-frontend/cypress-base/cypress/e2e/dashboard/nativeFilters.test.ts
+++ b/superset-frontend/cypress-base/cypress/e2e/dashboard/nativeFilters.test.ts
@@ -355,7 +355,7 @@ describe('Horizontal FilterBar', () => {
applyNativeFilterValueWithIndex(8, testItems.filterDefaultValue);
cy.get(nativeFilters.applyFilter).click({ force: true });
cy.wait('@chart');
- cy.get('.ant-scroll-number.ant-badge-count').should(
+ cy.get('.antd5-scroll-number.antd5-badge-count').should(
'have.attr',
'title',
'1',
diff --git a/superset-frontend/cypress-base/cypress/support/directories.ts b/superset-frontend/cypress-base/cypress/support/directories.ts
index 8dcf739d1..77268a5e0 100644
--- a/superset-frontend/cypress-base/cypress/support/directories.ts
+++ b/superset-frontend/cypress-base/cypress/support/directories.ts
@@ -48,7 +48,7 @@ export const profile = {
favoritesSpace: '#rc-tabs-0-panel-2',
};
export const securityAccess = {
- rolesBubble: '.ant-badge-count',
+ rolesBubble: '.antd5-badge-count',
};
export const homePage = {
homeSection: {
diff --git a/superset-frontend/src/components/Badge/Badge.stories.tsx b/superset-frontend/src/components/Badge/Badge.stories.tsx
index 6027ef0b8..781f6220c 100644
--- a/superset-frontend/src/components/Badge/Badge.stories.tsx
+++ b/superset-frontend/src/components/Badge/Badge.stories.tsx
@@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+import { AntdThemeProvider } from 'src/components/AntdThemeProvider';
import Badge, { BadgeProps } from '.';
export default {
@@ -58,15 +59,20 @@ const SIZES = {
defaultValue: undefined,
};
-export const InteractiveBadge = (args: BadgeProps) => ;
+export const InteractiveBadge = (args: BadgeProps) => (
+
+
+
+);
InteractiveBadge.args = {
- count: null,
- color: null,
+ count: undefined,
+ color: undefined,
text: 'Text',
- textColor: null,
status: 'success',
size: 'default',
+ showZero: false,
+ overflowCount: 99,
};
InteractiveBadge.argTypes = {
@@ -75,6 +81,8 @@ InteractiveBadge.argTypes = {
type: 'select',
},
options: [undefined, ...STATUSES],
+ description:
+ 'only works if `count` is `undefined` (or is set to 0) and `color` is set to `undefined`',
},
size: {
control: {
@@ -88,17 +96,22 @@ InteractiveBadge.argTypes = {
},
options: [undefined, ...COLORS.options],
},
- textColor: {
- control: {
- type: 'select',
- },
- options: [undefined, ...COLORS.options],
- },
count: {
control: {
type: 'select',
+ defaultValue: undefined,
},
options: [undefined, ...Array(100).keys()],
+ defaultValue: undefined,
+ },
+ showZero: {
+ control: 'boolean',
+ defaultValue: false,
+ },
+ overflowCount: {
+ control: 'number',
+ description:
+ 'The threshold at which the number overflows with a `+` e.g if you set this to 10, and the value is 11, you get `11+`',
},
};
@@ -107,33 +120,21 @@ export const BadgeGallery = () => (
{SIZES.options.map(size => (
{size}
- {COLORS.options.map(color => (
-
- ))}
+
+ {COLORS.options.map(color => (
+
+ ))}
+
))}
>
);
-export const BadgeTextGallery = () => (
- <>
- {COLORS.options.map(color => (
-
- ))}
- >
-);
-
BadgeGallery.parameters = {
actions: {
disable: true,
@@ -142,12 +143,3 @@ BadgeGallery.parameters = {
disable: true,
},
};
-
-BadgeTextGallery.parameters = {
- actions: {
- disable: true,
- },
- controls: {
- disable: true,
- },
-};
diff --git a/superset-frontend/src/components/Badge/Badge.test.tsx b/superset-frontend/src/components/Badge/Badge.test.tsx
index 084dceb34..cbf9bcf80 100644
--- a/superset-frontend/src/components/Badge/Badge.test.tsx
+++ b/superset-frontend/src/components/Badge/Badge.test.tsx
@@ -22,7 +22,6 @@ import Badge from '.';
const mockedProps = {
count: 9,
text: 'Text',
- textColor: 'orange',
};
test('should render', () => {
@@ -39,11 +38,3 @@ test('should render the text', () => {
render();
expect(screen.getByText('Text')).toBeInTheDocument();
});
-
-test('should render with the chosen textColor', () => {
- render();
- const badge = screen.getAllByText('9')[0];
- expect(badge).toHaveStyle(`
- color: 'orange';
- `);
-});
diff --git a/superset-frontend/src/components/Badge/index.tsx b/superset-frontend/src/components/Badge/index.tsx
index 723d6a6a6..463884e50 100644
--- a/superset-frontend/src/components/Badge/index.tsx
+++ b/superset-frontend/src/components/Badge/index.tsx
@@ -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,
- ) => ,
-)`
- & > 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) => )`
+ ${({ theme, color, count }) => `
+ & > sup,
+ & > sup.antd5-badge-count {
+ ${
+ count !== undefined
+ ? `background: ${color || theme.colors.primary.base};`
+ : ''
+ }
+ }
+ `}
`;
export default Badge;
diff --git a/superset-frontend/src/components/Datasource/DatasourceEditor.jsx b/superset-frontend/src/components/Datasource/DatasourceEditor.jsx
index 34ef5a1b0..e35106b24 100644
--- a/superset-frontend/src/components/Datasource/DatasourceEditor.jsx
+++ b/superset-frontend/src/components/Datasource/DatasourceEditor.jsx
@@ -94,7 +94,7 @@ const StyledTableTabs = styled(Tabs)`
`;
const StyledBadge = styled(Badge)`
- .ant-badge-count {
+ .antd5-badge-count {
line-height: ${({ theme }) => theme.gridUnit * 4}px;
height: ${({ theme }) => theme.gridUnit * 4}px;
margin-left: ${({ theme }) => theme.gridUnit}px;
diff --git a/superset-frontend/src/dashboard/components/FiltersBadge/index.tsx b/superset-frontend/src/dashboard/components/FiltersBadge/index.tsx
index dfea5cd50..485879e95 100644
--- a/superset-frontend/src/dashboard/components/FiltersBadge/index.tsx
+++ b/superset-frontend/src/dashboard/components/FiltersBadge/index.tsx
@@ -84,9 +84,8 @@ const StyledFilterCount = styled.div`
const StyledBadge = styled(Badge)`
${({ theme }) => `
- vertical-align: middle;
margin-left: ${theme.gridUnit * 2}px;
- &>sup {
+ &>sup.antd5-badge-count {
padding: 0 ${theme.gridUnit}px;
min-width: ${theme.gridUnit * 4}px;
height: ${theme.gridUnit * 4}px;
@@ -94,6 +93,7 @@ const StyledBadge = styled(Badge)`
font-weight: ${theme.typography.weights.medium};
font-size: ${theme.typography.sizes.s - 1}px;
box-shadow: none;
+ padding: 0 ${theme.gridUnit}px;
}
`}
`;