Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 1 | /** |
| 2 | * Copyright 2016 Leif Olsen. All Rights Reserved. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | /* |
| 18 | * The bordered fields are based on / inspired by this CodePen: http://codepen.io/prajwal078/pen/LVJZXz?editors=010 |
| 19 | */ |
| 20 | |
| 21 | // Use of this module requires the user to include variables from material-design-lite |
| 22 | //@import "../../node_modules/material-design-lite/src/variables"; |
| 23 | //@import "../../node_modules/material-design-lite/src/mixins"; |
| 24 | |
| 25 | @import "../variables"; |
| 26 | @import "../functions"; |
| 27 | |
| 28 | |
| 29 | // "Theme" for this styling |
| 30 | .mdlext-bordered-fields { |
| 31 | box-sizing: border-box; |
| 32 | |
| 33 | * { |
| 34 | box-sizing: border-box; |
| 35 | } |
| 36 | |
| 37 | // Styling for textfield and selectfield. |
| 38 | .mdl-textfield, |
| 39 | .mdlext-selectfield { |
| 40 | padding: 0; |
| 41 | margin: $mdlext-bordered-field-vertical-spacing-top 0 $mdlext-bordered-field-vertical-spacing-bottom 0; |
| 42 | |
| 43 | .mdl-textfield__input, |
| 44 | .mdlext-selectfield__select { |
| 45 | height: $mdlext-bordered-field-height; |
| 46 | background-color: $mdlext-bordered-field-background-color; |
| 47 | border: $mdlext-bordered-field-border-width solid $mdlext-bordered-field-border-color; |
| 48 | border-radius: $mdlext-bordered-field-border-radius; |
| 49 | padding: $mdlext-bordered-field-padding-top $mdlext-bordered-field-padding $mdlext-bordered-field-padding-bottom $mdlext-bordered-field-padding; |
| 50 | font-size: $mdlext-bordered-field-input-text-font-size; |
| 51 | font-weight: $mdlext-bordered-field-font-weight; |
| 52 | color: $mdlext-bordered-field-input-text-color; |
| 53 | |
| 54 | &:disabled { |
| 55 | color: $mdlext-bordered-field-input-text-disabled-text-color; |
| 56 | background-color: $mdlext-bordered-field-disabled-background-color; |
| 57 | border-color: $mdlext-bordered-field-disabled-border-color; |
| 58 | } |
| 59 | |
| 60 | // MDL can not handle required attribute properly. Planned for MDL-v2 |
| 61 | //&:required { |
| 62 | // background-color: $mdlext-bordered-field-required-background-color; |
| 63 | // border-color: $mdlext-bordered-field-required-border-color; |
| 64 | //} |
| 65 | |
| 66 | &:focus { |
| 67 | background-color: $mdlext-bordered-field-focus-background-color; |
| 68 | border-color: $mdlext-bordered-field-focus-border-color; |
| 69 | } |
| 70 | |
| 71 | // MDL can not handle required. Planned for MDL-v2 |
| 72 | //&:required:focus { |
| 73 | // background-color: $mdlext-bordered-field-required-focus-background-color; |
| 74 | // border-color: $mdlext-bordered-field-required-focus-border-color; |
| 75 | //} |
| 76 | } |
| 77 | .mdlext-selectfield__select { |
| 78 | padding-right: calc(1em + #{$mdlext-bordered-field-padding}); // space for down arrow |
| 79 | } |
| 80 | |
| 81 | /* |
| 82 | &.is-dirty { |
| 83 | .mdl-textfield__input, |
| 84 | .mdlext-selectfield__select { |
| 85 | } |
| 86 | } |
| 87 | */ |
| 88 | |
| 89 | &.is-invalid { |
| 90 | .mdl-textfield__input, |
| 91 | .mdlext-selectfield__select { |
| 92 | color: $mdlext-bordered-field-input-text-error-color; |
| 93 | border-color: $mdlext-bordered-field-error-border-color; |
| 94 | background-color: $mdlext-bordered-field-error-background-color; |
| 95 | |
| 96 | &:focus { |
| 97 | //&:required:focus { |
| 98 | border-color: $mdlext-bordered-field-error-focus-border-color; |
| 99 | background-color: $mdlext-bordered-field-error-focus-background-color; |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | .mdlext-selectfield::after { |
| 106 | top: auto; |
| 107 | bottom: $mdlext-bordered-field-padding-bottom; // Position of down arrow |
| 108 | } |
| 109 | |
| 110 | fieldset[disabled] .mdlext-selectfield::after, |
| 111 | .mdlext-selectfield.is-disabled::after { |
| 112 | color: $mdlext-bordered-field-input-text-disabled-text-color; |
| 113 | @include mdlext-arrow(bottom, $mdlext-selectfield-arrow-width, $mdlext-selectfield-arrow-length, $mdlext-bordered-field-input-text-disabled-text-color); |
| 114 | } |
| 115 | |
| 116 | |
| 117 | fieldset[disabled] .mdl-textfield .mdl-textfield__input, |
| 118 | fieldset[disabled] .mdlext-selectfield .mdlext-selectfield__select { |
| 119 | color: $mdlext-bordered-field-input-text-disabled-text-color; |
| 120 | background-color: $mdlext-bordered-field-disabled-background-color; |
| 121 | border-color: $mdlext-bordered-field-disabled-border-color; |
| 122 | } |
| 123 | |
| 124 | |
| 125 | // Styling for the label / floating label. |
| 126 | .mdl-textfield, |
| 127 | .mdlext-selectfield { |
| 128 | |
| 129 | &.is-dirty, |
| 130 | &.has-placeholder { |
| 131 | .mdl-textfield__label, |
| 132 | .mdlext-selectfield__label { |
| 133 | visibility: hidden; |
| 134 | } |
| 135 | } |
| 136 | .mdl-textfield__label, |
| 137 | .mdlext-selectfield__label { |
| 138 | color: $mdlext-bordered-field-input-text-label-color; |
| 139 | font-size: $mdlext-bordered-field-label-font-size; |
| 140 | font-weight: $mdlext-bordered-field-font-weight; |
| 141 | padding-left: $mdlext-bordered-field-padding; |
| 142 | top: auto; |
| 143 | bottom: $mdlext-bordered-field-padding-bottom; |
| 144 | |
| 145 | // Hides the colored underline for the textField/selectfield. |
| 146 | &::after { |
| 147 | background-color: transparent !important; |
| 148 | visibility: hidden !important; |
| 149 | } |
| 150 | } |
| 151 | &.mdl-textfield--floating-label.is-focused.is-focused, |
| 152 | &.mdl-textfield--floating-label.is-dirty.is-dirty, |
| 153 | &.mdl-textfield--floating-label.has-placeholder, |
| 154 | &.mdlext-selectfield--floating-label.is-focused.is-focused, |
| 155 | &.mdlext-selectfield--floating-label.is-dirty.is-dirty, |
| 156 | &.mdlext-selectfield--floating-label.has-placeholder { |
| 157 | |
| 158 | .mdl-textfield__label, |
| 159 | .mdlext-selectfield__label { |
| 160 | color: $mdlext-bordered-field-input-text-label-focus-color; |
| 161 | font-size: $mdlext-bordered-field-floating-label-font-size; |
| 162 | font-weight: $mdlext-bordered-field-floating-label-font-weight; |
| 163 | top: auto; |
| 164 | bottom: $mdlext-bordered-field-floating-label-focus-bottom; |
| 165 | visibility: visible; |
| 166 | } |
| 167 | } |
| 168 | &.mdl-textfield--floating-label.is-disabled.is-disabled, |
| 169 | &.mdlext-selectfield--floating-label.is-disabled.is-disabled { |
| 170 | |
| 171 | .mdl-textfield__label, |
| 172 | .mdlext-selectfield__label { |
| 173 | color: $mdlext-bordered-field-input-text-label-disabled-color; |
| 174 | } |
| 175 | } |
| 176 | &.mdl-textfield--floating-label.is-invalid.is-invalid, |
| 177 | &.mdlext-selectfield--floating-label.is-invalid.is-invalid { |
| 178 | |
| 179 | .mdl-textfield__label, |
| 180 | .mdlext-selectfield__label { |
| 181 | color: $mdlext-bordered-field-input-text-label-error-color; |
| 182 | } |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | fieldset[disabled] .mdl-textfield .mdl-textfield__label, |
| 187 | fieldset[disabled] .mdl-selectfield .mdl-selectfield__label { |
| 188 | color: $mdlext-bordered-field-input-text-label-disabled-color; |
| 189 | } |
| 190 | |
| 191 | // Icon(s) and/or button(s) inside textfield |
| 192 | .mdl-textfield, |
| 193 | .mdlext-selectfield { |
| 194 | &.mdlext-bordered-fields__icon-left, |
| 195 | &.mdlext-bordered-fields__icon-right { |
| 196 | & > i, |
| 197 | & > .mdl-button { |
| 198 | position: absolute; |
| 199 | bottom: $mdlext-bordered-field-padding-bottom - 2px; |
| 200 | } |
| 201 | & > i { |
| 202 | bottom: $mdlext-bordered-field-padding-bottom + 2px; |
| 203 | } |
| 204 | } |
| 205 | &.mdlext-bordered-fields__icon-left { |
| 206 | & > i:first-child, |
| 207 | & > .mdl-button:first-child { |
| 208 | left: $mdlext-bordered-field-padding/2; |
| 209 | } |
| 210 | & > i ~ .mdl-textfield__input, |
| 211 | & > .mdl-button ~ .mdl-textfield__input, |
| 212 | & > i ~ .mdlext-selectfield__select, |
| 213 | & > .mdl-button ~ .mdlext-selectfield__select { |
| 214 | padding-left: $input-text-button-size; |
| 215 | } |
| 216 | & > i ~ .mdl-textfield__label, |
| 217 | & > .mdl-button ~ .mdl-textfield__label { |
| 218 | left: $input-text-button-size - $mdlext-bordered-field-padding; |
| 219 | } |
| 220 | & > i ~ .mdlext-selectfield__label, |
| 221 | & > .mdl-button ~ .mdlext-selectfield__label { |
| 222 | left: $input-text-button-size - $mdlext-bordered-field-padding; |
| 223 | } |
| 224 | } |
| 225 | &.mdlext-bordered-fields__icon-right { |
| 226 | & > .mdl-textfield__input { |
| 227 | padding-right: $input-text-button-size; |
| 228 | } |
| 229 | & > i:last-child, |
| 230 | & > .mdl-button:last-child { |
| 231 | left: auto; |
| 232 | right: $mdlext-bordered-field-padding/2; |
| 233 | } |
| 234 | } |
| 235 | &.is-disabled i, |
| 236 | &.is-disabled .mdl-button { |
| 237 | color: $mdlext-bordered-field-disabled-border-color; |
| 238 | pointer-events: none; |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | fieldset[disabled] .mdl-textfield, |
| 243 | fieldset[disabled] .mdlext-selectfield { |
| 244 | i, |
| 245 | .mdl-button { |
| 246 | color: $mdlext-bordered-field-disabled-border-color; |
| 247 | pointer-events: none; |
| 248 | } |
| 249 | } |
| 250 | } |
| 251 | |