Skip to content

Commit 5b47c1c

Browse files
committed
chore: remove progress-circle into separate PR
1 parent b52e52a commit 5b47c1c

File tree

5 files changed

+786
-692
lines changed

5 files changed

+786
-692
lines changed

second-gen/packages/core/components/progress-circle/ProgressCircle.base.ts

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@ export abstract class ProgressCircleBase extends SizedMixin(SpectrumElement, {
3434

3535
/**
3636
* Static color variant for use on different backgrounds.
37-
* When set to 'white', the component uses white styling for images with a dark tinted background.
38-
* When set to 'black', the component uses black styling for images with a light tinted background.
37+
* When set to 'white', the component uses white styling for dark backgrounds.
3938
*/
4039
@property({ reflect: true, attribute: 'static-color' })
41-
public staticColor?: 'white' | 'black';
40+
public staticColor?: 'white';
4241

4342
/**
4443
* Progress value from 0 to 100.
@@ -47,24 +46,6 @@ export abstract class ProgressCircleBase extends SizedMixin(SpectrumElement, {
4746
@property({ type: Number })
4847
public progress = 0;
4948

50-
/**
51-
* Stroke width for the progress circle.
52-
*/
53-
@property({ type: Number, reflect: false })
54-
public get strokeWidth(): number {
55-
return this._strokeWidth;
56-
}
57-
58-
public set strokeWidth(customWidth: unknown) {
59-
if (customWidth && customWidth instanceof Number) {
60-
this._strokeWidth = customWidth as number;
61-
}
62-
63-
this._strokeWidth = this.size === 's' ? 2 : this.size === 'l' ? 4 : 3;
64-
}
65-
66-
private _strokeWidth: number = 2;
67-
6849
@query('slot')
6950
private slotEl!: HTMLSlotElement;
7051

second-gen/packages/swc/components/progress-circle/ProgressCircle.ts

Lines changed: 29 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,12 @@
1111
*/
1212

1313
import { CSSResultArray, html, TemplateResult } from 'lit';
14-
import { classMap } from 'lit/directives/class-map.js';
14+
import { ifDefined } from 'lit/directives/if-defined.js';
1515

1616
import { ProgressCircleBase } from '@swc/core/components/progress-circle';
1717

1818
import progressCircleStyles from './progress-circle.css';
1919

20-
function capitalize(str?: string): string {
21-
if (typeof str !== 'string') {
22-
return '';
23-
}
24-
return str.charAt(0).toUpperCase() + str.slice(1);
25-
}
2620
/**
2721
* A progress circle component that visually represents the completion progress of a task.
2822
* Can be used in both determinate (with specific progress value) and indeterminate (loading) states.
@@ -31,7 +25,12 @@ function capitalize(str?: string): string {
3125
* @since 2.0.0
3226
* @status stable
3327
* @github https://github.com/adobe/spectrum-web-components/tree/main/second-gen/packages/swc/components/progress-circle
34-
* @figma https://www.figma.com/design/Mngz9H7WZLbrCvGQf3GnsY/S2-%2F-Desktop?node-id=13061-181
28+
* @figma https://spectrum.figma.com/file/progress-circle
29+
*
30+
* @slot - Optional content to display inside the progress circle (e.g., percentage text)
31+
*
32+
* @csspart track - The background track of the progress circle
33+
* @csspart fill - The filled portion of the progress circle
3534
*
3635
* @fires progress-change - Dispatched when the progress value changes
3736
*
@@ -47,51 +46,29 @@ export class ProgressCircle extends ProgressCircleBase {
4746
}
4847

4948
protected override render(): TemplateResult {
50-
// SVG strokes are centered, so subtract half the stroke width from the radius to create an inner stroke.
51-
const radius = `calc(50% - ${this.strokeWidth / 2}px)`;
52-
49+
const styles = [
50+
this.makeRotation(-180 + (180 / 50) * Math.min(this.progress, 50)),
51+
this.makeRotation(
52+
-180 + (180 / 50) * Math.max(this.progress - 50, 0)
53+
),
54+
];
55+
const masks = ['Mask1', 'Mask2'];
5356
return html`
54-
<div
55-
class=${classMap({
56-
['spectrum-ProgressCircle']: true,
57-
[`spectrum-ProgressCircle--indeterminate`]:
58-
this.indeterminate,
59-
[`spectrum-ProgressCircle--static${capitalize(this.staticColor)}`]:
60-
typeof this.staticColor !== 'undefined',
61-
[`spectrum-ProgressCircle--size${this.size?.toUpperCase()}`]:
62-
typeof this.size !== 'undefined',
63-
})}
64-
>
65-
<svg
66-
fill="none"
67-
width="100%"
68-
height="100%"
69-
class="spectrum-outerCircle"
70-
>
71-
<circle
72-
class="spectrum-innerCircle"
73-
cx="50%"
74-
cy="50%"
75-
r=${`calc(50% - ${this.strokeWidth / 1}px)`}
76-
stroke-width=${this.strokeWidth}
77-
/>
78-
<circle
79-
cx="50%"
80-
cy="50%"
81-
class="spectrum-ProgressCircle-track"
82-
r=${radius}
83-
/>
84-
<circle
85-
cx="50%"
86-
cy="50%"
87-
r=${radius}
88-
class="spectrum-ProgressCircle-fill"
89-
pathLength="100"
90-
stroke-dasharray="100 200"
91-
stroke-dashoffset=${100 - this.progress}
92-
stroke-linecap="round"
93-
/>
94-
</svg>
57+
<slot @slotchange=${this.handleSlotchange}></slot>
58+
<div class="track"></div>
59+
<div class="fills">
60+
${masks.map(
61+
(mask, index) => html`
62+
<div class="fill${mask}">
63+
<div
64+
class="fillSub${mask}"
65+
style=${ifDefined(styles[index])}
66+
>
67+
<div class="fill"></div>
68+
</div>
69+
</div>
70+
`
71+
)}
9572
</div>
9673
`;
9774
}

0 commit comments

Comments
 (0)