Skip to content

Commit

Permalink
refactor(Tag): Upgrade Tag and TagsList to Ant Design 5 (#29593)
Browse files Browse the repository at this point in the history
  • Loading branch information
geido authored Jul 17, 2024
1 parent ae6e58f commit c0d46eb
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 5 deletions.
36 changes: 36 additions & 0 deletions superset-frontend/src/components/Tags/Tag.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { AntdThemeProvider } from 'src/components/AntdThemeProvider';
import TagType from 'src/types/TagType';
import { Tag } from '.';

export default {
title: 'Tags',
component: Tag,
};
export const InteractiveTag = (args: TagType) => (
<AntdThemeProvider>
<Tag {...args} />
</AntdThemeProvider>
);

InteractiveTag.args = {
editable: false,
name: 'Tag',
};
3 changes: 1 addition & 2 deletions superset-frontend/src/components/Tags/Tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import { styled } from '@superset-ui/core';
import TagType from 'src/types/TagType';
import AntdTag from 'antd/lib/tag';
import { Tag as AntdTag } from 'antd-v5';
import { useMemo } from 'react';
import { Tooltip } from 'src/components/Tooltip';
import { CloseOutlined } from '@ant-design/icons';
Expand All @@ -28,7 +28,6 @@ const StyledTag = styled(AntdTag)`
${({ theme }) => `
margin-top: ${theme.gridUnit}px;
margin-bottom: ${theme.gridUnit}px;
font-size: ${theme.typography.sizes.s}px;
`};
`;

Expand Down
13 changes: 10 additions & 3 deletions superset-frontend/src/components/Tags/TagsList.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/
import TagType from 'src/types/TagType';
import { AntdThemeProvider } from 'src/components/AntdThemeProvider';
import { TagsList } from '.';
import { TagsListProps } from './TagsList';

Expand All @@ -25,8 +26,14 @@ export default {
component: TagsList,
};

export const InteractiveTags = ({ tags, editable, maxTags }: TagsListProps) => (
<TagsList tags={tags} editable={editable} maxTags={maxTags} />
export const InteractiveTagsList = ({
tags,
editable,
maxTags,
}: TagsListProps) => (
<AntdThemeProvider>
<TagsList tags={tags} editable={editable} maxTags={maxTags} />
</AntdThemeProvider>
);

const tags: TagType[] = [
Expand All @@ -42,7 +49,7 @@ const editable = true;

const maxTags = 3;

InteractiveTags.args = {
InteractiveTagsList.args = {
tags,
editable,
maxTags,
Expand Down
4 changes: 4 additions & 0 deletions superset-frontend/src/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ const baseConfig: ThemeConfig = {
paddingLG: supersetTheme.gridUnit * 6,
fontWeightStrong: supersetTheme.typography.weights.medium,
},
Tag: {
borderRadiusSM: supersetTheme.gridUnit / 2,
defaultBg: supersetTheme.colors.grayscale.light4,
},
},
};

Expand Down

0 comments on commit c0d46eb

Please sign in to comment.