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

Omit rendering for rating/downloads of an extension if 0 #7380

Merged
merged 2 commits into from
Mar 27, 2020
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
2 changes: 1 addition & 1 deletion packages/vsx-registry/src/browser/style/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@
font-size: 80%;
}


.theia-vsx-extension-content .title .stat .average-rating > i {
color: #ff8e00;
}

.theia-vsx-extension-editor .download-count > i,
.theia-vsx-extension-content .title .stat .average-rating > i,
.theia-vsx-extension-content .title .stat .download-count > i {
padding-right: calc(var(--theia-ui-padding)/2);
Expand Down
15 changes: 7 additions & 8 deletions packages/vsx-registry/src/browser/vsx-extension.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ export class VSXExtensionComponent extends AbstractVSXExtensionComponent {
<span className='name'>{displayName}</span> <span className='version'>{version}</span>
</div>
<div className='stat'>
{downloadCount && <span className='download-count'><i className='fa fa-download' />{downloadCompactFormatter.format(downloadCount)}</span>}
{averageRating && <span className='average-rating'><i className='fa fa-star' />{averageRating.toFixed(1)}</span>}
{!!downloadCount && <span className='download-count'><i className='fa fa-download' />{downloadCompactFormatter.format(downloadCount)}</span>}
{!!averageRating && <span className='average-rating'><i className='fa fa-star' />{averageRating.toFixed(1)}</span>}
</div>
</div>
<div className='noWrapInfo theia-vsx-extension-description'>{description}</div>
Expand Down Expand Up @@ -369,8 +369,9 @@ export class VSXExtensionEditorComponent extends AbstractVSXExtensionComponent {
{this.renderNamespaceAccess()}
{publisher}
</span>
{downloadCount && <span className='fa fa-download download-count' onClick={this.openExtension}>{downloadFormatter.format(downloadCount)}</span>}
{averageRating && <span className='average-rating' onClick={this.openAverageRating}>{this.renderStars()}</span>}
{!!downloadCount && <span className='download-count' onClick={this.openExtension}>
<i className="fa fa-download" />{downloadFormatter.format(downloadCount)}</span>}
{averageRating !== undefined && <span className='average-rating' onClick={this.openAverageRating}>{this.renderStars()}</span>}
kaiyue0329 marked this conversation as resolved.
Show resolved Hide resolved
{repository && <span className='repository' onClick={this.openRepository}>Repository</span>}
{license && <span className='license' onClick={this.openLicense}>{license}</span>}
</div>
Expand Down Expand Up @@ -403,10 +404,8 @@ export class VSXExtensionEditorComponent extends AbstractVSXExtensionComponent {
}

protected renderStars(): React.ReactNode {
const rating = this.props.extension.averageRating;
if (typeof rating !== 'number') {
return undefined;
}
const rating = this.props.extension.averageRating || 0;

const renderStarAt = (position: number) => position <= rating ?
<i className='fa fa-star' /> :
position > rating && position - rating < 1 ?
Expand Down