import * as React from "react"; const { I18n } = require("react-i18nify"); interface CommentOrderSelectorProps { defaultOrderBy: string; reorderComments: (orderBy: string) => void; } interface CommentOrderSelectorState { orderBy: string; } /** * A simple static component with the comment's order selector markup * @class * @augments Component * @todo Needs a proper implementation */ class CommentOrderSelector extends React.Component { private dropdown: HTMLUListElement; constructor(props: CommentOrderSelectorProps) { super(props); this.state = { orderBy: this.props.defaultOrderBy }; } public setDropdown = (dropdown: HTMLUListElement) => this.dropdown = dropdown; public componentDidMount() { window.$(this.dropdown).foundation(); } public render() { const { orderBy } = this.state; return (
{I18n.t("components.comment_order_selector.title")}
); } private updateOrder = (orderBy: string) => { return (event: React.MouseEvent) => { event.preventDefault(); this.setState({ orderBy }); this.props.reorderComments(orderBy); }; } } export default CommentOrderSelector;