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

feat(loading): support inherit color #404

Merged
merged 1 commit into from
Apr 27, 2022
Merged
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
30 changes: 15 additions & 15 deletions src/loading/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,20 @@ Page({
```

## API

### Loading Props

| 名称 | 类型 | 默认值 | 说明 | 必传 |
| ---------------- | ------------- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | ---- |
| delay | Number | 0 | 延迟显示加载效果的时间,用于防止请求速度过快引起的加载闪烁,单位:毫秒 | N |
| duration | Number | 800 | 加载动画执行完成一次的时间,单位:毫秒 | N |
| external-classes | Array | - | 组件类名,分别用于设置加载组件外层元素,加载组件文本,加载组件指示符,加载指示符内侧同心圆等元素类名。`['t-class', 't-class-text', 't-class-indicator']` | N |
| indicator | Boolean | true | 是否显示加载指示符 | N |
| layout | String | horizontal | 对齐方式。可选项:horizontal/vertical | N |
| loading | Boolean | true | 是否处于加载状态 | N |
| pause | Boolean | false | 是否暂停动画 | N |
| progress | Number | - | 加载进度 | N |
| reverse | Boolean | - | 加载动画是否反向 | N |
| size | String | '40rpx' | 尺寸,示例:40rpx/20px | N |
| text | String / Slot | - | 加载提示文案 | N |
| theme | String | circular | 加载组件类型。可选项:circular/spinner/bar/error/dots | N |
名称 | 类型 | 默认值 | 说明 | 必传
-- | -- | -- | -- | --
delay | Number | 0 | 延迟显示加载效果的时间,用于防止请求速度过快引起的加载闪烁,单位:毫秒 | N
duration | Number | 800 | 加载动画执行完成一次的时间,单位:毫秒 | N
external-classes | Array | - | 组件类名,分别用于设置加载组件外层元素,加载组件文本,加载组件指示符,加载指示符内侧同心圆等元素类名。`['t-class', 't-class-text', 't-class-indicator']` | N
indicator | Boolean | true | 是否显示加载指示符 | N
inherit-color | Boolean | false | 是否继承父元素颜色 | N
layout | String | horizontal | 对齐方式。可选项:horizontal/vertical | N
loading | Boolean | true | 是否处于加载状态 | N
pause | Boolean | false | 是否暂停动画 | N
progress | Number | - | 加载进度 | N
reverse | Boolean | - | 加载动画是否反向 | N
size | String | '40rpx' | 尺寸,示例:40rpx/20px | N
text | String / Slot | - | 加载提示文案 | N
theme | String | circular | 加载组件类型。可选项:circular/spinner/bar/error/dots | N
4 changes: 3 additions & 1 deletion src/loading/loading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export default class Loading extends SuperComponent {
multipleSlots: true,
};

properties = props;
properties = {
...props,
};

timer = null;

Expand Down
8 changes: 2 additions & 6 deletions src/loading/loading.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@
style="{{progress >= 0 ? 'width:' + progress + '%' : ''}}"
class="{{prefix}}-class-indicator {{classPrefix}}__bar {{classPrefix}}__bar--{{progress < 0 ? 'animation' : progress < 100 ? 'static': ''}} {{progress >= 100 || !loading ? classPrefix + '__bar--loaded' : ''}}"
></view>
<view
class="{{classPrefix}} {{classPrefix + '--' + layout}}"
style="{{show ? '' : 'display:none'}}"
wx:else
>
<view class="{{classPrefix}} {{classPrefix + '--' + layout}}" style="{{show ? '' : 'display:none'}}" wx:else>
<view
wx:if="{{ theme !== 'error' }}"
class="{{prefix}}-class-indicator {{classPrefix}}__spinner {{classPrefix}}__spinner--{{ theme }} {{reverse ? 'reverse' : ''}}"
style="width: {{ utils.addUnit(size) }}; height: {{ utils.addUnit(size) }}; {{indicator ? '' : 'display:none'}}; {{duration ? 'animation-duration: ' + duration / 1000 + 's;' : ''}} animation-play-state: {{pause ? 'paused' : 'running'}};"
style="width: {{ utils.addUnit(size) }}; height: {{ utils.addUnit(size) }}; {{inheritColor ? 'color: inherit' : ''}} {{indicator ? '' : 'display:none'}}; {{duration ? 'animation-duration: ' + duration / 1000 + 's;' : ''}} animation-play-state: {{pause ? 'paused' : 'running'}};"
>
<view
wx:if="{{ theme === 'spinner' }}"
Expand Down
6 changes: 5 additions & 1 deletion src/loading/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

/**
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* updated at 2021-11-24 10:58:05
* */

import { TdLoadingProps } from './type';
Expand All @@ -26,6 +25,11 @@ const props: TdLoadingProps = {
type: Boolean,
value: true,
},
/** 是否继承父元素颜色 */
inheritColor: {
type: Boolean,
value: false,
},
/** 对齐方式 */
layout: {
type: String,
Expand Down
23 changes: 9 additions & 14 deletions src/loading/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

/**
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* updated at 2021-11-24 10:58:05
* */

export interface TdLoadingProps {
Expand All @@ -13,7 +12,6 @@ export interface TdLoadingProps {
delay?: {
type: NumberConstructor;
value?: number;
required?: boolean;
};
/**
* 加载动画执行完成一次的时间,单位:毫秒
Expand All @@ -22,15 +20,13 @@ export interface TdLoadingProps {
duration?: {
type: NumberConstructor;
value?: number;
required?: boolean;
};
/**
* 组件类名,分别用于设置加载组件外层元素,加载组件文本,加载组件指示符,加载指示符内侧同心圆等元素类名
*/
externalClasses?: {
type: ArrayConstructor;
value?: ['t-class', 't-class-text', 't-class-indicator'];
required?: boolean;
};
/**
* 是否显示加载指示符
Expand All @@ -39,7 +35,14 @@ export interface TdLoadingProps {
indicator?: {
type: BooleanConstructor;
value?: boolean;
required?: boolean;
};
/**
* 是否继承父元素颜色
* @default false
*/
inheritColor?: {
type: BooleanConstructor;
value?: boolean;
};
/**
* 对齐方式
Expand All @@ -48,7 +51,6 @@ export interface TdLoadingProps {
layout?: {
type: StringConstructor;
value?: 'horizontal' | 'vertical';
required?: boolean;
};
/**
* 是否处于加载状态
Expand All @@ -57,7 +59,6 @@ export interface TdLoadingProps {
loading?: {
type: BooleanConstructor;
value?: boolean;
required?: boolean;
};
/**
* 是否暂停动画
Expand All @@ -66,23 +67,20 @@ export interface TdLoadingProps {
pause?: {
type: BooleanConstructor;
value?: boolean;
required?: boolean;
};
/**
* 加载进度
*/
progress?: {
type: NumberConstructor;
value?: number;
required?: boolean;
};
/**
* 加载动画是否反向
*/
reverse?: {
type: BooleanConstructor;
value?: boolean;
required?: boolean;
};
/**
* 尺寸,示例:40rpx/20px
Expand All @@ -91,15 +89,13 @@ export interface TdLoadingProps {
size?: {
type: StringConstructor;
value?: string;
required?: boolean;
};
/**
* 加载提示文案
*/
text?: {
type: StringConstructor;
value?: string;
required?: boolean;
};
/**
* 加载组件类型
Expand All @@ -108,6 +104,5 @@ export interface TdLoadingProps {
theme?: {
type: StringConstructor;
value?: 'circular' | 'spinner' | 'bar' | 'error' | 'dots';
required?: boolean;
};
};
}