Skip to content

Commit 686c6bb

Browse files
authored
Merge pull request #43 from areebsattar/Feature-Active-row
NW6 | Sabella Fisseha | Feature active row
2 parents d81e223 + 9654cba commit 686c6bb

6 files changed

Lines changed: 52 additions & 20 deletions

File tree

src/components/Card/Card.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ const Card = (props) => {
88
<h2>{title}</h2>
99
<img src={image} alt={title} />
1010

11-
<a href={url}> {title}</a>
12-
13-
11+
<a href={url} className="cardhref ">
12+
{" "}
13+
{title}
14+
</a>
1415
</div>
1516
);
1617
};

src/components/Card/Card.scss

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
11
.card {
2-
display: grid;
3-
grid-template:
4-
"image image image" 1fr
5-
". title ." auto / var(--space--gap) 1fr var(--space--gap);
6-
border: var(--border);
7-
border-color: var(--color--accent);
2+
display: flex;
3+
flex-direction: column;
4+
}
85

9-
&__title {
10-
grid-area: title;
11-
}
12-
&__image {
13-
grid-area: image;
14-
mix-blend-mode: overlay;
15-
}
6+
h2 {
7+
text-align: center;
8+
font-size: 2em;
9+
}
10+
h2:hover {
11+
background-color: rgb(26, 3, 26);
12+
color: white;
13+
}
14+
.cardhref {
15+
font-size: 2em;
16+
font-weight: bold;
17+
color: rgb(255, 255, 255);
18+
text-decoration: none;
19+
position: relative;
20+
top: -40%;
21+
text-align: center;
22+
}
23+
.cardhref:hover {
24+
background-color: skyblue;
25+
opacity: 0.7;
26+
color: black;
1627
}

src/components/Search/Search.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
display: flex;
44
gap: var(--space--gap);
55
align-items: stretch;
6+
margin-bottom: 15px;
67
}
78
&__label {
89
align-self: center;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.button {
2+
margin-bottom: 10px;
3+
}

src/components/SearchResult/SearchResult.scss

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ table {
44
}
55

66
thead {
7-
background-color: #f2f2f2;
7+
background-color: rgb(31, 11, 31);
8+
color: white;
89
}
910

1011
th,
@@ -17,3 +18,9 @@ td {
1718
th {
1819
font-weight: bold;
1920
}
21+
.table-row {
22+
cursor: pointer;
23+
}
24+
.selected {
25+
background-color: skyblue;
26+
}

src/components/SearchResult/TableBody.jsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
// import FakeBookings from "@/data/fakeBookings.json";
2-
1+
import FakeBookings from "@/data/fakeBookings.json";
2+
import React from "react";
3+
import { useState } from "react";
34
function TableBody(props) {
5+
const [selectedRow, setSelectedRow] = useState("unselect");
6+
function handleSelect() {
7+
setSelectedRow(selectedRow === "unselect" ? "selected" : "unselect");
8+
}
49
let {
510
id,
611
title,
@@ -15,7 +20,11 @@ function TableBody(props) {
1520
} = props;
1621
return (
1722
<>
18-
<tr key={id}>
23+
<tr
24+
key={id}
25+
onClick={handleSelect}
26+
className={`table-row ${selectedRow}`}
27+
>
1928
<td>{id}</td>
2029
<td>{title}</td>
2130
<td>{firstName}</td>

0 commit comments

Comments
 (0)