Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make icons change layout too [#1911] #1912

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions src/components/controls/panel-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,31 @@ class PanelLayouts extends React.Component {

return (
<div style={{marginTop: 0, marginBottom: 10}}>
<PanelsFullIcon width={22} selected={this.props.panelLayout === "full"}/>
<SidebarButton
selected={this.props.panelLayout === "full"}
<span
style={{cursor: "pointer"}}
onClick={() => {
analyticsControlsEvent("change-layout-full");
this.props.dispatch({ type: CHANGE_PANEL_LAYOUT, data: "full" });
}}
>
<ButtonText>{t("sidebar:full")}</ButtonText>
</SidebarButton>
<PanelsFullIcon width={22} selected={this.props.panelLayout === "full"}/>
<SidebarButton selected={this.props.panelLayout === "full"}>
<ButtonText>{t("sidebar:full")}</ButtonText>
</SidebarButton>
Comment on lines +37 to +40
Copy link
Member

@victorlin victorlin Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nit)

A button nested in a clickable span is presented as two separate selectable items to a screen reader (or Vimium in my case). This is what I see on the PR review app:

image

By placing the icon within the button instead (and adjusting styles), the same desired effect can be achieved while maintaining a single selectable item:

image

<SidebarButton
  selected={this.props.panelLayout === "full"}
  style={{cursor: "pointer"}}
  onClick={}
>
  <PanelsFullIcon width={22} selected={this.props.panelLayout === "full"}/>
  <ButtonText>{t("sidebar:full")}</ButtonText>
</SidebarButton>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By placing the icon within the button instead

Yeah, I tried that, the styling got janky. I will look at it again tomorrow.

</span>

<PanelsGridIcon width={22} selected={this.props.panelLayout === "grid"}/>
<SidebarButton
selected={this.props.panelLayout === "grid"}
<span
style={{cursor: "pointer"}}
onClick={() => {
analyticsControlsEvent("change-layout-grid");
this.props.dispatch({ type: CHANGE_PANEL_LAYOUT, data: "grid" });
}}
>
<ButtonText>{t("sidebar:grid")}</ButtonText>
</SidebarButton>
<PanelsGridIcon width={22} selected={this.props.panelLayout === "grid"}/>
<SidebarButton selected={this.props.panelLayout === "grid"} >
<ButtonText>{t("sidebar:grid")}</ButtonText>
</SidebarButton>
</span>

</div>
);
Expand Down
Loading