1 import { Component, linkEvent } from 'inferno';
2 import { SortType } from '../interfaces';
3 import { sortingHelpUrl } from '../utils';
4 import { i18n } from '../i18next';
6 interface SortSelectProps {
8 onChange?(val: SortType): any;
12 interface SortSelectState {
16 export class SortSelect extends Component<SortSelectProps, SortSelectState> {
17 private emptyState: SortSelectState = {
18 sort: this.props.sort,
21 constructor(props: any, context: any) {
22 super(props, context);
23 this.state = this.emptyState;
30 value={this.state.sort}
31 onChange={linkEvent(this, this.handleSortChange)}
32 class="custom-select custom-select-sm w-auto mr-2"
34 <option disabled>{i18n.t('sort_type')}</option>
35 {!this.props.hideHot && (
36 <option value={SortType.Hot}>{i18n.t('hot')}</option>
38 <option value={SortType.New}>{i18n.t('new')}</option>
39 <option disabled>─────</option>
40 <option value={SortType.TopDay}>{i18n.t('top_day')}</option>
41 <option value={SortType.TopWeek}>{i18n.t('week')}</option>
42 <option value={SortType.TopMonth}>{i18n.t('month')}</option>
43 <option value={SortType.TopYear}>{i18n.t('year')}</option>
44 <option value={SortType.TopAll}>{i18n.t('all')}</option>
47 className="text-muted"
51 title={i18n.t('sorting_help')}
53 <svg class={`icon icon-inline`}>
54 <use xlinkHref="#icon-help-circle"></use>
61 handleSortChange(i: SortSelect, event: any) {
62 i.state.sort = Number(event.target.value);
64 i.props.onChange(i.state.sort);