diff --git a/package/component/src/component/progress/index.less b/package/component/src/component/progress/index.less index 682567ae..cefc7fb6 100644 --- a/package/component/src/component/progress/index.less +++ b/package/component/src/component/progress/index.less @@ -43,17 +43,10 @@ display: inline-block; } -.lay-progress-circle, -.lay-progress-circle-bg { - width: 150px; - height: 150px; +.lay-progress-circle{ position: relative; border-radius: 50%; - -webkit-mask: radial-gradient(transparent 69px, #000 45px); -} - -.lay-progress-circle-bg { - background-color: var(--global-neutral-color-3); + display: inline-block; } .lay-progress-circle__text { @@ -63,11 +56,3 @@ transform: translate(-50%, -50%); } -.lay-progress-circle-corner { - position: absolute; - width: 6px; - height: 6px; - border-radius: 50%; - top: 72px; - left: 72px; -} diff --git a/package/component/src/component/progress/index.vue b/package/component/src/component/progress/index.vue index 45c379ec..5ca075a6 100644 --- a/package/component/src/component/progress/index.vue +++ b/package/component/src/component/progress/index.vue @@ -16,9 +16,15 @@ export interface LayProgressProps { showText?: boolean; text?: string; circle?: boolean; + circleSize?: number; + circleWidth?: number; } -const props = defineProps(); +const props = withDefaults(defineProps(), { + circle: false, + circleSize: 150, + circleWidth: 6, +}); const styles = computed(() => { return [ @@ -70,44 +76,59 @@ const getCircleRotate = computed(() => { } return (percent / 100) * 360; }); + +const getStrokeDasharray = computed(() => { + let percent; + if (typeof props.percent == "string") { + percent = parseInt(props.percent); + } else { + percent = props.percent; + } + let radii = props.circleSize / 2 - props.circleWidth / 2; + let perimeter = Math.PI * 2 * radii; + return `${(percent / 100) * perimeter}px ${perimeter}px`; +}); + +const getPathD = computed(() => { + let circleSize = props.circleSize; + let circleWidth = props.circleWidth; + return `M ${circleSize / 2} ${circleSize / 2} m 0, -${ + (circleSize - circleWidth) / 2 + } a ${(circleSize - circleWidth) / 2}, ${ + (circleSize - circleWidth) / 2 + } 0 1, 1 0, ${circleSize - circleWidth} a ${ + (circleSize - circleWidth) / 2 + }, ${(circleSize - circleWidth) / 2} 0 1, 1 0, -${circleSize - circleWidth}`; +});