Skip to content

A games launcher for GOG, Amazon and Epic Games for Linux, Windows and macOS.

3.3 KB
Raw Blame
.ToggleSwitch {
  position: relative;
}

/* Keep the input focusable but give it the track's geometry: spatial
   navigation starts from the focused element's box, and a 1x1 clipped input
   sends the cursor to whatever is nearest that corner instead of the switch. */
.ToggleSwitch__input {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-end: 0;
  transform: translateY(-50%);
  width: 46px;
  height: 26px;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.ToggleSwitch__track {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  width: 46px;
  height: 26px;
  padding: var(--space-2xs-fixed);
  border-radius: 999px;
  background: var(--input-background);
  border: 1px solid
    color-mix(
      in oklab,
      var(--on-panel, var(--text-default)) 52%,
      var(--panel-base)
    );
  cursor: pointer;
  transition:
    background-color 160ms ease,
    border-color 160ms ease;
}

.ToggleSwitch__thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--on-panel, var(--text-default));
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  transition:
    transform 160ms ease,
    background-color 160ms ease;
}

.ToggleSwitch__input:checked + .ToggleSwitch__track {
  background: var(--navbar-accent, var(--accent));
  border-color: var(--navbar-accent, var(--accent));
}

.ToggleSwitch__input:checked + .ToggleSwitch__track .ToggleSwitch__thumb {
  transform: translateX(20px);
  background: var(--ink-on-accent, var(--background-darker));
}

/* A checkbox that controls a list is mixed: partially filled track, and the
   thumb keeps its position with a dash instead of the "on" accent dot. */
.ToggleSwitch__input:indeterminate + .ToggleSwitch__track {
  background: color-mix(
    in oklab,
    var(--navbar-accent, var(--accent)) 32%,
    var(--input-background)
  );
  border-color: var(--navbar-accent, var(--accent));
}

.ToggleSwitch__input:indeterminate + .ToggleSwitch__track .ToggleSwitch__thumb {
  position: relative;
  transform: none;
  background: var(--navbar-accent, var(--accent));
}

.ToggleSwitch__input:indeterminate
  + .ToggleSwitch__track
  .ToggleSwitch__thumb::after {
  content: '';
  position: absolute;
  inset-block-start: 50%;
  inset-inline: 5px;
  height: 2px;
  border-radius: 1px;
  background: var(--ink-on-accent, var(--background-darker));
  transform: translateY(-50%);
}

@media (forced-colors: active) {
  .ToggleSwitch__input:indeterminate + .ToggleSwitch__track {
    background: Canvas;
    border-color: CanvasText;
  }

  .ToggleSwitch__input:indeterminate
    + .ToggleSwitch__track
    .ToggleSwitch__thumb {
    background: CanvasText;
  }

  .ToggleSwitch__input:indeterminate
    + .ToggleSwitch__track
    .ToggleSwitch__thumb::after {
    background: Canvas;
  }
}

.isRTL
  .ToggleSwitch__input:checked
  + .ToggleSwitch__track
  .ToggleSwitch__thumb {
  transform: translateX(-20px);
}

.ToggleSwitch__input:focus-visible + .ToggleSwitch__track,
.gamepad-active .ToggleSwitch__input:focus + .ToggleSwitch__track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.ToggleSwitch--disabled .SettingRow__label,
.ToggleSwitch--disabled .SettingRow__description {
  color: var(--on-panel-muted, var(--text-secondary));
}

.ToggleSwitch--disabled .ToggleSwitch__track {
  cursor: not-allowed;
  opacity: 0.5;
}

.ToggleSwitch.fading {
  animation: fadeIn 300ms ease;
}