Skip to content

Commit

Permalink
feat(Skeleton): support delay props (#2698)
Browse files Browse the repository at this point in the history
  • Loading branch information
anlyyao authored Apr 16, 2024
1 parent 92ec2e3 commit 1e8a6ac
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/skeleton/__test__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('skeleton', () => {
describe('Props', () => {
it(`: style && customStyle`, async () => {
const id = simulate.load({
template: `<t-skeleton class="skeleton" style="{{style}}" customStyle="{{customStyle}}"></t-skeleton>`,
template: `<t-skeleton class="skeleton" style="{{style}}" customStyle="{{customStyle}}" loading="{{true}}"></t-skeleton>`,
usingComponents: {
't-skeleton': skeleton,
},
Expand Down
13 changes: 13 additions & 0 deletions src/skeleton/skeleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ export default class Skeleton extends SuperComponent {
rowCol() {
this.init();
},
'loading,delay'(loading: boolean, delay: number) {
if (!loading || delay === 0) {
this.setData({
isShow: loading,
});
return;
}
setTimeout(() => {
this.setData({
isShow: loading,
});
}, delay);
},
};

lifetimes = {
Expand Down
2 changes: 1 addition & 1 deletion src/skeleton/skeleton.wxml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<wxs src="../common/utils.wxs" module="_" />

<view wx:if="{{ loading }}" style="{{_._style([style, customStyle])}}" class="{{classPrefix}} class {{prefix}}-class ">
<view wx:if="{{ isShow }}" style="{{_._style([style, customStyle])}}" class="{{classPrefix}} class {{prefix}}-class ">
<view wx:if="{{ parsedRowcols.length }}" class="{{classPrefix}}__content">
<view
wx:for="{{parsedRowcols}}"
Expand Down

0 comments on commit 1e8a6ac

Please sign in to comment.