Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs/progress 修复首次进入时与设置的stroke-width的延迟显示和兼容性问题 #3133

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/image/README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ className | Description
-- | --
t-class | \-
t-class-load | \-
t-class-image | \-
t-class-error | \-

### CSS Variables

Expand Down
2 changes: 2 additions & 0 deletions src/image/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ load | - | 图片加载完成时触发
-- | --
t-class | 根节点样式类
t-class-load | 加载样式类
t-class-image | 图片样式类
t-class-error | 加载失败样式类

### CSS Variables

Expand Down
12 changes: 7 additions & 5 deletions src/image/image.less
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
@image-loading-color: var(--td-image-loading-color, @text-color-placeholder);
@image-round-radius: var(--td-image-round-radius, @radius-default);

:host {
.@{prefix}-image {
position: relative;
}
display: inline-block;

.@{prefix}-image {
color: @image-color;
vertical-align: top;
&__img {
color: @image-color;
vertical-align: top;
}

&__mask {
display: flex;
Expand All @@ -34,6 +35,7 @@
&--lazy {
position: absolute;
top: 0;
left: 0;
z-index: -1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/image/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { prefix } = config;
const name = `${prefix}-image`;
@wxComponent()
export default class Image extends SuperComponent {
externalClasses = [`${prefix}-class`, `${prefix}-class-load`];
externalClasses = [`${prefix}-class`, `${prefix}-class-load`, `${prefix}-class-image`, `${prefix}-class-error`];

options = {
multipleSlots: true,
Expand Down
98 changes: 51 additions & 47 deletions src/image/image.wxml
Original file line number Diff line number Diff line change
@@ -1,52 +1,56 @@
<wxs src="../common/utils.wxs" module="_" />

<!-- 加载中占位 -->
<view
wx:if="{{isLoading}}"
style="{{_._style([innerStyle, style, customStyle])}}"
class="class {{prefix}}-class {{classPrefix}} {{classPrefix}}__mask {{classPrefix}}--loading {{classPrefix}}--shape-{{shape}}"
aria-hidden="{{ariaHidden}}"
>
<t-loading
wx:if="{{loading === 'default'}}"
theme="dots"
size="44rpx"
loading
inherit-color
t-class="t-class-load"
t-class-text="{{classPrefix}}--loading-text"
></t-loading>
<view wx:elif="{{loading !== '' && loading !== 'slot'}}" class="{{classPrefix}}__common {{prefix}}-class-load">
{{loading}}
<view class="class {{prefix}}-class {{classPrefix}}">
anlyyao marked this conversation as resolved.
Show resolved Hide resolved
<!-- 加载中占位 -->
<view
wx:if="{{isLoading}}"
style="{{_._style([innerStyle, style, customStyle])}}"
class="{{classPrefix}}__img {{classPrefix}}__mask {{classPrefix}}--loading {{classPrefix}}--shape-{{shape}}"
aria-hidden="{{ariaHidden}}"
>
<t-loading
wx:if="{{loading === 'default'}}"
theme="dots"
size="44rpx"
loading
inherit-color
t-class="t-class-load"
t-class-text="{{classPrefix}}--loading-text"
></t-loading>
<view wx:elif="{{loading !== '' && loading !== 'slot'}}" class="{{classPrefix}}__common {{prefix}}-class-load">
{{loading}}
</view>
<slot wx:else name="loading" />
</view>
<slot wx:else name="loading" />
</view>
<!-- 加载失败占位 -->
<view
wx:elif="{{isFailed}}"
style="{{_._style([innerStyle, style, customStyle])}}"
class="class {{prefix}}-class {{classPrefix}} {{classPrefix}}__mask {{classPrefix}}--failed {{classPrefix}}--shape-{{shape}}"
aria-hidden="{{ariaHidden}}"
>
<view wx:if="{{error === 'default'}}" style="font-size: 44rpx" class="{{prefix}}-class-load">
<t-icon name="close" aria-role="img" aria-label="加载失败" />
<!-- 加载失败占位 -->
<view
wx:elif="{{isFailed}}"
style="{{_._style([innerStyle, style, customStyle])}}"
class="{{classPrefix}}__img {{prefix}}-class-error {{classPrefix}}__mask {{classPrefix}}--failed {{classPrefix}}--shape-{{shape}}"
aria-hidden="{{ariaHidden}}"
>
<view wx:if="{{error === 'default'}}" style="font-size: 44rpx" class="{{prefix}}-class-load">
<t-icon name="close" aria-role="img" aria-label="加载失败" />
</view>
<view wx:elif="{{error && error !== 'slot'}}" class="{{classPrefix}}__common {{prefix}}-class-load">
{{error}}
</view>
<slot wx:else name="error" />
</view>
<view wx:elif="{{error && error !== 'slot'}}" class="{{classPrefix}}__common {{prefix}}-class-load"> {{error}} </view>
<slot wx:else name="error" />
<!-- 图片 -->
<image
id="{{tId||'image'}}"
wx:if="{{ !isFailed }}"
class="{{classPrefix}}__img {{classPrefix}}--shape-{{shape}} {{isLoading ? classPrefix + '--lazy' : ''}}"
src="{{src}}"
style="{{_._style([innerStyle, style, customStyle])}}"
mode="{{mode}}"
webp="{{webp}}"
lazy-load="{{lazy}}"
bind:load="onLoaded"
bind:error="onLoadError"
show-menu-by-longpress="{{showMenuByLongpress}}"
aria-hidden="{{ariaHidden || isLoading || isFailed}}"
aria-label="{{ariaLabel}}"
/>
</view>
<!-- 图片 -->
<image
id="{{tId||'image'}}"
wx:if="{{ !isFailed }}"
class="class {{prefix}}-class {{classPrefix}} {{classPrefix}}--shape-{{shape}} {{isLoading ? classPrefix + '--lazy' : ''}}"
src="{{src}}"
style="{{_._style([innerStyle, style, customStyle])}}"
mode="{{mode}}"
webp="{{webp}}"
lazy-load="{{lazy}}"
bind:load="onLoaded"
bind:error="onLoadError"
show-menu-by-longpress="{{showMenuByLongpress}}"
aria-hidden="{{ariaHidden || isLoading || isFailed}}"
aria-label="{{ariaLabel}}"
/>
18 changes: 0 additions & 18 deletions src/progress/progress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import config from '../common/config';
import props from './props';
import { getBackgroundColor } from './utils';
import { unitConvert, getRect } from '../common/utils';

Check failure on line 5 in src/progress/progress.ts

View workflow job for this annotation

GitHub Actions / lint

'getRect' is defined but never used

const { prefix } = config;
const name = `${prefix}-progress`;
Expand Down Expand Up @@ -67,11 +67,6 @@
});
},

theme(theme) {
if (theme === 'circle') {
this.getInnerDiameter();
}
},

trackColor(trackColor) {
this.setData({
Expand All @@ -80,17 +75,4 @@
},
};

methods = {
getInnerDiameter() {
const { strokeWidth } = this.properties;
const wrapID = `.${name}__canvas--circle`;
if (strokeWidth) {
getRect(this, wrapID).then((wrapRect) => {
this.setData({
innerDiameter: wrapRect.width - unitConvert(strokeWidth) * 2,
});
});
}
},
};
}
2 changes: 1 addition & 1 deletion src/progress/progress.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
>
<view
class="{{classPrefix}}__canvas--inner {{prefix}}-class-bar"
style="{{innerDiameter? 'width:'+ innerDiameter*2 + 'rpx;' + 'height:'+ innerDiameter*2 + 'rpx;': ''}}"
style="{{heightBar? '--td-progress-stroke-circle-width:' + heightBar + 'px' : ''}}"
>
<view wx:if="{{label}}" class="{{classPrefix}}__info {{prefix}}-class-label" aria-hidden="{{ true }}">
<template
Expand Down
Loading