summaryrefslogtreecommitdiffstats
path: root/toolkit/content/widgets/moz-toggle/moz-toggle.css
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /toolkit/content/widgets/moz-toggle/moz-toggle.css
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/content/widgets/moz-toggle/moz-toggle.css')
-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..8b67a81878
--- /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/. */
+
+@import url("chrome://global/skin/design-system/text-and-typography.css");
+
+:host {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+}
+
+:host([disabled]) {
+ opacity: 0.4
+}
+
+::slotted(a[is="moz-support-link"]) {
+ display: inline-block;
+}
+
+#moz-toggle-label {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ gap: 8px;
+}
+
+.description-wrapper,
+.description-wrapper ::slotted([slot="support-link"]) {
+ margin: 0;
+}
+
+.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;
+ flex-shrink: 0;
+}
+
+.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);
+ }
+}