summaryrefslogtreecommitdiffstats
path: root/toolkit/content/widgets/moz-toggle/moz-toggle.css
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--toolkit/content/widgets/moz-toggle/moz-toggle.css198
1 files changed, 198 insertions, 0 deletions
diff --git a/toolkit/content/widgets/moz-toggle/moz-toggle.css b/toolkit/content/widgets/moz-toggle/moz-toggle.css
new file mode 100644
index 0000000000..1bae09a108
--- /dev/null
+++ b/toolkit/content/widgets/moz-toggle/moz-toggle.css
@@ -0,0 +1,198 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+:host {
+ display: grid;
+ gap: 8px;
+ justify-content: space-between;
+ align-items: center;
+}
+
+:host([disabled]) {
+ opacity: 0.4
+}
+
+.toggle-button,
+.label-wrapper {
+ grid-row: 1;
+}
+
+.description-wrapper {
+ color: var(--text-color-deemphasized);
+}
+
+.description-wrapper,
+.description-wrapper ::slotted([slot="support-link"]) {
+ grid-row: 2;
+ font-size: var(--in-content-font-body-size-small);
+ line-height: 1.25;
+ margin: 0;
+ grid-column: 1 / -1;
+}
+
+.toggle-button {
+ --toggle-background-color: var(--button-background-color);
+ --toggle-background-color-hover: var(--button-background-color-hover);
+ --toggle-background-color-active: var(--button-background-color-active);
+ --toggle-background-color-pressed: var(--color-accent-primary);
+ --toggle-background-color-pressed-hover: var(--color-accent-primary-hover);
+ --toggle-background-color-pressed-active: var(--color-accent-primary-active);
+ --toggle-border-color: var(--border-interactive-color);
+ --toggle-border-radius: var(--border-radius-circle);
+ --toggle-border-width: var(--border-width);
+ --toggle-height: var(--size-item-small);
+ --toggle-width: var(--size-item-large);
+ --toggle-dot-background-color: var(--toggle-border-color);
+ --toggle-dot-background-color-on-pressed: var(--color-canvas);
+ --toggle-dot-margin: 1px;
+ --toggle-dot-height: calc(var(--toggle-height) - 2 * var(--toggle-dot-margin) - 2 * var(--toggle-border-width));
+ --toggle-dot-width: var(--toggle-dot-height);
+ --toggle-dot-transform-x: calc(var(--toggle-width) - 4 * var(--toggle-dot-margin) - var(--toggle-dot-width));
+}
+
+.toggle-button {
+ appearance: none;
+ padding: 0;
+ margin: 0;
+ border: var(--toggle-border-width) solid var(--toggle-border-color);
+ height: var(--toggle-height);
+ width: var(--toggle-width);
+ border-radius: var(--toggle-border-radius);
+ background: var(--toggle-background-color);
+ box-sizing: border-box;
+}
+
+.toggle-button:focus-visible {
+ outline: var(--focus-outline);
+ outline-offset: var(--focus-outline-offset);
+}
+
+.toggle-button:enabled:hover {
+ background: var(--toggle-background-color-hover);
+ border-color: var(--toggle-border-color);
+}
+
+.toggle-button:enabled:active {
+ background: var(--toggle-background-color-active);
+ border-color: var(--toggle-border-color);
+}
+
+.toggle-button[aria-pressed="true"] {
+ background: var(--toggle-background-color-pressed);
+ border-color: transparent;
+}
+
+.toggle-button[aria-pressed="true"]:enabled:hover {
+ background: var(--toggle-background-color-pressed-hover);
+ border-color: transparent;
+}
+
+.toggle-button[aria-pressed="true"]:enabled:active {
+ background: var(--toggle-background-color-pressed-active);
+ border-color: transparent;
+}
+
+.toggle-button::before {
+ display: block;
+ content: "";
+ background-color: var(--toggle-dot-background-color);
+ height: var(--toggle-dot-height);
+ width: var(--toggle-dot-width);
+ margin: var(--toggle-dot-margin);
+ border-radius: var(--toggle-border-radius);
+ translate: 0;
+}
+
+.toggle-button[aria-pressed="true"]::before {
+ translate: var(--toggle-dot-transform-x);
+ background-color: var(--toggle-dot-background-color-on-pressed);
+}
+
+.toggle-button[aria-pressed="true"]:enabled:hover::before,
+.toggle-button[aria-pressed="true"]:enabled:active::before {
+ background-color: var(--toggle-dot-background-color-on-pressed);
+}
+
+.toggle-button[aria-pressed="true"]:-moz-locale-dir(rtl)::before,
+.toggle-button[aria-pressed="true"]:dir(rtl)::before {
+ translate: calc(-1 * var(--toggle-dot-transform-x));
+}
+
+@media (prefers-reduced-motion: no-preference) {
+ .toggle-button::before {
+ transition: translate 100ms;
+ }
+}
+
+@media (prefers-contrast) {
+ :host([disabled]) {
+ opacity: 1;
+ }
+
+ :host([disabled]) > .toggle-button[aria-pressed="true"],
+ :host([disabled]) > .toggle-button {
+ background-color: var(--toggle-background-color-disabled);
+ border-color: var(--toggle-border-color-disabled);
+ }
+
+ :host([disabled]) > .toggle-button[aria-pressed="false"]::before,
+ :host([disabled]) > .toggle-button[aria-pressed="true"]::before {
+ background-color: var(--toggle-background-color-disabled);
+ }
+
+ .toggle-button {
+ --toggle-dot-background-color: var(--color-accent-primary);
+ --toggle-dot-background-color-hover: var(--color-accent-primary-hover);
+ --toggle-dot-background-color-active: var(--color-accent-primary-active);
+ --toggle-dot-background-color-on-pressed: var(--button-background-color);
+ --toggle-background-color-disabled: var(--button-background-color-disabled);
+ --toggle-border-color-hover: var(--border-interactive-color-hover);
+ --toggle-border-color-active: var(--border-interactive-color-active);
+ --toggle-border-color-disabled: var(--border-interactive-color-disabled);
+ }
+
+ .toggle-button:enabled:hover {
+ border-color: var(--toggle-border-color-hover);
+ }
+
+ .toggle-button:enabled:active {
+ border-color: var(--toggle-border-color-active);
+ }
+
+ .toggle-button[aria-pressed="true"]:enabled {
+ border-color: var(--toggle-border-color);
+ position: relative;
+ }
+
+ .toggle-button[aria-pressed="true"]:enabled:hover,
+ .toggle-button[aria-pressed="true"]:enabled:hover:active {
+ border-color: var(--toggle-border-color-hover);
+ }
+
+ .toggle-button[aria-pressed="true"]:enabled:active {
+ background-color: var(--toggle-dot-background-color-active);
+ border-color: var(--toggle-dot-background-color-hover);
+ }
+
+ .toggle-button[aria-pressed="true"]:enabled::after {
+ border: 1px solid var(--button-background-color);
+ content: '';
+ position: absolute;
+ height: var(--toggle-height);
+ width: var(--toggle-width);
+ display: block;
+ border-radius: var(--toggle-border-radius);
+ inset: -2px;
+ }
+
+ .toggle-button[aria-pressed="true"]:enabled:active::after {
+ border-color: var(--toggle-border-color-active);
+ }
+
+ .toggle-button:hover::before,
+ .toggle-button:hover:active::before,
+ .toggle-button:active::before {
+ background-color: var(--toggle-dot-background-color-hover);
+ }
+}