Skip to content

Commit 4f4f484

Browse files
authored
Merge pull request #19 from KeyValueSoftwareSystems/feature/design-changes
style: new design updates, default color change, barcount format change
2 parents 572829f + d5076f8 commit 4f4f484

File tree

19 files changed

+108
-76
lines changed

19 files changed

+108
-76
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,13 @@ Props that can be passed to the component are listed below:
176176
</tr>
177177
<tr>
178178
<td><code><b>ratingAverageIconProps?:</b> object</code></td>
179-
<td>An object defining the fill color ( fillColor?: string ) and background color ( bgColor?: string ) for customizing the appearance of star icon in the average rating section.</td>
179+
<td>An object defining the fill color ( fillColor?: string ), background color ( bgColor?: string ), border color (borderColor: string) and border width (borderWidth: number) for customizing the appearance of star icon in the average rating section.</td>
180180
<td><code>undefined</code></td>
181181
</tr>
182182
<tr>
183183
<td><code><b>thousandsSeparator?:</b> string</code></td>
184184
<td>A string specifying the custom thousands separator for formatting a numerical value.</td>
185-
<td><code>','</code></td>
185+
<td><code>undefined</code></td>
186186
</tr>
187187
<tr>
188188
<td><code><b>ratingAverageSubText?:</b> string</code></td>
@@ -194,6 +194,11 @@ Props that can be passed to the component are listed below:
194194
<td>The order prop dictates the summary section's display order. Possible values are: 'ORIGINAL' or 'REVERSE'. For numeric ratingIds, it sorts in ascending (ORIGINAL) or descending (REVERSE) order. For string based ratingIds, it reflects the original/reversed order of keys in the ratings prop.</td>
195195
<td><code>'REVERSE'</code></td>
196196
</tr>
197+
<tr>
198+
<td><code><b>ratingLabelIconProps?:</b> object</code></td>
199+
<td>An object defining the fill color ( fillColor?: string ), background color ( bgColor?: string ), border color (borderColor: string) and border width (borderWidth: number) for customizing the appearance of star icon in the progess bar label section.</td>
200+
<td><code>undefined</code></td>
201+
</tr>
197202
</tbody>
198203
</table>
199204

10.6 KB
Loading

src/assets/star-grey.svg

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/constants.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,11 @@ export enum ORDER {
2727

2828
export const INTERNATIONAL_NUMBER_SYSTEM_REGEX = /\B(?=(\d{3})+(?!\d))/g;
2929

30-
export const DEFAULT_BAR_COLORS = {
31-
1: '#ff8b5a',
32-
2: '#ffb337',
33-
3: '#ffd834',
34-
4: '#add633',
35-
5: '#9fc05a'
36-
};
30+
export const DEFAULT_COLOR = "#5D5FEF";
3731

3832
export const RATING_AVERAGE_DEFAULTS = {
3933
icon: {
40-
fillColor: '#919191',
41-
bgColor: '#F2F2F2'
34+
fillColor: DEFAULT_COLOR,
35+
bgColor: '#FFFFFF'
4236
}
4337
};

src/rating-average/RatingAverage.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const RatingAverage: FC<IRatingAverageProp> = (props) => {
2424
thousandsSeparator,
2525
ratingAverageSubText
2626
} = props;
27-
const { fillColor = icon.fillColor, bgColor = icon.bgColor } =
27+
const { fillColor = icon.fillColor, bgColor = icon.bgColor, borderColor, borderWidth } =
2828
iconProps || {};
2929

3030
const extractStarInfo = (average: number): [number, number, number] => {
@@ -65,6 +65,8 @@ const RatingAverage: FC<IRatingAverageProp> = (props) => {
6565
<Star
6666
fillColor={fillColor}
6767
bgColor={bgColor}
68+
borderColor={borderColor}
69+
borderWidth={borderWidth}
6870
colorFilledFraction={1}
6971
id={`completely-filled-star-${index}`}
7072
/>
@@ -79,6 +81,8 @@ const RatingAverage: FC<IRatingAverageProp> = (props) => {
7981
<Star
8082
fillColor={fillColor}
8183
bgColor={bgColor}
84+
borderColor={borderColor}
85+
borderWidth={borderWidth}
8286
colorFilledFraction={visibleStarFraction}
8387
id="fraction-filled-star"
8488
/>
@@ -95,6 +99,8 @@ const RatingAverage: FC<IRatingAverageProp> = (props) => {
9599
<Star
96100
fillColor={fillColor}
97101
bgColor={bgColor}
102+
borderColor={borderColor}
103+
borderWidth={borderWidth}
98104
colorFilledFraction={0}
99105
id={`unfilled-star-${index}`}
100106
/>

src/rating-average/star/Star.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@ import React, { FC } from 'react';
33
import { StarProp } from './types';
44

55
const Star: FC<StarProp> = (props) => {
6-
const { fillColor, bgColor, colorFilledFraction, id } = props;
6+
const { fillColor, bgColor, colorFilledFraction, borderColor, borderWidth = 2, id } = props;
7+
const borderFallBackColor = borderColor || fillColor;
78

89
return (
9-
<svg width="100%" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
10+
<svg width="100%" viewBox="-2 -2 36 36" xmlns="http://www.w3.org/2000/svg">
1011
<defs>
1112
<linearGradient id={id} shapeRendering="crispEdges">
1213
<stop offset={colorFilledFraction} stopColor={fillColor} />
1314
<stop offset="0%" stopColor={bgColor} />
1415
</linearGradient>
1516
</defs>
1617
<path
18+
stroke={borderFallBackColor}
19+
strokeWidth={borderWidth}
1720
fill={`url(#${id})`}
1821
d="M20.388,10.918L32,12.118l-8.735,7.749L25.914,31.4l-9.893-6.088L6.127,31.4l2.695-11.533L0,12.118
1922
l11.547-1.2L16.026,0.6L20.388,10.918z"

src/rating-average/star/types.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { RatingAverageIconProps } from '../../rating-summary/types';
1+
import { RatingIconProps } from '../../rating-summary/types';
22

3-
export interface StarProp extends RatingAverageIconProps {
3+
export interface StarProp extends RatingIconProps {
44
colorFilledFraction: number;
55
id: string;
66
}

src/rating-average/styles.module.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
row-gap: 4px;
77
}
88
.averageRatingValue {
9-
font-size: 60px;
10-
font-weight: 200;
9+
font-size: 36px;
10+
font-weight: 600;
1111
margin: 0;
1212
}
1313
.iconsWrapper {
@@ -19,8 +19,8 @@
1919
display: flex;
2020
flex-direction: row;
2121
justify-content: center;
22-
color: #a9a9a9;
23-
font-size: 14px;
22+
color: #1D1D1D;
23+
font-size: 12px;
2424
min-width: 104px;
2525
padding-top: 4px;
2626
column-gap: 4px;

src/rating-average/types.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
CustomAverageFn,
33
CustomStyles,
44
IRatings,
5-
RatingAverageIconProps,
5+
RatingIconProps,
66
RatingRanks
77
} from '../rating-summary/types';
88

@@ -11,7 +11,7 @@ export interface IRatingAverageProp {
1111
ranks?: RatingRanks;
1212
customAverageFn?: CustomAverageFn;
1313
averageRatingPrecision: number;
14-
iconProps?: RatingAverageIconProps;
14+
iconProps?: RatingIconProps;
1515
styles?: CustomStyles;
1616
thousandsSeparator?: string;
1717
ratingAverageSubText: string;

src/rating-distribution-item/RatingDistributionItem.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React, { FC } from 'react';
22

33
import { IRatingDistributionProp } from './types';
4-
import { DEFAULT_BAR_COLORS, Elements } from '../constants';
5-
import { formatNumber, getStyles, isValidNumber } from '../utils';
4+
import { Elements, DEFAULT_COLOR } from '../constants';
5+
import { formatNumber, getStyles } from '../utils';
66
import classes from './styles.module.scss';
77

88
const RatingDistributionItem: FC<IRatingDistributionProp> = (props) => {
@@ -24,13 +24,11 @@ const RatingDistributionItem: FC<IRatingDistributionProp> = (props) => {
2424
const getBarBgColor = (): string => {
2525
if (barColors?.[currentRatingId]) return barColors[currentRatingId];
2626

27-
return isValidNumber(currentRatingId) &&
28-
DEFAULT_BAR_COLORS[Number(currentRatingId)]
29-
? DEFAULT_BAR_COLORS[Number(currentRatingId)]
30-
: DEFAULT_BAR_COLORS[1];
27+
return DEFAULT_COLOR;
3128
};
3229

3330
return (
31+
<>
3432
<div
3533
className={classes.barContainer}
3634
style={getStyles(styles, Elements.BarContainer, currentRatingId)}
@@ -59,7 +57,10 @@ const RatingDistributionItem: FC<IRatingDistributionProp> = (props) => {
5957
showAnimation && classes.animations
6058
}`}
6159
>
62-
{showCount && (
60+
</div>
61+
</div>
62+
</div>
63+
{showCount && (
6364
<span
6465
className={classes.countContainer}
6566
style={getStyles(styles, Elements.Count, currentRatingId)}
@@ -68,9 +69,7 @@ const RatingDistributionItem: FC<IRatingDistributionProp> = (props) => {
6869
{formatNumber(currentRatingValue, thousandsSeparator)}
6970
</span>
7071
)}
71-
</div>
72-
</div>
73-
</div>
72+
</>
7473
);
7574
};
7675

0 commit comments

Comments
 (0)