codeforamerica/ohana-web-search

View on GitHub
app/assets/stylesheets/components/_input-search.scss

Summary

Maintainability
Test Coverage
// Form input styles.

// Search.
// Reset browser-specific added styles.
@include reset-input-webkit();
@include reset-input-ie();

.input-search-small {
  @include input-placeholder(rgba($white, 0.6), italic);
  position:relative;

  input:focus {
    outline: none;
  }

  > input {
    font-size: $font_size_105;
    margin-left: 0;
    height: 45px;
    padding: 3px;
    padding-left: 45px;
    padding-right: 25px;
    width: 100%;
    vertical-align: bottom;

    border-collapse: collapse;
    border: none;
    background: none;
    border-bottom: 1px solid $primary-dark;
    @include single-box-shadow(0, 1px, 6px, 1px, rgba($black, 0.1), inset);
    @include box-sizing(border-box);
    color: $white;
  }

  > .button-icon {
    cursor: pointer;
    background: none;
    border: none;
    margin: 0;
    margin-left: 5px;
    padding: 10px;
    @include box-sizing(border-box);
    vertical-align: baseline;
    font-family: $font_serif;
    font-size: $font_size_110;
    line-height: 0;
    height: 40px;
    min-width: 34px;
    border-collapse: collapse;
    position: absolute;
    left: 0;
    top: 0;
    z-index: $layer-8;

    >.fa {
      color: $primary-darkest;
    }

    &:hover {
      > .fa {
        color: $primary-dark;
        // color: $button-hover-color;
      }
    }
  }
}

.input-search-big {
  @include input-placeholder(midtone($black, 0.2), italic);
  position: relative;
  width: 440px;

  input:focus {
    outline: none;
  }

  > input {
    padding-left: 45px;
    width: 100%;

    border-collapse: collapse;
    @include box-sizing(border-box);
    @include rounded-except(none);

    height: 50px;
    padding: 10px;
    padding-right: 144px;
    margin:0;
    font-size: $font_size_110;
    vertical-align:middle;
    background: $white;
    @include border-radius(4px);
    border:1px solid rgba($input-border-color, 0.4);
    color: $black;
  }

  > .button-icon {
    position: absolute;
    top: 0;
    right: 0;
    left: auto;
    z-index: $layer-8;
    height: 50px;
    min-width: 134px;
    margin: 0;
    margin-left: 5px;
    padding: 10px;
    border-collapse: collapse;
    @include box-sizing(border-box);
    @include rounded-except(left);

    border: 1px solid rgba($input-border-color, 0.4);
    border-left: 1px solid rgba($input-border-color, 0.2);
    background: $button-bg;

    font-size: $font_size_115;
    vertical-align: baseline;
    font-family: $font_serif;
    line-height: 0;
    letter-spacing: 1px;

    cursor: pointer;

    > span {
      @include inline-block();
      color: $black; // IE fallback
      color: midtone($black, .5);
      text-shadow: 1px 4px 6px $accentA-light, 0 0 0 $black, 1px 4px 6px $accentA-light;
      line-height: 20px; // Needed by Opera to handle vertical-align:middle properly
      color: $button-color;
    }

    >.fa {
      color: $button-fa-color;
    }

    &:hover {
      background: $button-hover-bg;

      >span {
        text-shadow: none;
        color: $button-hover-color;
      }

      >.fa {
        color: $button-fa-color;
      }
    }
  }
}

.input-search-filter {
  @include input-placeholder(rgba($white, 0.6), italic);
  position: relative;

  > label {
    font-size: $font_size_90;
    color: rgba($black, 0.5);
  }

  > .filter-input-group {
    > .button-icon {
      font-size: $font_size_110;
      position: absolute;
      z-index: $layer-8;
      margin-left: 3px;
      padding: 0;
      border: none;
      background: none;
      color: $search-button-color;
      width: 30px;
      height: 40px;
      text-align: center;
      cursor: pointer;

      &:hover {
        color: $search-button-hover-color;
      }
    }

    > input {
      width: 100%;
      height: 40px;
      padding-left: 35px;
      padding-right: 25px;
      @include box-sizing(border-box);
      @include single-box-shadow(0, 1px, 6px, 1px, rgba($black, 0.1), inset);
      @include rounded-except(none);
      border: none;
      border-bottom: 1px solid rgba($white, 0.7);
      border-collapse: collapse;
      -webkit-appearance: none; // Remove rounding styling of input fields on iOS.
      font-size: $font_size_95;
      background: $primary;
      color: $white;
    }

    > input:focus {
      outline: none;
    }
  }
}

.input-search-filter.input-search-filter-option {
  > .filter-input-group > input {
    @include rounded-except(upper-right);
  }

  .input-search-filter-option {
    font-size: $font_size_95;
    border: none;
    margin: 0;
    padding: 3px;
    padding-top: 0;
    padding-bottom: 0;
    max-height: 23px;
    background: rgba($white, 0.3);
    border: 1px solid rgba($white, 0);
    cursor: pointer;
    @include rounded-except(bottom);

    > span {
      color: $black; // IE fallback
      color: midtone($black, 0.5);
    }

    > .fa {
      color: $input-fa-color;
    }

    &:hover {
      background: $search-button-hover-background;
      border: 1px solid rgba($input-border-color, 0.2);
      border-bottom: 1px solid rgba($white, 0.3);

      .fa {
        color: $search-button-fa-hover-color;
      }
    }

    // Prevent hover state appearance when 'disabled' attribute is present.
    &[disabled] {
      background: rgba($white, 0.3);
      border: 1px solid rgba($white, 0);
      cursor: auto;

      .fa {
        color: $input-fa-color;
      }
    }
  }
}

// Clearable input fields have a (x) that can be clicked for clearing the
// field's content.
.clearable {
  position: relative;

  &:hover {
    .button-clear {
      color: rgba($black, .4);
    }
  }

  .button-clear {
    position: absolute;
    right: 0;
    top: 50%;
    margin-top: -15px;

    color: $greyscale_midtone; // IE Fallback
    color: rgba($black, .1);
    font-size: $font_size_110;

    border-collapse: collapse;
    border: none;
    outline: none;
    background: transparent;
  }

  .button-clear::after {
    content: "×";
  }

  .button-clear:hover {
    color: $black;
    cursor: pointer;
  }
}