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(ProgressBar): Upgrade ProgressBar to Antd 5 #29666

Merged
merged 1 commit into from
Jul 23, 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
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { AntdThemeProvider } from 'src/components/AntdThemeProvider';
import ProgressBar, { ProgressBarProps } from '.';

export default {
Expand All @@ -24,37 +25,67 @@ export default {
};

export const InteractiveProgressBar = (args: ProgressBarProps) => (
<ProgressBar {...args} />
<AntdThemeProvider>
<ProgressBar {...args} type="line" />
</AntdThemeProvider>
);

InteractiveProgressBar.args = {
export const InteractiveProgressCircle = (args: ProgressBarProps) => (
<AntdThemeProvider>
geido marked this conversation as resolved.
Show resolved Hide resolved
<ProgressBar {...args} type="circle" />
</AntdThemeProvider>
);

export const InteractiveProgressDashboard = (args: ProgressBarProps) => (
<AntdThemeProvider>
<ProgressBar {...args} type="dashboard" />
</AntdThemeProvider>
);

const commonArgs = {
striped: true,
percent: 90,
showInfo: true,
status: 'normal',
strokeColor: '#FF0000',
trailColor: '#000',
strokeLinecap: 'round',
type: 'line',
};

InteractiveProgressBar.argTypes = {
status: {
const commonArgTypes = {
strokeLinecap: {
control: {
type: 'select',
},
options: ['normal', 'success', 'exception', 'active'],
options: ['round', 'butt', 'square'],
},
strokeLinecap: {
type: {
control: {
type: 'select',
},
options: ['round', 'square'],
options: ['line', 'circle', 'dashboard'],
},
type: {
};

InteractiveProgressBar.args = {
...commonArgs,
status: 'normal',
};

InteractiveProgressBar.argTypes = {
...commonArgTypes,
status: {
control: {
type: 'select',
},
options: ['line', 'circle', 'dashboard'],
options: ['normal', 'success', 'exception', 'active'],
},
};

InteractiveProgressCircle.args = commonArgs;

InteractiveProgressCircle.argTypes = commonArgTypes;

InteractiveProgressDashboard.args = commonArgs;

InteractiveProgressDashboard.argTypes = commonArgTypes;
15 changes: 4 additions & 11 deletions superset-frontend/src/components/ProgressBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* under the License.
*/
import { styled } from '@superset-ui/core';
import { Progress as AntdProgress } from 'antd';
import { ProgressProps } from 'antd/lib/progress/progress';
import { Progress as AntdProgress } from 'antd-v5';
import { ProgressProps } from 'antd-v5/lib/progress/progress';

export interface ProgressBarProps extends ProgressProps {
striped?: boolean;
Expand All @@ -28,18 +28,11 @@ export interface ProgressBarProps extends ProgressProps {
const ProgressBar = styled(({ striped, ...props }: ProgressBarProps) => (
<AntdProgress data-test="progress-bar" {...props} />
))`
line-height: 0;
position: static;
.ant-progress-inner {
.antd5-progress-inner {
position: static;
}
.ant-progress-outer {
${({ percent }) => !percent && `display: none;`}
}
.ant-progress-text {
font-size: ${({ theme }) => theme.typography.sizes.s}px;
}
.ant-progress-bg {
.antd5-progress-bg {
position: static;
${({ striped }) =>
striped &&
Expand Down
5 changes: 5 additions & 0 deletions superset-frontend/src/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ const baseConfig: ThemeConfig = {
borderRadiusSM: supersetTheme.gridUnit / 2,
defaultBg: supersetTheme.colors.grayscale.light4,
},
Progress: {
fontSize: supersetTheme.typography.sizes.s,
Copy link
Member

Choose a reason for hiding this comment

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

@geido Is it possible to specify these at the component?

Copy link
Member Author

Choose a reason for hiding this comment

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

This was a decision we made to keep the style centralized rather than scattered across. The component tokens are relevant to general theme, as the general theme might need to be tweaked if we realize that multiple components are using the same styles and thus should be promoted. We can reconsider this choice once the big part of the transition is done and the general theme should be stable.

colorText: supersetTheme.colors.text.label,
remainingColor: supersetTheme.colors.grayscale.light4,
},
},
};

Expand Down
Loading