1 import { Component, linkEvent } from "inferno";
2 import { CommentSortType } from "lemmy-js-client";
3 import { i18n } from "../../i18next";
4 import { randomStr, relTags, sortingHelpUrl } from "../../utils";
5 import { Icon } from "./icon";
7 interface CommentSortSelectProps {
9 onChange?(val: CommentSortType): any;
12 interface CommentSortSelectState {
13 sort: CommentSortType;
16 export class CommentSortSelect extends Component<
17 CommentSortSelectProps,
18 CommentSortSelectState
20 private id = `sort-select-${randomStr()}`;
21 state: CommentSortSelectState = {
22 sort: this.props.sort,
25 constructor(props: any, context: any) {
26 super(props, context);
29 static getDerivedStateFromProps(props: any): CommentSortSelectState {
41 value={this.state.sort}
42 onChange={linkEvent(this, this.handleSortChange)}
43 className="form-select d-inline-block w-auto me-2 mb-2"
44 aria-label={i18n.t("sort_type")}
46 <option disabled aria-hidden="true">
49 <option value={"Hot"}>{i18n.t("hot")}</option>,
50 <option value={"Top"}>{i18n.t("top")}</option>,
51 <option value={"New"}>{i18n.t("new")}</option>
52 <option value={"Old"}>{i18n.t("old")}</option>
55 className="text-muted"
58 title={i18n.t("sorting_help")}
60 <Icon icon="help-circle" classes="icon-inline" />
66 handleSortChange(i: CommentSortSelect, event: any) {
67 i.props.onChange?.(event.target.value);