Skip to content

Commit 767ea35

Browse files
authored
Merge pull request #163 from gabrielsanttana/update-card-component
Update Card from class component to functional component
2 parents 283c834 + 1a6a6a6 commit 767ea35

File tree

1 file changed

+40
-31
lines changed

1 file changed

+40
-31
lines changed
Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,44 @@
1-
import React from 'react';
2-
import './css/project-cards.css';
1+
import React from "react";
2+
import "./css/project-cards.css";
33

4-
export default class Card extends React.Component {
5-
render() {
6-
let tags = [];
7-
if (this.props.tags){
8-
tags = this.props.tags.map((tag, key) => <div key={key}><p>{tag}</p></div>)
9-
}
4+
const Card = ({
5+
projectLink,
6+
logoLink,
7+
name,
8+
description,
9+
tags: propsTags,
10+
}) => {
11+
let tags = [];
1012

11-
return (
12-
<div className="Card-Container">
13-
<a className="Card-Real-Link" href={this.props.projectLink}>
14-
<div className="Card-Header">
15-
<img className="Project-Logo"
16-
alt="the framework or language that the project is build upon"
17-
src={this.props.logoLink} />
18-
<h3 className="Card-Title">{ this.props.name }</h3>
19-
</div>
20-
<div className="Card-Body">
21-
<div className="Card-Tag">
22-
{tags}
23-
</div>
24-
<div className="Card-Description">
25-
<p> { this.props.description }</p>
26-
</div>
27-
<div className="Card-Link">
28-
Go to Project
29-
</div>
30-
</div>
31-
</a>
13+
if (propsTags) {
14+
tags = propsTags.map((tag, key) => (
15+
<div key={key}>
16+
<p>{tag}</p>
3217
</div>
33-
);
18+
));
3419
}
35-
}
20+
21+
return (
22+
<div className="Card-Container">
23+
<a className="Card-Real-Link" href={projectLink}>
24+
<div className="Card-Header">
25+
<img
26+
className="Project-Logo"
27+
alt="the framework or language that the project is build upon"
28+
src={logoLink}
29+
/>
30+
<h3 className="Card-Title">{name}</h3>
31+
</div>
32+
<div className="Card-Body">
33+
<div className="Card-Tag">{tags}</div>
34+
<div className="Card-Description">
35+
<p> {description}</p>
36+
</div>
37+
<div className="Card-Link">Go to Project</div>
38+
</div>
39+
</a>
40+
</div>
41+
);
42+
};
43+
44+
export default Card;

0 commit comments

Comments
 (0)