summaryrefslogtreecommitdiffstats
path: root/webapp/components/emoji_picker/components/emoji_picker_category.jsx
blob: 21c59baea6e5c05369cb0c197886e564bd049448 (plain)
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
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

import React from 'react';

export default class EmojiPickerCategory extends React.Component {
    static propTypes = {
        category: React.PropTypes.string.isRequired,
        icon: React.PropTypes.node.isRequired,
        onCategoryClick: React.PropTypes.func.isRequired,
        selected: React.PropTypes.bool.isRequired
    }

    constructor(props) {
        super(props);

        this.handleClick = this.handleClick.bind(this);
    }

    handleClick(e) {
        e.preventDefault();

        this.props.onCategoryClick(this.props.category);
    }

    render() {
        let className = 'emoji-picker__category';
        if (this.props.selected) {
            className += ' emoji-picker__category--selected';
        }

        return (
            <a
                className={className}
                href='#'
                onClick={this.handleClick}
            >
                {this.props.icon}
            </a>
        );
    }
}