refactor(ProgressBar): Upgrade ProgressBar to Antd 5 (#29666)

This commit is contained in:
Geido 2024-07-23 18:59:41 +03:00 committed by GitHub
parent cd713a239e
commit 3de2b7c989
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 51 additions and 22 deletions

View File

@ -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 {
@ -24,32 +25,39 @@ export default {
};
export const InteractiveProgressBar = (args: ProgressBarProps) => (
<ProgressBar {...args} />
<AntdThemeProvider>
<ProgressBar {...args} type="line" />
</AntdThemeProvider>
);
InteractiveProgressBar.args = {
export const InteractiveProgressCircle = (args: ProgressBarProps) => (
<AntdThemeProvider>
<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: {
control: {
type: 'select',
},
options: ['normal', 'success', 'exception', 'active'],
},
const commonArgTypes = {
strokeLinecap: {
control: {
type: 'select',
},
options: ['round', 'square'],
options: ['round', 'butt', 'square'],
},
type: {
control: {
@ -58,3 +66,26 @@ InteractiveProgressBar.argTypes = {
options: ['line', 'circle', 'dashboard'],
},
};
InteractiveProgressBar.args = {
...commonArgs,
status: 'normal',
};
InteractiveProgressBar.argTypes = {
...commonArgTypes,
status: {
control: {
type: 'select',
},
options: ['normal', 'success', 'exception', 'active'],
},
};
InteractiveProgressCircle.args = commonArgs;
InteractiveProgressCircle.argTypes = commonArgTypes;
InteractiveProgressDashboard.args = commonArgs;
InteractiveProgressDashboard.argTypes = commonArgTypes;

View File

@ -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;
@ -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 &&

View File

@ -64,6 +64,11 @@ const baseConfig: ThemeConfig = {
borderRadiusSM: supersetTheme.gridUnit / 2,
defaultBg: supersetTheme.colors.grayscale.light4,
},
Progress: {
fontSize: supersetTheme.typography.sizes.s,
colorText: supersetTheme.colors.text.label,
remainingColor: supersetTheme.colors.grayscale.light4,
},
},
};