ernestwisniewski/kbin

View on GitHub
assets/styles/components/_settings_row.scss

Summary

Maintainability
Test Coverage
.settings-row {
  display: grid;
  grid-template-areas: "label value";
  grid-template-columns: auto;
  align-items: center;
  width: 100%;
  background: var(--kbin-sidebar-settings-row-bg);

  &:nth-child(7),
  &:nth-child(13),
  &:nth-child(15) {
    .rounded-edges & {
    border-bottom-left-radius: .375rem;
    border-bottom-right-radius: .375rem;
    overflow: clip;
    }
  }

  &[data-controller="settings-row-enum"] {
    grid-template-areas: "label value";
  }

  .label {
    grid-area: label;
    line-height: normal;
    height: 100%;
    align-items: center;
    display: flex;
    margin-left: .375rem;
  }

  .help {
    display: none;
  }

  .value-container {
    display: flex;
    justify-content: end;
    width: 100%;
    padding: 4px 6px;
    line-height: normal;
    flex-grow: 1;
    grid-area: value;

    .link-muted.active {
      color: var(--kbin-primary);
      font-weight: 800 !important;
    }

    /** Enum Settings row **/
    .enum {
      display: flex;
      align-items: center;
      text-align: center;
      background-color: var(--kbin-sidebar-settings-switch-off-bg);
      overflow: clip;
      font-size: .8em;
      box-shadow: 0 .0625rem hsla(0,0%,100%,.08);

      .rounded-edges & {
        border-radius: var(--kbin-rounded-edges-radius);
      }

      input {
        display: none;
      }

      .value {
        cursor: pointer;

        span {
          min-width: 3rem;
          height: 100%;
          display: block;
          padding: .25rem .25rem;
          font-weight: 400;
          color: var(--kbin-button-secondary-text-color);
          transition: color .25s, background-color .25s, font-weight .15s;
        }

        &:hover {
          input:checked + span {
            background: var(--kbin-sidebar-settings-switch-hover-bg);
            color: var(--kbin-button-primary-hover-text-color);
          }

          span {
            background: var(--kbin-sidebar-settings-switch-hover-bg);
            color: var(--kbin-button-secondary-text-hover-color);
          }
        }
      }

      input:checked + span {
        background: var(--kbin-sidebar-settings-switch-on-bg);
        color: var(--kbin-sidebar-settings-switch-on-color);
        font-weight: 800;
      }
    }

    /** Button Settings row **/
    button {
      background: var(--kbin-button-primary-bg);
      color: var(--kbin-button-primary-text-color);
      border: var(--kbin-button-primary-border);
      cursor: pointer;
      font-size: 0.8em;

      .rounded-edges & {
        border-radius: var(--kbin-rounded-edges-radius);
      }

      &:hover {
        background: var(--kbin-button-primary-hover-bg);
        color: var(--kbin-button-primary-hover-text-color);
      }
    }

    /** Switch Settings row **/
    .switch {

      .rounded-edges & {
        border-radius: .75rem;
      }

      input {
        display: none;
      }
    }

    .slider {
      cursor: pointer;
      background-color: var(--kbin-sidebar-settings-switch-off-bg);
      transition: .25s;
      display: block;
      height: 1.25rem;
      width: 2rem;
      border: .125rem solid var(--kbin-sidebar-settings-switch-off-bg);
      box-shadow: 0px .0625rem hsla(0, 0%, 100%, .08);

      .rounded-edges & {
        border-radius: .75rem;
      }

      &:hover {
        background-color: var(--kbin-sidebar-settings-switch-hover-bg);
        border-color: var(--kbin-sidebar-settings-switch-hover-bg);

        &::before {
          background-color: var(--kbin-sidebar-settings-switch-on-color);
        }
      }

      &:before {
        position: absolute;
        content: "";
        height: 1rem;
        width: 1rem;
        background-color: var(--kbin-sidebar-settings-switch-off-color);
        transition: .25s;

        .rounded-edges & {
          border-radius: 50%;
        }
      }
    }

    input:checked + .slider {
      background-color: var(--kbin-sidebar-settings-switch-on-bg);
      border: .125rem solid var(--kbin-sidebar-settings-switch-on-bg);
      box-shadow: 0px -1px hsla(0, 0%, 0%, .1);
    }

    input:checked + .slider:before {
      transform: translateX(.75rem);
      background: var(--kbin-sidebar-settings-switch-on-color);
      box-shadow: inset 0 -.0625rem hsl(0, 0%, 0%, .1);
    }
  }
}