_forms.scss 2.71 KB
Newer Older
1
2
3
// Form control focus state
//
// Generate a customized focus state and for any input with the specified color,
4
// which defaults to the `$input-focus-border-color` variable.
5
6
7
8
9
10
11
12
//
// We highly encourage you to not customize the default value, but instead use
// this to tweak colors on an as-needed basis. This aesthetic change is based on
// WebKit's default styles, but applicable to a wider range of browsers. Its
// usability and accessibility should be taken into account with any change.
//
// Example usage: change the default blue border and shadow to white for better
// contrast against a dark gray background.
Mark Otto's avatar
Mark Otto committed
13
@mixin form-control-focus() {
14
  &:focus {
15
16
17
    color: $input-focus-color;
    background-color: $input-focus-bg;
    border-color: $input-focus-border-color;
18
    outline: none;
Mark Otto's avatar
Mark Otto committed
19
20
21
22
23
24
    // Avoid using mixin so we can pass custom focus shadow properly
    @if $enable-shadows {
      box-shadow: $input-box-shadow, $input-btn-focus-box-shadow;
    } @else {
      box-shadow: $input-btn-focus-box-shadow;
    }
25
26
  }
}
27
28
29
30


@mixin form-validation-state($state, $color) {

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
  .#{$state}-feedback {
    display: none;
    margin-top: .25rem;
    font-size: .875rem;
    color: $color;
  }

  .#{$state}-tooltip {
    position: absolute;
    top: 100%;
    z-index: 5;
    display: none;
    width: 250px;
    padding: .5rem;
    margin-top: .1rem;
    font-size: .875rem;
    line-height: 1;
    color: #fff;
49
    background-color: rgba($color, .8);
50
51
52
    border-radius: .2rem;
  }

53
54
55
56
57
58
59
  .form-control,
  .custom-select {
    .was-validated &:#{$state},
    &.is-#{$state} {
      border-color: $color;

      &:focus {
60
        box-shadow: 0 0 0 $input-btn-focus-width rgba($color, .25);
61
62
      }

63
64
      ~ .#{$state}-feedback,
      ~ .#{$state}-tooltip {
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
        display: block;
      }
    }
  }


  // TODO: redo check markup lol crap
  .form-check-input {
    .was-validated &:#{$state},
    &.is-#{$state} {
      + .form-check-label {
        color: $color;
      }
    }
  }

  // custom radios and checks
  .custom-control-input {
    .was-validated &:#{$state},
    &.is-#{$state} {
      ~ .custom-control-indicator {
86
        background-color: rgba($color, .4);
Sharrell Porter's avatar
Sharrell Porter committed
87
      }
88
89
90
      ~ .custom-control-description {
        color: $color;
      }
Mark Otto's avatar
Mark Otto committed
91
92
      &:focus {
        ~ .custom-control-indicator {
93
          box-shadow: 0 0 0 1px $body-bg, 0 0 0 $input-btn-focus-width rgba($color, .25);
Mark Otto's avatar
Mark Otto committed
94
95
        }
      }
96
97
98
99
100
101
102
103
104
105
106
107
108
    }
  }

  // custom file
  .custom-file-input {
    .was-validated &:#{$state},
    &.is-#{$state} {
      ~ .custom-file-control {
        border-color: $color;

        &::before { border-color: inherit; }
      }
      &:focus {
Mark Otto's avatar
Mark Otto committed
109
110
111
        ~ .custom-file-control {
          box-shadow: 0 0 0 $input-btn-focus-width rgba($color, .25);
        }
112
113
114
115
      }
    }
  }
}