Skip to content
Snippets Groups Projects
Commit d558ef62 authored by henry's avatar henry Committed by Pier Angelo Vendrame
Browse files

Customize moz-toggle for tor-browser.

parent 005f542c
Branches
Tags
1 merge request!1500TB 43415: Rebased onto 134.0a1
......@@ -29,6 +29,10 @@ export default class MozToggle extends MozLitElement {
description: { type: String },
ariaLabel: { type: String, attribute: "aria-label" },
accessKey: { type: String, mapped: true },
// Extension for tor-browser. Used for tor-browser#41333.
title: { type: String, attribute: "title" },
// Extension for tor-browser. Used for tor-browser#40837.
labelAlignAfter: { type: Boolean, attribute: "label-align-after" },
};
static get queries() {
......@@ -86,6 +90,12 @@ export default class MozToggle extends MozLitElement {
buttonTemplate() {
const { pressed, disabled, description, ariaLabel, handleClick } = this;
// For tor-browser, if we have a title we use it as the aria-description.
// Used for tor-browser#41333.
// Only set the description using the title if it differs from the
// accessible name derived from the label.
const label = ariaLabel || this.label;
const ariaDescription = label === this.title ? undefined : this.title;
return html`
<button
id="moz-toggle-button"
......@@ -95,6 +105,7 @@ export default class MozToggle extends MozLitElement {
?disabled=${disabled}
aria-pressed=${pressed}
aria-label=${ifDefined(ariaLabel ?? undefined)}
aria-description=${ifDefined(ariaDescription ?? undefined)}
aria-describedby=${ifDefined(
description ? "moz-toggle-description" : undefined
)}
......@@ -105,6 +116,11 @@ export default class MozToggle extends MozLitElement {
}
render() {
// For tor-browser, we want to be able to place the label after the toggle
// as well.
// Used for the enable-bridges switch tor-browser#40837.
const labelAlignAfter = this.labelAlignAfter;
return html`
<link
rel="stylesheet"
......@@ -119,11 +135,12 @@ export default class MozToggle extends MozLitElement {
for="moz-toggle-button"
shownaccesskey=${ifDefined(this.accessKey)}
>
${labelAlignAfter ? this.buttonTemplate() : ""}
<span>
${this.label}
${!this.description ? this.supportLinkTemplate() : ""}
</span>
${this.buttonTemplate()}
${labelAlignAfter ? "" : this.buttonTemplate()}
</label>
`
: this.buttonTemplate()}
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment