Skip to content

Commit

Permalink
demo: update Progress demo (ant-design#48052)
Browse files Browse the repository at this point in the history
* demo: update Progress demo

* fix: fix

* fix: fix

* fix: fix

* fix: update snap
  • Loading branch information
li-jia-nan authored and CooperHash committed Apr 10, 2024
1 parent 82c282e commit c1927ed
Show file tree
Hide file tree
Showing 4 changed files with 209 additions and 53 deletions.
124 changes: 108 additions & 16 deletions components/progress/__tests__/__snapshots__/demo-extend.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -486,12 +486,108 @@ exports[`renders components/progress/demo/circle-mini.tsx extend context correct
exports[`renders components/progress/demo/circle-mini.tsx extend context correctly 2`] = `[]`;

exports[`renders components/progress/demo/circle-steps.tsx extend context correctly 1`] = `
<div
class="ant-space ant-space-horizontal ant-space-align-center ant-space-gap-row-small ant-space-gap-col-small"
style="flex-wrap: wrap;"
>
Array [
<h5
class="ant-typography"
>
Custom count:
</h5>,
<div
class="ant-slider ant-slider-horizontal"
>
<div
class="ant-slider-rail"
/>
<div
class="ant-slider-track"
style="left: 0%; width: 37.5%;"
/>
<div
class="ant-slider-step"
/>
<div
aria-disabled="false"
aria-orientation="horizontal"
aria-valuemax="10"
aria-valuemin="2"
aria-valuenow="5"
class="ant-slider-handle"
role="slider"
style="left: 37.5%; transform: translateX(-50%);"
tabindex="0"
/>
<div
class="ant-tooltip ant-zoom-big-fast-appear ant-zoom-big-fast-appear-prepare ant-zoom-big-fast ant-slider-tooltip ant-tooltip-placement-top"
style="--arrow-x: 0px; --arrow-y: 0px; left: -1000vw; top: -1000vh; box-sizing: border-box;"
>
<div
class="ant-tooltip-arrow"
style="position: absolute; bottom: 0px; left: 0px;"
/>
<div
class="ant-tooltip-content"
>
<div
class="ant-tooltip-inner"
role="tooltip"
>
5
</div>
</div>
</div>
</div>,
<h5
class="ant-typography"
>
Custom gap:
</h5>,
<div
class="ant-slider ant-slider-horizontal"
>
<div
class="ant-slider-rail"
/>
<div
class="ant-slider-track"
style="left: 0%; width: 20%;"
/>
<div
class="ant-slider-step"
/>
<div
aria-disabled="false"
aria-orientation="horizontal"
aria-valuemax="40"
aria-valuemin="0"
aria-valuenow="8"
class="ant-slider-handle"
role="slider"
style="left: 20%; transform: translateX(-50%);"
tabindex="0"
/>
<div
class="ant-tooltip ant-zoom-big-fast-appear ant-zoom-big-fast-appear-prepare ant-zoom-big-fast ant-slider-tooltip ant-tooltip-placement-top"
style="--arrow-x: 0px; --arrow-y: 0px; left: -1000vw; top: -1000vh; box-sizing: border-box;"
>
<div
class="ant-tooltip-arrow"
style="position: absolute; bottom: 0px; left: 0px;"
/>
<div
class="ant-tooltip-content"
>
<div
class="ant-tooltip-inner"
role="tooltip"
>
8
</div>
</div>
</div>
</div>,
<div
class="ant-space-item"
class="ant-flex ant-flex-wrap-wrap ant-flex-gap-middle"
style="margin-top: 16px;"
>
<div
aria-valuenow="50"
Expand Down Expand Up @@ -588,10 +684,6 @@ exports[`renders components/progress/demo/circle-steps.tsx extend context correc
</span>
</div>
</div>
</div>
<div
class="ant-space-item"
>
<div
aria-valuenow="100"
class="ant-progress ant-progress-status-success ant-progress-circle ant-progress-steps ant-progress-show-info ant-progress-default"
Expand All @@ -613,7 +705,7 @@ exports[`renders components/progress/demo/circle-steps.tsx extend context correc
opacity="1"
r="40"
stroke-width="20"
style="stroke-dasharray: 251.32741228718345px 251.32741228718345; stroke-dashoffset: 213.06192982974676; transform: rotate(-90deg); transform-origin: 50px 50px; transition: stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s, opacity .3s ease 0s; fill-opacity: 0; transition-duration: 0s, 0s;"
style="stroke-dasharray: 251.32741228718345px 251.32741228718345; stroke-dashoffset: 208.06192982974676; transform: rotate(-90deg); transform-origin: 50px 50px; transition: stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s, opacity .3s ease 0s; fill-opacity: 0; transition-duration: 0s, 0s;"
/>
<circle
class="ant-progress-circle-path"
Expand All @@ -622,7 +714,7 @@ exports[`renders components/progress/demo/circle-steps.tsx extend context correc
opacity="1"
r="40"
stroke-width="20"
style="stroke-dasharray: 251.32741228718345px 251.32741228718345; stroke-dashoffset: 213.06192982974676; transform: rotate(-18deg); transform-origin: 50px 50px; transition: stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s, opacity .3s ease 0s; fill-opacity: 0; transition-duration: 0s, 0s;"
style="stroke-dasharray: 251.32741228718345px 251.32741228718345; stroke-dashoffset: 208.06192982974676; transform: rotate(-18deg); transform-origin: 50px 50px; transition: stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s, opacity .3s ease 0s; fill-opacity: 0; transition-duration: 0s, 0s;"
/>
<circle
class="ant-progress-circle-path"
Expand All @@ -631,7 +723,7 @@ exports[`renders components/progress/demo/circle-steps.tsx extend context correc
opacity="1"
r="40"
stroke-width="20"
style="stroke-dasharray: 251.32741228718345px 251.32741228718345; stroke-dashoffset: 213.06192982974676; transform: rotate(54deg); transform-origin: 50px 50px; transition: stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s, opacity .3s ease 0s; fill-opacity: 0; transition-duration: 0s, 0s;"
style="stroke-dasharray: 251.32741228718345px 251.32741228718345; stroke-dashoffset: 208.06192982974676; transform: rotate(54deg); transform-origin: 50px 50px; transition: stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s, opacity .3s ease 0s; fill-opacity: 0; transition-duration: 0s, 0s;"
/>
<circle
class="ant-progress-circle-path"
Expand All @@ -640,7 +732,7 @@ exports[`renders components/progress/demo/circle-steps.tsx extend context correc
opacity="1"
r="40"
stroke-width="20"
style="stroke-dasharray: 251.32741228718345px 251.32741228718345; stroke-dashoffset: 213.06192982974676; transform: rotate(126deg); transform-origin: 50px 50px; transition: stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s, opacity .3s ease 0s; fill-opacity: 0; transition-duration: 0s, 0s;"
style="stroke-dasharray: 251.32741228718345px 251.32741228718345; stroke-dashoffset: 208.06192982974676; transform: rotate(126deg); transform-origin: 50px 50px; transition: stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s, opacity .3s ease 0s; fill-opacity: 0; transition-duration: 0s, 0s;"
/>
<circle
class="ant-progress-circle-path"
Expand All @@ -649,7 +741,7 @@ exports[`renders components/progress/demo/circle-steps.tsx extend context correc
opacity="1"
r="40"
stroke-width="20"
style="stroke-dasharray: 251.32741228718345px 251.32741228718345; stroke-dashoffset: 213.06192982974676; transform: rotate(198deg); transform-origin: 50px 50px; transition: stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s, opacity .3s ease 0s; fill-opacity: 0; transition-duration: 0s, 0s;"
style="stroke-dasharray: 251.32741228718345px 251.32741228718345; stroke-dashoffset: 208.06192982974676; transform: rotate(198deg); transform-origin: 50px 50px; transition: stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s, opacity .3s ease 0s; fill-opacity: 0; transition-duration: 0s, 0s;"
/>
</svg>
<span
Expand Down Expand Up @@ -677,8 +769,8 @@ exports[`renders components/progress/demo/circle-steps.tsx extend context correc
</span>
</div>
</div>
</div>
</div>
</div>,
]
`;

exports[`renders components/progress/demo/circle-steps.tsx extend context correctly 2`] = `[]`;
Expand Down
86 changes: 70 additions & 16 deletions components/progress/__tests__/__snapshots__/demo.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -456,12 +456,70 @@ exports[`renders components/progress/demo/circle-mini.tsx correctly 1`] = `
`;

exports[`renders components/progress/demo/circle-steps.tsx correctly 1`] = `
<div
class="ant-space ant-space-horizontal ant-space-align-center ant-space-gap-row-small ant-space-gap-col-small"
style="flex-wrap:wrap"
>
Array [
<h5
class="ant-typography"
>
Custom count:
</h5>,
<div
class="ant-slider ant-slider-horizontal"
>
<div
class="ant-slider-rail"
/>
<div
class="ant-slider-track"
style="left:0%;width:37.5%"
/>
<div
class="ant-slider-step"
/>
<div
aria-disabled="false"
aria-orientation="horizontal"
aria-valuemax="10"
aria-valuemin="2"
aria-valuenow="5"
class="ant-slider-handle"
role="slider"
style="left:37.5%;transform:translateX(-50%)"
tabindex="0"
/>
</div>,
<h5
class="ant-typography"
>
Custom gap:
</h5>,
<div
class="ant-slider ant-slider-horizontal"
>
<div
class="ant-slider-rail"
/>
<div
class="ant-slider-track"
style="left:0%;width:20%"
/>
<div
class="ant-slider-step"
/>
<div
aria-disabled="false"
aria-orientation="horizontal"
aria-valuemax="40"
aria-valuemin="0"
aria-valuenow="8"
class="ant-slider-handle"
role="slider"
style="left:20%;transform:translateX(-50%)"
tabindex="0"
/>
</div>,
<div
class="ant-space-item"
class="ant-flex ant-flex-wrap-wrap ant-flex-gap-middle"
style="margin-top:16px"
>
<div
aria-valuenow="50"
Expand Down Expand Up @@ -558,10 +616,6 @@ exports[`renders components/progress/demo/circle-steps.tsx correctly 1`] = `
</span>
</div>
</div>
</div>
<div
class="ant-space-item"
>
<div
aria-valuenow="100"
class="ant-progress ant-progress-status-success ant-progress-circle ant-progress-steps ant-progress-show-info ant-progress-default"
Expand All @@ -583,7 +637,7 @@ exports[`renders components/progress/demo/circle-steps.tsx correctly 1`] = `
opacity="1"
r="40"
stroke-width="20"
style="stroke-dasharray:251.32741228718345px 251.32741228718345;stroke-dashoffset:213.06192982974676;transform:rotate(-90deg);transform-origin:50px 50px;transition:stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s, opacity .3s ease 0s;fill-opacity:0"
style="stroke-dasharray:251.32741228718345px 251.32741228718345;stroke-dashoffset:208.06192982974676;transform:rotate(-90deg);transform-origin:50px 50px;transition:stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s, opacity .3s ease 0s;fill-opacity:0"
/>
<circle
class="ant-progress-circle-path"
Expand All @@ -592,7 +646,7 @@ exports[`renders components/progress/demo/circle-steps.tsx correctly 1`] = `
opacity="1"
r="40"
stroke-width="20"
style="stroke-dasharray:251.32741228718345px 251.32741228718345;stroke-dashoffset:213.06192982974676;transform:rotate(-18deg);transform-origin:50px 50px;transition:stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s, opacity .3s ease 0s;fill-opacity:0"
style="stroke-dasharray:251.32741228718345px 251.32741228718345;stroke-dashoffset:208.06192982974676;transform:rotate(-18deg);transform-origin:50px 50px;transition:stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s, opacity .3s ease 0s;fill-opacity:0"
/>
<circle
class="ant-progress-circle-path"
Expand All @@ -601,7 +655,7 @@ exports[`renders components/progress/demo/circle-steps.tsx correctly 1`] = `
opacity="1"
r="40"
stroke-width="20"
style="stroke-dasharray:251.32741228718345px 251.32741228718345;stroke-dashoffset:213.06192982974676;transform:rotate(54deg);transform-origin:50px 50px;transition:stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s, opacity .3s ease 0s;fill-opacity:0"
style="stroke-dasharray:251.32741228718345px 251.32741228718345;stroke-dashoffset:208.06192982974676;transform:rotate(54deg);transform-origin:50px 50px;transition:stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s, opacity .3s ease 0s;fill-opacity:0"
/>
<circle
class="ant-progress-circle-path"
Expand All @@ -610,7 +664,7 @@ exports[`renders components/progress/demo/circle-steps.tsx correctly 1`] = `
opacity="1"
r="40"
stroke-width="20"
style="stroke-dasharray:251.32741228718345px 251.32741228718345;stroke-dashoffset:213.06192982974676;transform:rotate(126deg);transform-origin:50px 50px;transition:stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s, opacity .3s ease 0s;fill-opacity:0"
style="stroke-dasharray:251.32741228718345px 251.32741228718345;stroke-dashoffset:208.06192982974676;transform:rotate(126deg);transform-origin:50px 50px;transition:stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s, opacity .3s ease 0s;fill-opacity:0"
/>
<circle
class="ant-progress-circle-path"
Expand All @@ -619,7 +673,7 @@ exports[`renders components/progress/demo/circle-steps.tsx correctly 1`] = `
opacity="1"
r="40"
stroke-width="20"
style="stroke-dasharray:251.32741228718345px 251.32741228718345;stroke-dashoffset:213.06192982974676;transform:rotate(198deg);transform-origin:50px 50px;transition:stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s, opacity .3s ease 0s;fill-opacity:0"
style="stroke-dasharray:251.32741228718345px 251.32741228718345;stroke-dashoffset:208.06192982974676;transform:rotate(198deg);transform-origin:50px 50px;transition:stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s, opacity .3s ease 0s;fill-opacity:0"
/>
</svg>
<span
Expand Down Expand Up @@ -647,8 +701,8 @@ exports[`renders components/progress/demo/circle-steps.tsx correctly 1`] = `
</span>
</div>
</div>
</div>
</div>
</div>,
]
`;

exports[`renders components/progress/demo/component-token.tsx correctly 1`] = `
Expand Down
4 changes: 2 additions & 2 deletions components/progress/demo/circle-steps.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## zh-CN

步骤进度圈,支持颜色分段展示。
步骤进度圈,支持颜色分段展示,默认间隔为 2px

## en-US

A circular progress bar that support steps.
A circular progress bar that support steps and color segments, default gap is 2px.
48 changes: 29 additions & 19 deletions components/progress/demo/circle-steps.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
import { Progress, Space } from 'antd';
import React from 'react';
import { Flex, Progress, Slider, Typography } from 'antd';

const App: React.FC = () => (
<Space wrap>
<Progress
type="dashboard"
steps={8}
percent={50}
trailColor="rgba(0, 0, 0, 0.06)"
strokeWidth={20}
/>
<Progress
type="circle"
percent={100}
steps={{ count: 5, gap: 12 }}
trailColor="rgba(0, 0, 0, 0.06)"
strokeWidth={20}
/>
</Space>
);
const App: React.FC = () => {
const [stepsCount, setStepsCount] = React.useState<number>(5);
const [stepsGap, setStepsGap] = React.useState<number>(7);
return (
<>
<Typography.Title level={5}>Custom count:</Typography.Title>
<Slider min={2} max={10} value={stepsCount} onChange={setStepsCount} />
<Typography.Title level={5}>Custom gap:</Typography.Title>
<Slider step={4} min={0} max={40} value={stepsGap} onChange={setStepsGap} />
<Flex wrap="wrap" gap="middle" style={{ marginTop: 16 }}>
<Progress
type="dashboard"
steps={8}
percent={50}
trailColor="rgba(0, 0, 0, 0.06)"
strokeWidth={20}
/>
<Progress
type="circle"
percent={100}
steps={{ count: stepsCount, gap: stepsGap }}
trailColor="rgba(0, 0, 0, 0.06)"
strokeWidth={20}
/>
</Flex>
</>
);
};

export default App;

0 comments on commit c1927ed

Please sign in to comment.