Skip to content

Commit c2a85d8

Browse files
committed
[#2] feat: edit ProductItem component according to hover event
1 parent 7dfbdc3 commit c2a85d8

File tree

3 files changed

+55
-27
lines changed

3 files changed

+55
-27
lines changed
Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,51 @@
1+
import { useState } from "react";
12
import ImageBox from "../../ImageBox";
23
import styles from "./styles.module.scss";
4+
import cn from "classnames";
5+
import AddButton from "../../AddButton";
36

47
export default function ProductItem() {
8+
const [isHovered, setIsHovered] = useState(false);
9+
10+
const onMouseEnter = () => setIsHovered(true);
11+
const onMouseLeave = () => setIsHovered(false);
512
return (
6-
<div className={styles.Container}>
7-
<ImageBox productImg />
8-
<div className={styles.Content}>
9-
<div className={styles.Name}>
10-
Apple iPhone 11 Pro Maxi Phone 11 Pro Max iPhone 11 (Max 2 Line)...
11-
</div>
12-
<div className={styles.Variant}>
13-
<label>Marka:&nbsp;</label>
14-
<span className={styles.Name}>Apple</span>
15-
</div>
16-
<div className={styles.Variant}>
17-
<label>Renk:&nbsp;</label>
18-
<span className={styles.Name}>Siyah</span>
19-
</div>
20-
<span className={styles.Price}>90,85 TL</span>
21-
<div className={styles.DiscountContainer}>
22-
<span className={styles.DiscountedPrice}>124,00 TL</span>
23-
<span className={styles.Discount}>12%</span>
24-
</div>
25-
</div>
13+
<div
14+
className={cn(styles.Container, isHovered && styles.Stroke)}
15+
onMouseEnter={() => onMouseEnter()}
16+
onMouseLeave={() => onMouseLeave()}
17+
>
18+
{!isHovered ? (
19+
<>
20+
<ImageBox productImg />
21+
<div className={styles.Content}>
22+
<div className={styles.Name}>iPhone 11 Kırmızı Kılıf</div>
23+
<div>
24+
<div className={styles.Variant}>
25+
<label>Marka:&nbsp;</label>
26+
<span className={styles.Name}>Apple</span>
27+
</div>
28+
<div className={styles.Variant}>
29+
<label>Renk:&nbsp;</label>
30+
<span className={styles.Name}>Siyah</span>
31+
</div>
32+
</div>
33+
<span className={styles.Price}>90,85 TL</span>
34+
<div className={styles.DiscountContainer}>
35+
<span className={styles.DiscountedPrice}>124,00 TL</span>
36+
<span className={styles.Discount}>12%</span>
37+
</div>
38+
</div>
39+
</>
40+
) : (
41+
<>
42+
<ImageBox productImg isHovered />
43+
<div className={cn(styles.Content, styles.Hover)}>
44+
<div className={styles.Name}>iPhone 11 Kırmızı Kılıf</div>
45+
<AddButton />
46+
</div>
47+
</>
48+
)}
2649
</div>
2750
);
2851
}

client/src/components/ProductTable/ProductItem/styles.module.scss

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,27 @@
99
max-height: 100%;
1010
height: 100%;
1111

12+
&.Stroke {
13+
border: 1px solid vars.$stroke-border-color;
14+
border-radius: 4px;
15+
}
16+
1217
.Content {
1318
display: flex;
1419
width: 230px;
1520
max-width: 230px;
21+
height: 130px;
22+
max-height: 130px;
1623
align-items: flex-start;
1724
flex-direction: column;
25+
justify-content: space-between;
1826

1927
.Name {
20-
font-family: Roboto;
28+
padding-top: 9px;
2129
font-style: normal;
2230
font-weight: normal;
2331
font-size: 12px;
2432
line-height: 18px;
25-
margin-top: 9px;
26-
margin-bottom: 10px;
2733
}
2834

2935
.Variant {
@@ -33,8 +39,6 @@
3339
font-size: 12px;
3440
line-height: 18px;
3541
color: vars.$primary-font-color;
36-
// .Label {
37-
// }
3842

3943
.Name {
4044
font-weight: normal;
@@ -43,7 +47,6 @@
4347

4448
.Price {
4549
height: 17px;
46-
margin-top: 13px;
4750
font-style: normal;
4851
font-weight: bold;
4952
font-size: 14px;

client/src/global/variables.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ $brand-color: #ff6000; // logo, linkler vs
55
$border-color: #b0b0b0; // buttonlar sepetim
66
$sorting-border-color: #b4b4bb; //siralama
77
$hover-border-color: $border-color; // ürüne hover edilmesi
8+
$stroke-border-color: #cdcdcd;
89

910
$muted-font-color: $border-color;
1011
$primary-font-color: #484848; // ana baslik, alt basliklar
1112
$secondary-font-color: #646464; // linkler
13+
$deactive-font-color: $border-color; // sepet deactive
1214
$disabled-font-color: #9b9b9b; // düşülen para
1315
$highlight-font-color: #f90000; // indirim, sepetten kaldir butonu
1416

@@ -19,8 +21,8 @@ $hover-link-color: $brand-color;
1921
$add-to-cart-btn-bg: rgba(255, 96, 0, 0.11);
2022
$cart-item-border-color: #e5e5e5;
2123
$cart-remove-btn-color: $highlight-font-color;
24+
$cart-remove-deactive-btn-color: rgba(126, 126, 126, 0.11);
2225
$pagination-btn-color: #eeeeee;
2326
$search-bg-color: $pagination-btn-color;
2427
$search-ph-color: $border-color; // search placeholder
2528

26-
$secondary-bg-color: $border-color; // search, deactive button

0 commit comments

Comments
 (0)