Skip to content

Commit 21bae4f

Browse files
authored
Showing download count of extensions, make empty rating stars less attractive (#742)
* Showing download count of extensions instead of average rating counts on main page, make empty rating stars less attractive * made empty stars as grey stars, added download icon before download counts * make half star icon grey, remove brackets outside download counts
1 parent 5526358 commit 21bae4f

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

webui/src/pages/extension-detail/extension-rating-stars.tsx

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,28 @@
1010

1111
import * as React from 'react';
1212
import StarIcon from '@material-ui/icons/Star';
13-
import StarBorderIcon from '@material-ui/icons/StarBorder';
1413
import StarHalfIcon from '@material-ui/icons/StarHalf';
14+
import { Theme, WithStyles, createStyles, withStyles } from '@material-ui/core';
1515

16-
interface ExportRatingStarsProps {
16+
const starStyles = (theme: Theme) => createStyles({
17+
wrapper: {
18+
position: 'relative',
19+
display: 'inline-block',
20+
},
21+
topIcon: {
22+
position: 'absolute',
23+
},
24+
bottomIcon: {
25+
display: 'block',
26+
}
27+
});
28+
29+
interface ExportRatingStarsProps extends WithStyles<typeof starStyles>{
1730
number: number;
1831
fontSize?: 'inherit' | 'default' | 'small' | 'large';
1932
}
2033

21-
export class ExportRatingStars extends React.Component<ExportRatingStarsProps> {
34+
class ExportRatingStarsComponent extends React.Component<ExportRatingStarsProps> {
2235
render(): React.ReactNode {
2336
return <React.Fragment>
2437
{this.getStar(1)}{this.getStar(2)}{this.getStar(3)}{this.getStar(4)}{this.getStar(5)}
@@ -32,8 +45,13 @@ export class ExportRatingStars extends React.Component<ExportRatingStarsProps> {
3245
return <StarIcon fontSize={fontSize}/>;
3346
}
3447
if (i > starsNumber && i - 1 < starsNumber) {
35-
return <StarHalfIcon fontSize={fontSize}/>;
48+
return <span className={this.props.classes.wrapper}>
49+
<StarHalfIcon fontSize={fontSize} className={this.props.classes.topIcon}/>
50+
<StarIcon style={{ color: '#bcbcbc' }} fontSize={fontSize} className={this.props.classes.bottomIcon}/>
51+
</span>;
3652
}
37-
return <StarBorderIcon fontSize={fontSize}/>;
53+
return <StarIcon style={{ color: '#bcbcbc' }} fontSize={fontSize}/>;
3854
}
3955
}
56+
57+
export const ExportRatingStars = withStyles(starStyles)(ExportRatingStarsComponent);

webui/src/pages/extension-list/extension-list-item.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import * as React from 'react';
1212
import { Link as RouteLink } from 'react-router-dom';
1313
import { Paper, Typography, Box, Grid, Fade } from '@material-ui/core';
1414
import { withStyles, createStyles, WithStyles, Theme } from '@material-ui/core/styles';
15+
import SaveAltIcon from '@material-ui/icons/SaveAlt';
1516
import { MainContext } from '../../context';
1617
import { ExtensionDetailRoutes } from '../extension-detail/extension-detail';
1718
import { SearchEntry } from '../../extension-registry-types';
@@ -90,7 +91,7 @@ class ExtensionListItemComponent extends React.Component<ExtensionListItemCompon
9091
const { icon } = this.state;
9192
const route = createRoute([ExtensionDetailRoutes.ROOT, extension.namespace, extension.name]);
9293
const numberFormat = new Intl.NumberFormat(undefined, { notation: 'compact', compactDisplay: 'short' } as any);
93-
const reviewCountFormatted = numberFormat.format(extension.reviewCount || 0);
94+
const downloadCountFormatted = numberFormat.format(extension.downloadCount || 0);
9495
return <React.Fragment>
9596
<Fade in={true} timeout={{ enter: ((this.props.filterSize + this.props.idx) % this.props.filterSize) * 200 }}>
9697
<Grid item xs={12} sm={3} md={2} title={extension.displayName || extension.name} className={classes.extensionCard}>
@@ -116,7 +117,8 @@ class ExtensionListItemComponent extends React.Component<ExtensionListItemCompon
116117
</Box>
117118
<Box display='flex' justifyContent='center'>
118119
<ExportRatingStars number={extension.averageRating || 0} fontSize='small'/>
119-
({reviewCountFormatted})
120+
&nbsp;
121+
{downloadCountFormatted != "0" && <><SaveAltIcon/> {downloadCountFormatted}</>}
120122
</Box>
121123
</Paper>
122124
</RouteLink>

0 commit comments

Comments
 (0)