Skip to content

Commit f9eeb04

Browse files
authored
th-98: TowTruck Card (#188)
* th-98: + starRating component * th-98: + truck images * th-98: + towTruckCard * th-98: * towTruckCard replaced types
1 parent 9314c32 commit f9eeb04

File tree

13 files changed

+288
-4
lines changed

13 files changed

+288
-4
lines changed

frontend/src/assets/css/vars.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ $red-dark: #d51a52;
88
$blue-light: #527efe;
99
$blue: #507ceb;
1010
$blue-dark: #3563e9;
11+
$black-blue: #1a202c;
1112
$grey-extra-light: #ebf3ff;
13+
$grey-border: #e7eef6;
1214
$grey-light: #d5dce8;
1315
$grey: #90a3bf;
1416
$grey-dark: #7c8798;
@@ -23,6 +25,7 @@ $shadow-light: 0 4px 8px -2px rgb(0 85 255 / 16%);
2325
$shadow: 0 2px 4px -2px rgb(0 44 132 / 6%);
2426
$font-family: "Plus Jakarta Sans", sans-serif;
2527
$font-weight-regular: 400;
28+
$font-weight-normal: 500;
2629
$font-weight-semibold: 600;
2730
$font-weight-bold: 700;
2831
$font-weight-extrabold: 800;

frontend/src/assets/img/truck/type-1.svg

Lines changed: 9 additions & 0 deletions
Loading

frontend/src/assets/img/truck/type-2.svg

Lines changed: 9 additions & 0 deletions
Loading

frontend/src/assets/img/truck/type-3.svg

Lines changed: 9 additions & 0 deletions
Loading

frontend/src/libs/components/badge/badge.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const paletteColors = {
1414
const [defaultColor] = Object.keys(paletteColors) as Color[];
1515

1616
type Properties = {
17-
children: string;
17+
children: string | JSX.Element[];
1818
className?: string;
1919
color?: Color;
2020
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;

frontend/src/libs/components/components.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export { Radio } from './radio/radio.js';
2121
export { Router } from './router/router.jsx';
2222
export { RouterProvider } from './router-provider/router-provider.jsx';
2323
export { Spinner } from './spinner/spinner.js';
24+
export { StarRating } from './star-rating/star-rating.jsx';
2425
export { Table } from './table/table.js';
2526
export { Toggle } from './toggle/toggle.js';
2627
export { Provider as StoreProvider } from 'react-redux';
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { IconName } from '~/libs/enums/icon-name.enum.js';
2+
3+
import { Icon } from '../components.js';
4+
import styles from './styles.module.scss';
5+
6+
type Properties = {
7+
rating: number;
8+
};
9+
10+
const StarRating: React.FC<Properties> = ({ rating }: Properties) => {
11+
const fullFieldStars = Math.floor(rating);
12+
const allStarts = Math.ceil(rating);
13+
14+
const createStarItem = (width: number, key: number): JSX.Element => {
15+
return (
16+
<div className={styles.star} key={key}>
17+
<div className={styles.placeholder}>
18+
<Icon iconName={IconName.STAR}></Icon>
19+
</div>
20+
<div className={styles.inner} style={{ width: `${width}%` }}>
21+
<Icon iconName={IconName.STAR}></Icon>
22+
</div>
23+
</div>
24+
);
25+
};
26+
27+
const createStars = (): JSX.Element[] => {
28+
const stars: JSX.Element[] = [];
29+
for (let index = 1; index <= 5; index++) {
30+
if (fullFieldStars >= index) {
31+
stars.push(createStarItem(100, index));
32+
} else if (allStarts >= index) {
33+
stars.push(createStarItem((rating - fullFieldStars) * 100, index));
34+
} else {
35+
stars.push(createStarItem(0, index));
36+
}
37+
}
38+
39+
return stars;
40+
};
41+
42+
return <div className={styles.container}>{createStars()}</div>;
43+
};
44+
45+
export { StarRating };
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.container {
2+
display: flex;
3+
}
4+
5+
.star {
6+
position: relative;
7+
}
8+
9+
.inner {
10+
position: absolute;
11+
top: 0;
12+
left: 0;
13+
width: 0;
14+
height: 100%;
15+
overflow: hidden;
16+
color: #ffd12d;
17+
white-space: nowrap;
18+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { type ValueOf, TruckTowType } from 'shared/build';
2+
3+
import img1 from '~/assets/img/truck/type-1.svg';
4+
import img2 from '~/assets/img/truck/type-2.svg';
5+
import img3 from '~/assets/img/truck/type-3.svg';
6+
7+
const getTowTruckImage = (type: ValueOf<typeof TruckTowType>): string => {
8+
switch (type) {
9+
case TruckTowType.FLATBED_OR_ROLLBACK: {
10+
return img3;
11+
}
12+
case TruckTowType.HOOK_AND_CHAIN: {
13+
return img3;
14+
}
15+
case TruckTowType.INTEGRATED: {
16+
return img1;
17+
}
18+
case TruckTowType.WHEEL_LIFT: {
19+
return img2;
20+
}
21+
}
22+
};
23+
24+
export { getTowTruckImage };
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
@import "../../../assets/css/styles.scss";
2+
3+
.container {
4+
width: 100%;
5+
height: 212px;
6+
margin-bottom: 16px;
7+
padding: 7px 0;
8+
background-color: white;
9+
border-radius: 10px;
10+
box-shadow: 0 2px 4px 0 rgba(173 164 164 / 15%);
11+
}
12+
13+
.body {
14+
display: flex;
15+
justify-content: space-between;
16+
width: 100%;
17+
padding: 0 24px 4px;
18+
}
19+
20+
.footer {
21+
display: flex;
22+
justify-content: space-between;
23+
padding: 14px 24px 16px;
24+
border-top: 1px solid $grey-border;
25+
}
26+
27+
.description {
28+
margin-top: 26px;
29+
}
30+
31+
.name {
32+
color: $black-blue;
33+
font-weight: $font-weight-bold;
34+
font-size: 20px;
35+
}
36+
37+
.rating {
38+
display: flex;
39+
align-items: center;
40+
gap: 7px;
41+
margin-top: 9px;
42+
}
43+
44+
.reviews {
45+
color: $grey;
46+
font-weight: $font-weight-normal;
47+
font-size: 14px;
48+
}
49+
50+
.capacity {
51+
display: flex;
52+
align-items: center;
53+
gap: 3px;
54+
margin-top: 13px;
55+
color: $grey;
56+
font-weight: $font-weight-bold;
57+
font-size: 14px;
58+
}
59+
60+
.aside {
61+
display: flex;
62+
}
63+
64+
.img {
65+
width: 267px;
66+
height: 127px;
67+
}
68+
69+
.info {
70+
display: flex;
71+
align-items: center;
72+
gap: 23px;
73+
}
74+
75+
.price {
76+
font-size: 20px;
77+
}
78+
79+
.bold {
80+
font-weight: $font-weight-bold;
81+
}
82+
83+
.gray {
84+
color: $grey;
85+
font-size: 14px;
86+
}
87+
88+
.badge {
89+
height: 25px;
90+
margin-top: 27px;
91+
}
92+
93+
.km {
94+
margin-left: 6px;
95+
}

0 commit comments

Comments
 (0)