|
| 1 | +@import "./input.vars"; |
| 2 | + |
1 | 3 | // Input Fill: Outline
|
2 | 4 | // ----------------------------------------------------------------
|
3 | 5 |
|
|
9 | 11 | }
|
10 | 12 |
|
11 | 13 | :host(.input-fill-outline.input-shape-round) {
|
12 |
| - --border-radius: 9999px; |
| 14 | + --border-radius: 28px; |
13 | 15 | --padding-start: 32px;
|
14 | 16 | --padding-end: 32px;
|
15 | 17 | }
|
|
62 | 64 |
|
63 | 65 | :host(.input-fill-outline.input-label-placement-stacked) .label-text-wrapper,
|
64 | 66 | :host(.input-fill-outline.input-label-placement-floating) .label-text-wrapper {
|
65 |
| - @include transform-origin(center, top); |
| 67 | + @include transform-origin(start, top); |
| 68 | + |
| 69 | + position: absolute; |
| 70 | + |
| 71 | + /** |
| 72 | + * Label text should not extend |
| 73 | + * beyond the bounds of the input. |
| 74 | + */ |
| 75 | + max-width: calc(100% - var(--padding-start) - var(--padding-end)); |
66 | 76 | }
|
67 | 77 |
|
68 | 78 | /**
|
|
81 | 91 | */
|
82 | 92 | :host(.has-focus.input-fill-outline.input-label-placement-floating) .label-text-wrapper,
|
83 | 93 | :host(.has-value.input-fill-outline.input-label-placement-floating) .label-text-wrapper,
|
84 |
| -:host(.input-fill-outline.input-label-placement-stacked) .label-text-wrapper, |
85 | 94 | :host(.input-fill-outline.input-label-placement-stacked) .label-text-wrapper {
|
86 |
| - @include transform(translateY(-32%), scale(.75)); |
| 95 | + @include transform(translateY(-32%), scale(#{$input-floating-label-scale})); |
87 | 96 | @include margin(0);
|
| 97 | + |
| 98 | + /** |
| 99 | + * Label text should not extend |
| 100 | + * beyond the bounds of the input. |
| 101 | + */ |
| 102 | + max-width: calc((100% - var(--padding-start) - var(--padding-end) - #{$input-md-floating-label-padding * 2}) / #{$input-floating-label-scale}); |
88 | 103 | }
|
89 | 104 |
|
90 | 105 | /**
|
|
128 | 143 | border-bottom: var(--border-width) var(--border-style) var(--border-color);
|
129 | 144 | }
|
130 | 145 |
|
131 |
| -:host(.input-fill-outline) .input-outline-start { |
132 |
| - @include border-radius(var(--border-radius), 0px, 0px, var(--border-radius)); |
133 |
| - @include border(null, null, null, var(--border-width) var(--border-style) var(--border-color)); |
134 |
| - |
135 |
| - width: 12px; |
| 146 | +/** |
| 147 | + * Ensures long labels do not cause the notch to flow |
| 148 | + * out of bounds. |
| 149 | + */ |
| 150 | +:host(.input-fill-outline) .input-outline-notch { |
| 151 | + max-width: calc(100% - var(--padding-start) - var(--padding-end)); |
136 | 152 | }
|
137 | 153 |
|
138 | 154 | /**
|
139 |
| - * When shape="round", the starting outline fragment |
140 |
| - * should appear with a pill shape. |
| 155 | + * This element ensures that the notch used |
| 156 | + * the size of the scaled text so that the |
| 157 | + * border cut out is the correct width. |
| 158 | + * The text in this element should not |
| 159 | + * be interactive. |
141 | 160 | */
|
142 |
| -:host(.input-fill-outline.input-shape-round) .input-outline-start { |
143 |
| - @include border-radius(28px, 0px, 0px, 28px); |
144 |
| - width: 28px; |
| 161 | +:host(.input-fill-outline) .notch-spacer { |
| 162 | + /** |
| 163 | + * We need $input-md-floating-label-padding of padding on the right. |
| 164 | + * However, we also subtracted $input-md-floating-label-padding from |
| 165 | + * the width of .input-outline-start |
| 166 | + * to create space, so we need to take |
| 167 | + * that into consideration here. |
| 168 | + */ |
| 169 | + @include padding(null, #{$input-md-floating-label-padding * 2}, null, null); |
| 170 | + |
| 171 | + font-size: calc(1em * #{$input-floating-label-scale}); |
| 172 | + |
| 173 | + opacity: 0; |
| 174 | + pointer-events: none; |
| 175 | +} |
| 176 | + |
| 177 | +:host(.input-fill-outline) .input-outline-start { |
| 178 | + @include border-radius(var(--border-radius), 0px, 0px, var(--border-radius)); |
| 179 | + @include border(null, null, null, var(--border-width) var(--border-style) var(--border-color)); |
| 180 | + |
| 181 | + /** |
| 182 | + * There should be spacing between the translated text |
| 183 | + * and .input-outline-start. However, we can't add this |
| 184 | + * spacing onto the notch because it would cause the |
| 185 | + * label to look like it is not aligned with the |
| 186 | + * text input. Instead, we subtract a few pixels from |
| 187 | + * this element. |
| 188 | + */ |
| 189 | + width: calc(var(--padding-start) - #{$input-md-floating-label-padding}); |
145 | 190 | }
|
146 | 191 |
|
147 | 192 | :host(.input-fill-outline) .input-outline-end {
|
|
163 | 208 | */
|
164 | 209 | :host(.has-focus.input-fill-outline.input-label-placement-floating) .input-outline-notch,
|
165 | 210 | :host(.has-value.input-fill-outline.input-label-placement-floating) .input-outline-notch,
|
166 |
| -:host(.input-fill-outline.input-label-placement-stacked) .input-outline-notch, |
167 | 211 | :host(.input-fill-outline.input-label-placement-stacked) .input-outline-notch {
|
168 | 212 | border-top: none;
|
169 | 213 | }
|
0 commit comments