<commit_before>//
// Copyright 2021 Google LLC
// SPDX-License-Identifier: Apache-2.0
//

// stylelint-disable selector-class-pattern --
// Selector '.md3-*' should only be used in this project.

// PUBLIC PROPERTIES

@use '../../motion/animation';
@use '../../sass/touch-target';

// TODO(b/230768994): update animation timing
$animation-duration: 75ms;
$icon-exit-duration: 0.4 * $animation-duration;
$icon-enter-duration: $animation-duration - $icon-exit-duration;

// PUBLIC API

@mixin static-styles() {
  :host {
    display: inline-flex;
    outline: none;
    -webkit-tap-highlight-color: transparent;
  }

  .md3-switch {
    @include _root;
  }

  // Track
  .md3-switch__track {
    @include _track;

    &::before {
      @include _track-before;

      .md3-switch--selected & {
        @include _track-selected-before;
      }
    }
  }

  // Handle container
  .md3-switch__handle-container {
    @include _handle-container;
  }

  // Handle
  .md3-switch__handle {
    @include _handle;

    &::before {
      @include _handle-before;

      .md3-switch--selected & {
        @include _handle-selected-before;
      }
    }
  }

  // Icons
  .md3-switch__icons {
    @include _icons;
  }

  .md3-switch__icon {
    @include _icon;
    @include _icon-hidden;
  }

  .md3-switch--selected .md3-switch__icon--on,
  .md3-switch--unselected .md3-switch__icon--off {
    @include _icon-visible;
  }

  // Touch target
  .md3-switch__touch {
    @include touch-target.touch-target();
  }

  // Disabled
  .md3-switch:disabled {
    @include _disabled;
  }

  // Disabled - Track
  .md3-switch__track {
    .md3-switch:disabled & {
      background-color: transparent;
      border-color: transparent;

      &::before {
        background-clip: content-box;
      }
    }
    .md3-switch--selected:disabled & {
      background-clip: border-box;
    }
  }

  input {
    @include _input;
  }
}

// PRIVATE API

@mixin _root() {
  align-items: center;
  background: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  flex-shrink: 0; // Stop from collapsing in flex containers
  margin: 0;
  outline: none;
  padding: 0;
  position: relative;
}

@mixin _disabled() {
  cursor: default;
  pointer-events: none;
}

@mixin _track() {
  position: relative;
  width: 100%;
  height: 100%;
  box-sizing: border-box;

  border-radius: inherit;

  // Center content
  display: flex;
  justify-content: center;
  align-items: center;
}

@mixin _track-before() {
  @include _before-base();

  border-style: solid;
}

// When selected, turn off ::before
@mixin _track-selected-before() {
  opacity: 0;
}

@mixin _handle-container() {
  position: relative;
}

@mixin _handle() {
  transition-property: transform margin-inline-start margin-inline-end;
  transition-duration: #{$animation-duration};
  transition-timing-function: animation.$standard-easing;

  transform-origin: center;
}

@mixin _handle-before() {
  @include _before-base();
}

@mixin _before-base() {
  content: '';
  display: flex;
  position: absolute;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  box-sizing: border-box;

  transition-property: opacity;
  transition-duration: #{$animation-duration};
}

// When selected, turn off ::before
@mixin _handle-selected-before() {
  opacity: 0;
}

@mixin _icons() {
  position: relative;
  height: 100%;
  width: 100%;
}

@mixin _icon() {
  position: absolute;
  inset: 0;
  margin: auto;
}

@mixin _icon-hidden() {
  opacity: 0;<commit_msg>refactor(switch): use animation mixin for css transitions<commit_after>//
// Copyright 2021 Google LLC
// SPDX-License-Identifier: Apache-2.0
//

// stylelint-disable selector-class-pattern --
// Selector '.md3-*' should only be used in this project.

// PUBLIC PROPERTIES

@use '../../motion/animation';
@use '../../sass/touch-target';

// TODO(b/230768994): update animation timing
$animation-duration: 75ms;
$icon-exit-duration: 0.4 * $animation-duration;
$icon-enter-duration: $animation-duration - $icon-exit-duration;

// PUBLIC API

@mixin static-styles() {
  :host {
    display: inline-flex;
    outline: none;
    -webkit-tap-highlight-color: transparent;
  }

  .md3-switch {
    @include _root;
  }

  // Track
  .md3-switch__track {
    @include _track;

    &::before {
      @include _track-before;

      .md3-switch--selected & {
        @include _track-selected-before;
      }
    }
  }

  // Handle container
  .md3-switch__handle-container {
    @include _handle-container;
  }

  // Handle
  .md3-switch__handle {
    @include _handle;

    &::before {
      @include _handle-before;

      .md3-switch--selected & {
        @include _handle-selected-before;
      }
    }
  }

  // Icons
  .md3-switch__icons {
    @include _icons;
  }

  .md3-switch__icon {
    @include _icon;
    @include _icon-hidden;
  }

  .md3-switch--selected .md3-switch__icon--on,
  .md3-switch--unselected .md3-switch__icon--off {
    @include _icon-visible;
  }

  // Touch target
  .md3-switch__touch {
    @include touch-target.touch-target();
  }

  // Disabled
  .md3-switch:disabled {
    @include _disabled;
  }

  // Disabled - Track
  .md3-switch__track {
    .md3-switch:disabled & {
      background-color: transparent;
      border-color: transparent;

      &::before {
        background-clip: content-box;
      }
    }
    .md3-switch--selected:disabled & {
      background-clip: border-box;
    }
  }

  input {
    @include _input;
  }
}

// PRIVATE API

@mixin _root() {
  align-items: center;
  background: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  flex-shrink: 0; // Stop from collapsing in flex containers
  margin: 0;
  outline: none;
  padding: 0;
  position: relative;
}

@mixin _disabled() {
  cursor: default;
  pointer-events: none;
}

@mixin _track() {
  position: relative;
  width: 100%;
  height: 100%;
  box-sizing: border-box;

  border-radius: inherit;

  // Center content
  display: flex;
  justify-content: center;
  align-items: center;
}

@mixin _track-before() {
  @include _before-base();

  border-style: solid;
}

// When selected, turn off ::before
@mixin _track-selected-before() {
  opacity: 0;
}

@mixin _handle-container() {
  position: relative;
  transition: animation.standard(margin, $animation-duration);
}

@mixin _handle() {
  transform-origin: center;
  transition: animation.standard(transform, $animation-duration);
}

@mixin _handle-before() {
  @include _before-base();
}

@mixin _before-base() {
  content: '';
  display: flex;
  position: absolute;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  box-sizing: border-box;

  transition-property: opacity;
  transition-duration: #{$animation-duration};
}

// When selected, turn off ::before
@mixin _handle-selected-before() {
  opacity: 0;
}

@mixin _icons() {
  position: relative;
  height: 100%;
  width: 100%;
}

@mixin _icon() {
  position: absolute;
  inset: 0;
  margin: auto;

  transition-property: fill;
  transition-duration: #{$animation-duration};
}

@mixin _icon-hidden() {
  opacity: 0;
{'fraction_non_alphanumeric': 0.14765291607396872, 'fraction_numerical': 0.01763869132290185, 'mean_word_length': 2.810840108401084, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3848613', 'n_tokens_mistral': 2548, 'n_tokens_neox': 2410, 'n_words': 517}