iter(g85): 进度条补可访问名与语义色
This commit is contained in:
@@ -9,10 +9,13 @@ export function progress(props: ProgressProps = {}): HTMLElement {
|
||||
const track = h('div', { class: 'ua-progress-track' }, fill);
|
||||
const text = h('span', { class: 'ua-progress-text' });
|
||||
const withText = props.showText !== false && !!value; // 不确定态没有百分比可显示
|
||||
const label = props.label; // 可访问名:读屏念「上传进度 50%」而不是干巴巴的百分比
|
||||
const variant = props.variant ?? 'default'; // 语义色:default 之外都带类名,满格时仍以 variant 为准
|
||||
const cls = `ua-progress${variant === 'default' ? '' : ` ua-progress-${variant}`}`;
|
||||
|
||||
if (!value) {
|
||||
fill.classList.add('ua-indeterminate'); // 宽度与往复动画交给 CSS
|
||||
return h('div', { class: 'ua-progress', role: 'progressbar', 'aria-label': '进行中' }, track);
|
||||
return h('div', { class: cls, role: 'progressbar', 'aria-label': label ?? '进行中' }, track);
|
||||
}
|
||||
effect(() => {
|
||||
const v = clamp(value()); // 依赖收集:信号变化自动写回
|
||||
@@ -23,8 +26,9 @@ export function progress(props: ProgressProps = {}): HTMLElement {
|
||||
return h(
|
||||
'div',
|
||||
{
|
||||
class: 'ua-progress',
|
||||
class: cls,
|
||||
role: 'progressbar',
|
||||
'aria-label': label,
|
||||
'aria-valuemin': '0',
|
||||
'aria-valuemax': '100',
|
||||
'aria-valuenow': () => String(Math.round(clamp(value()))),
|
||||
|
||||
Reference in New Issue
Block a user