2019-10-13 21:32:11 +00:00
|
|
|
/*
|
2019-10-20 09:13:42 +00:00
|
|
|
Copyright 2019 Tulir Asokan <tulir@maunium.net>
|
2019-10-13 21:32:11 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2020-05-25 13:59:03 +00:00
|
|
|
import classNames from "classnames";
|
2019-10-13 21:32:11 +00:00
|
|
|
|
2019-10-14 17:14:40 +00:00
|
|
|
class Header extends React.PureComponent {
|
2019-10-13 21:32:11 +00:00
|
|
|
static propTypes = {
|
|
|
|
categories: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
|
|
onAnchorClick: PropTypes.func.isRequired,
|
2019-10-14 17:14:40 +00:00
|
|
|
refs: PropTypes.object,
|
2019-10-13 21:32:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
2020-05-25 13:59:03 +00:00
|
|
|
<nav className="mx_EmojiPicker_header" role="tablist">
|
|
|
|
{this.props.categories.map(category => {
|
|
|
|
const classes = classNames(`mx_EmojiPicker_anchor mx_EmojiPicker_anchor_${category.id}`, {
|
|
|
|
mx_EmojiPicker_anchor_visible: category.visible,
|
|
|
|
});
|
|
|
|
return <button
|
|
|
|
disabled={!category.enabled}
|
|
|
|
key={category.id}
|
|
|
|
ref={category.ref}
|
|
|
|
className={classes}
|
|
|
|
onClick={() => this.props.onAnchorClick(category.id)}
|
|
|
|
title={category.name}
|
|
|
|
role="tab"
|
|
|
|
aria-selected={category.visible}
|
|
|
|
aria-controls={`mx_EmojiPicker_category_${category.id}`}
|
|
|
|
/>;
|
|
|
|
})}
|
2019-10-13 21:32:11 +00:00
|
|
|
</nav>
|
2019-10-20 09:13:32 +00:00
|
|
|
);
|
2019-10-13 21:32:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Header;
|