CircleProgress
環形進度指示器:渲染行內 SVG(viewBox 0 0 size size),由軌道圓(lh-circle-progress__track)與進度弧圓(lh-circle-progress__arc)組成,填充比例由 stroke-dasharray 驅動。全部幾何換算、鉗制、顏色歸一與文案格式化皆消費 @lh-ui/share/core/circle-progress 的純函式,各端語義完全一致。
modelValue鉗制到[0, 100](越界不報錯)。startAngle採用時鐘口徑:0= 12 點鐘方向,順時針為正。SVG 預設起筆點(3 點鐘)由 svg 元素的行內rotate(startAngle - 90deg)變換補償。clockwise預設true;false時在同一行內變換追加scaleX(-1),使進度弧從同一原點逆時針掃出。color接受單色或陣列;長度 ≥2 的陣列渲染defs > linearGradient(id 由React.useId()生成,實例間唯一),進度弧以stroke="url(#id)"引用。
基本用法
CircleProgress(預設/漸層/逆時針/起始角/自訂文案/無文案)
70%100%60%50%88 分
import { LhCircleProgress } from '@lh-ui/react'
export default function Demo() {
return (
<>
<LhCircleProgress modelValue={70} />
<LhCircleProgress modelValue={100} color="#E4007E" />
<LhCircleProgress modelValue={60} color={['#2B4C7C', '#E4007E']} size={80} />
<LhCircleProgress modelValue={50} clockwise={false} startAngle={90} />
<LhCircleProgress modelValue={88} format={(v) => `${v} 分`} />
<LhCircleProgress modelValue={40} showText={false} />
</>
)
}