fix: Fix focus ring styles for home toggles #1772

This commit is contained in:
Jay Sitter 2023-07-02 20:44:26 -04:00
parent 8e20d16f71
commit acfbe99a07
2 changed files with 57 additions and 40 deletions

View file

@ -1,3 +1,4 @@
import { randomStr } from "@utils/helpers";
import { Component, linkEvent } from "inferno"; import { Component, linkEvent } from "inferno";
import { DataType } from "../../interfaces"; import { DataType } from "../../interfaces";
import { I18NextService } from "../../services"; import { I18NextService } from "../../services";
@ -15,6 +16,8 @@ export class DataTypeSelect extends Component<
DataTypeSelectProps, DataTypeSelectProps,
DataTypeSelectState DataTypeSelectState
> { > {
private id = `listing-type-input-${randomStr()}`;
state: DataTypeSelectState = { state: DataTypeSelectState = {
type_: this.props.type_, type_: this.props.type_,
}; };
@ -32,32 +35,36 @@ export class DataTypeSelect extends Component<
render() { render() {
return ( return (
<div className="data-type-select btn-group btn-group-toggle flex-wrap"> <div className="data-type-select btn-group btn-group-toggle flex-wrap">
<input
id={`${this.id}-posts`}
type="radio"
className="btn-check"
value={DataType.Post}
checked={this.state.type_ == DataType.Post}
onChange={linkEvent(this, this.handleTypeChange)}
/>
<label <label
htmlFor={`${this.id}-posts`}
className={`pointer btn btn-outline-secondary className={`pointer btn btn-outline-secondary
${this.state.type_ == DataType.Post && "active"} ${this.state.type_ == DataType.Post && "active"}
`} `}
> >
<input
type="radio"
className="btn-check"
value={DataType.Post}
checked={this.state.type_ == DataType.Post}
onChange={linkEvent(this, this.handleTypeChange)}
/>
{I18NextService.i18n.t("posts")} {I18NextService.i18n.t("posts")}
</label> </label>
<input
id={`${this.id}-comments`}
type="radio"
className="btn-check"
value={DataType.Comment}
checked={this.state.type_ == DataType.Comment}
onChange={linkEvent(this, this.handleTypeChange)}
/>
<label <label
htmlFor={`${this.id}-comments`}
className={`pointer btn btn-outline-secondary ${ className={`pointer btn btn-outline-secondary ${
this.state.type_ == DataType.Comment && "active" this.state.type_ == DataType.Comment && "active"
}`} }`}
> >
<input
type="radio"
className="btn-check"
value={DataType.Comment}
checked={this.state.type_ == DataType.Comment}
onChange={linkEvent(this, this.handleTypeChange)}
/>
{I18NextService.i18n.t("comments")} {I18NextService.i18n.t("comments")}
</label> </label>
</div> </div>

View file

@ -38,15 +38,12 @@ export class ListingTypeSelect extends Component<
render() { render() {
return ( return (
<div className="listing-type-select btn-group btn-group-toggle flex-wrap"> <div
className="listing-type-select btn-group btn-group-toggle flex-wrap"
role="group"
>
{this.props.showSubscribed && ( {this.props.showSubscribed && (
<label <>
title={I18NextService.i18n.t("subscribed_description")}
className={`btn btn-outline-secondary
${this.state.type_ == "Subscribed" && "active"}
${!UserService.Instance.myUserInfo ? "disabled" : "pointer"}
`}
>
<input <input
id={`${this.id}-subscribed`} id={`${this.id}-subscribed`}
type="radio" type="radio"
@ -56,16 +53,20 @@ export class ListingTypeSelect extends Component<
onChange={linkEvent(this, this.handleTypeChange)} onChange={linkEvent(this, this.handleTypeChange)}
disabled={!UserService.Instance.myUserInfo} disabled={!UserService.Instance.myUserInfo}
/> />
{I18NextService.i18n.t("subscribed")} <label
</label> htmlFor={`${this.id}-subscribed`}
title={I18NextService.i18n.t("subscribed_description")}
className={`btn btn-outline-secondary
${this.state.type_ == "Subscribed" && "active"}
${!UserService.Instance.myUserInfo ? "disabled" : "pointer"}
`}
>
{I18NextService.i18n.t("subscribed")}
</label>
</>
)} )}
{this.props.showLocal && ( {this.props.showLocal && (
<label <>
title={I18NextService.i18n.t("local_description")}
className={`pointer btn btn-outline-secondary ${
this.state.type_ == "Local" && "active"
}`}
>
<input <input
id={`${this.id}-local`} id={`${this.id}-local`}
type="radio" type="radio"
@ -74,24 +75,33 @@ export class ListingTypeSelect extends Component<
checked={this.state.type_ == "Local"} checked={this.state.type_ == "Local"}
onChange={linkEvent(this, this.handleTypeChange)} onChange={linkEvent(this, this.handleTypeChange)}
/> />
{I18NextService.i18n.t("local")} <label
</label> htmlFor={`${this.id}-local`}
title={I18NextService.i18n.t("local_description")}
className={`pointer btn btn-outline-secondary ${
this.state.type_ == "Local" && "active"
}`}
>
{I18NextService.i18n.t("local")}
</label>
</>
)} )}
<input
id={`${this.id}-all`}
type="radio"
className="btn-check"
value={"All"}
checked={this.state.type_ == "All"}
onChange={linkEvent(this, this.handleTypeChange)}
/>
<label <label
title={I18NextService.i18n.t("all_description")} title={I18NextService.i18n.t("all_description")}
htmlFor={`${this.id}-all`}
className={`pointer btn btn-outline-secondary ${ className={`pointer btn btn-outline-secondary ${
(this.state.type_ == "All" && "active") || (this.state.type_ == "All" && "active") ||
(!this.props.showLocal && this.state.type_ == "Local" && "active") (!this.props.showLocal && this.state.type_ == "Local" && "active")
}`} }`}
> >
<input
id={`${this.id}-all`}
type="radio"
className="btn-check"
value={"All"}
checked={this.state.type_ == "All"}
onChange={linkEvent(this, this.handleTypeChange)}
/>
{I18NextService.i18n.t("all")} {I18NextService.i18n.t("all")}
</label> </label>
</div> </div>