Skip to content

Commit

Permalink
fix: Fix focus ring styles for home toggles LemmyNet#1772
Browse files Browse the repository at this point in the history
  • Loading branch information
jsit committed Jul 3, 2023
1 parent 8e20d16 commit acfbe99
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 40 deletions.
35 changes: 21 additions & 14 deletions src/shared/components/common/data-type-select.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { randomStr } from "@utils/helpers";
import { Component, linkEvent } from "inferno";
import { DataType } from "../../interfaces";
import { I18NextService } from "../../services";
Expand All @@ -15,6 +16,8 @@ export class DataTypeSelect extends Component<
DataTypeSelectProps,
DataTypeSelectState
> {
private id = `listing-type-input-${randomStr()}`;

state: DataTypeSelectState = {
type_: this.props.type_,
};
Expand All @@ -32,32 +35,36 @@ export class DataTypeSelect extends Component<
render() {
return (
<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
htmlFor={`${this.id}-posts`}
className={`pointer btn btn-outline-secondary
${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")}
</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
htmlFor={`${this.id}-comments`}
className={`pointer btn btn-outline-secondary ${
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")}
</label>
</div>
Expand Down
62 changes: 36 additions & 26 deletions src/shared/components/common/listing-type-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,12 @@ export class ListingTypeSelect extends Component<

render() {
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 && (
<label
title={I18NextService.i18n.t("subscribed_description")}
className={`btn btn-outline-secondary
${this.state.type_ == "Subscribed" && "active"}
${!UserService.Instance.myUserInfo ? "disabled" : "pointer"}
`}
>
<>
<input
id={`${this.id}-subscribed`}
type="radio"
Expand All @@ -56,16 +53,20 @@ export class ListingTypeSelect extends Component<
onChange={linkEvent(this, this.handleTypeChange)}
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 && (
<label
title={I18NextService.i18n.t("local_description")}
className={`pointer btn btn-outline-secondary ${
this.state.type_ == "Local" && "active"
}`}
>
<>
<input
id={`${this.id}-local`}
type="radio"
Expand All @@ -74,24 +75,33 @@ export class ListingTypeSelect extends Component<
checked={this.state.type_ == "Local"}
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
title={I18NextService.i18n.t("all_description")}
htmlFor={`${this.id}-all`}
className={`pointer btn btn-outline-secondary ${
(this.state.type_ == "All" && "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")}
</label>
</div>
Expand Down

0 comments on commit acfbe99

Please sign in to comment.