* convert all tags to have a `tag` field corresponding to the query parameter, and `intlLabel` field that defines the title message for `FormattedMessage` * define all the tag messages in a shared file so they can be included in multiple places. * convert the `TagButton` to use `tag` for the `onclick` handler value, and localize `intlLabel` for the title. In the library I’ve continued to use `tag.toLowercase()` even though all the tags are currently defined as lowercase. It’s safer, but currently not strictly needed.
33 lines
700 B
React
33 lines
700 B
React
import bindAll from 'lodash.bindall';
|
|
import PropTypes from 'prop-types';
|
|
import React from 'react';
|
|
|
|
import TagButtonComponent from '../components/tag-button/tag-button.jsx';
|
|
|
|
class TagButton extends React.Component {
|
|
constructor (props) {
|
|
super(props);
|
|
bindAll(this, [
|
|
'handleClick'
|
|
]);
|
|
}
|
|
handleClick () {
|
|
this.props.onClick(this.props.tag);
|
|
}
|
|
render () {
|
|
return (
|
|
<TagButtonComponent
|
|
{...this.props}
|
|
onClick={this.handleClick}
|
|
/>
|
|
);
|
|
}
|
|
}
|
|
|
|
TagButton.propTypes = {
|
|
...TagButtonComponent.propTypes,
|
|
onClick: PropTypes.func
|
|
};
|
|
|
|
export default TagButton;
|