-
Notifications
You must be signed in to change notification settings - Fork 4k
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(module:skeleton):add skeleton component #1829
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1829 +/- ##
==========================================
+ Coverage 96% 96.01% +<.01%
==========================================
Files 477 479 +2
Lines 11618 11685 +67
Branches 1550 1561 +11
==========================================
+ Hits 11154 11219 +65
Misses 132 132
- Partials 332 334 +2
Continue to review full report at Codecov.
|
</span> | ||
</div> | ||
<div class="ant-skeleton-content"> | ||
<h3 *ngIf="!!nzTitle" class="ant-skeleton-title" [style.width]="toCSSUnit(_title.width)"></h3> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a good idea to access a private variable in template files. It may cause errors in --aot
compiling.
return {}; | ||
} | ||
|
||
toCSSUnit(value: number | string = ''): number | string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that this function would not return a number
.
|
||
- 网络较慢,需要长时间等待加载处理的情况下 | ||
- 图文信息内容较多的列表/卡片中 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add the other demo? See: https://deploy-preview-11226--ant-design.netlify.com/components/skeleton-cn/.
It would be good if we sync to ant design react.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx, I just sent a commit
@wenqi73 Thanks for you contribution. Hopefully we would commit these to master branch this weekend. |
9ecea6e
to
d43346e
Compare
39e6d3b
to
e535dd0
Compare
@wendzhue Please review again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your code is of good quality with minor changes requested. We would merge this after Ant Design officially releases this component and make some changes accordingly.
} | ||
|
||
updateProps(): void { | ||
this.title = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you're trying to cover default props with user's customized props. But these ...
operators seems verbose to me. Could you figure out a simpler and direct way to prepare these parameters?
@Input() nzAvatar: NzSkeletonAvatar | boolean = false; | ||
@Input() nzParagraph: NzSkeletonParagraph | boolean = true; | ||
|
||
getTitleBasicProps(hasAvatar: boolean, hasParagraph: boolean): NzSkeletonTitle { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to expose these get*
methods as public
.
There are some other methods should be set as private
too.
You'd better write them into updateProps
since they're only used there, to improve code clarity. And in that way you don't have to pass these parameters all over the place.
} | ||
|
||
getAvatarBasicProps(hasTitle: boolean, hasParagraph: boolean): NzSkeletonAvatar { | ||
if (hasTitle && !hasParagraph) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use ?:
operator for code readability. Like:
const shape = hasTitle && !hasParagraph ? 'square' : 'circle';
return { shape };
toCSSUnit(value: number | string = ''): string { | ||
if (typeof value === 'number') { | ||
return `${value}px`; | ||
} else if (typeof value === 'string') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typeof ''
returns "string"
. It's not reliable though it works because when width
is not truthy, the line goes 100% wide as a block element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I revert this because the width is controlled by less:
https://github.com/ant-design/ant-design/blob/02af08951ad4b0a461fc282382f3c12dd5b6d7d1/components/skeleton/style/index.less#L63-L65
width = ''
will not affect default width, maybe there is a better solution.
widthList = width; | ||
} else if (width && !Array.isArray(width)) { | ||
widthList = []; | ||
widthList[rows - 1] = width; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it would work silently in situations like [undefined, undefined, 80]
and make the first two lines' width
property not set. But worrisome...
No need to change perhaps.
@wenqi73 And there's an avatar skeleton demo in card component page. Please add it. See https://deploy-preview-11226--ant-design.netlify.com/components/card-cn/#components-card-demo-loading. Besides, please change your first commit message to |
@wendzhue Another question: card loading demo has changed to skeleton, I think the test is useless so I commented it. please check again and I will change the commit message later. |
@wenqi73 Ant Design had released this component and added a new demo. See https://ant.design/components/skeleton-cn/#components-skeleton-demo-complex. Please add it. |
And please rebase your commit to tag 1.4.1. Since it was checked out some versions ago. |
And |
2bcc679
to
c201b4b
Compare
@wendzhue demo has added, please check. |
LGTM. @simplejason If possible, this could be released this weekend. |
* feat(module:skeleton): add skeleton component * fix(component:skeleton):sync demo to antd
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #1808
What is the new behavior?
Does this PR introduce a breaking change?
Other information