forked from AdaGold/inspiration-board
-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathCard.js
More file actions
45 lines (32 loc) · 951 Bytes
/
Copy pathCard.js
File metadata and controls
45 lines (32 loc) · 951 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { getUnicode } from 'emoji-dictionary';
import './Card.css';
class Card extends Component {
renderEmoji(emoji) {
return <p className="card__content-emoji">{getUnicode(emoji)}</p>
}
renderText(text) {
return <p className="card__content-text">{text}</p>
}
render() {
const icon = this.props.emoji ? this.renderEmoji(this.props.emoji) : null
const text = this.props.text ? this.renderText(this.props.text) : null
return (
<div className="card">
<div className="card__content">
{text}
{icon}
</div>
<div className="card__delete" onClick={() => this.props.onDeleteCallback(this.props.id)}>X</div>
</div>
)
}
}
Card.propTypes = {
onDeleteCallback: PropTypes.func,
text: PropTypes.string,
id: PropTypes.number,
emoji: PropTypes.string,
};
export default Card;