Skip to content
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(Tag): Upgrade Tag and TagsList to Ant Design 5 #29593

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In #29545 I add the theme provider globally, so that we don't need to do it in every story :)

<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>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto here, we can remove this provider soon...

<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
Loading