|
| 1 | +.spx-input { |
| 2 | + --spx-input-pd-x: 0.75rem; |
| 3 | + |
| 4 | + position: relative; |
| 5 | + height: fit-content; |
| 6 | + display: inline-flex; |
| 7 | + border-radius: var(--spx-border-radius); |
| 8 | + background: inherit; |
| 9 | + pointer-events: none; |
| 10 | + |
| 11 | + input { |
| 12 | + height: var(--spx-input-height-default); |
| 13 | + line-height: var(--spx-input-height-default); |
| 14 | + width: 100%; |
| 15 | + box-sizing: border-box; |
| 16 | + font-size: medium; |
| 17 | + background: inherit; |
| 18 | + border: none; |
| 19 | + border-radius: var(--spx-border-radius); |
| 20 | + padding: 0px var(--spx-input-pd-x); |
| 21 | + pointer-events: all; |
| 22 | + } |
| 23 | + |
| 24 | + input:focus-visible { |
| 25 | + outline: none; |
| 26 | + } |
| 27 | + |
| 28 | + label { |
| 29 | + position: absolute; |
| 30 | + font-size: medium; |
| 31 | + top: 50%; |
| 32 | + transform: translateY(-50%); |
| 33 | + transition: |
| 34 | + padding 200ms, |
| 35 | + font-size 200ms, |
| 36 | + transform 200ms; |
| 37 | + pointer-events: none; |
| 38 | + display: flex; |
| 39 | + gap: 2px; |
| 40 | + align-items: center; |
| 41 | + } |
| 42 | + |
| 43 | + input::-webkit-calendar-picker-indicator, |
| 44 | + [list]::-webkit-calendar-picker-indicator { |
| 45 | + display: none !important; |
| 46 | + } |
| 47 | + |
| 48 | + &:has(input:disabled) { |
| 49 | + filter: var(--spx-filter-control-disabled); |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | +.spx-input[spx-size='small'] { |
| 54 | + width: var(--spx-control-width-small); |
| 55 | + max-width: 100%; |
| 56 | +} |
| 57 | + |
| 58 | +.spx-input[spx-size='medium'] { |
| 59 | + width: var(--spx-control-width-medium); |
| 60 | + max-width: 100%; |
| 61 | +} |
| 62 | + |
| 63 | +.spx-input[spx-size='large'] { |
| 64 | + width: var(--spx-control-width-large); |
| 65 | + max-width: 100%; |
| 66 | +} |
| 67 | + |
| 68 | +/* Common */ |
| 69 | +.spx-input[spx-variant='contained'], |
| 70 | +.spx-input[spx-variant='outlined'] { |
| 71 | + label { |
| 72 | + left: var(--spx-input-pd-x); |
| 73 | + } |
| 74 | +} |
| 75 | + |
| 76 | +/* Contained */ |
| 77 | +.spx-input[spx-variant='contained'] { |
| 78 | + border-bottom-left-radius: 0px; |
| 79 | + border-bottom-right-radius: 0px; |
| 80 | + background: var(--spx-color-input-contained-bg); |
| 81 | + |
| 82 | + input { |
| 83 | + color: inherit; |
| 84 | + box-sizing: border-box; |
| 85 | + border-bottom-left-radius: 0px; |
| 86 | + border-bottom-right-radius: 0px; |
| 87 | + padding-top: 1.25rem; |
| 88 | + } |
| 89 | + |
| 90 | + label { |
| 91 | + color: var(--spx-color-text-subtle); |
| 92 | + } |
| 93 | + |
| 94 | + input:focus { |
| 95 | + box-shadow: 0 var(--spx-border-width) 0 var(--spx-color-input-focus); |
| 96 | + } |
| 97 | + |
| 98 | + input:focus + label { |
| 99 | + transform: translateY(-2.15rem); |
| 100 | + color: var(--spx-color-input-focus); |
| 101 | + } |
| 102 | + |
| 103 | + input:focus + label, |
| 104 | + input:not(:placeholder-shown) + label { |
| 105 | + transform: translateY(-1.15rem); |
| 106 | + font-size: smaller; |
| 107 | + } |
| 108 | +} |
| 109 | + |
| 110 | +.spx-input[spx-variant='contained']:has(input:invalid) { |
| 111 | + border-color: var(--spx-color-error); |
| 112 | + |
| 113 | + label { |
| 114 | + color: var(--spx-color-input-error); |
| 115 | + } |
| 116 | + |
| 117 | + input { |
| 118 | + box-shadow: 0 var(--spx-border-width) 0 var(--spx-color-input-error); |
| 119 | + } |
| 120 | +} |
| 121 | + |
| 122 | +/* Outlined */ |
| 123 | +.spx-input[spx-variant='outlined'] { |
| 124 | + background: inherit; |
| 125 | + color: var(--spx-color-input-outlined-fg); |
| 126 | + border-color: var(--spx-color-input-outlined-fg); |
| 127 | + |
| 128 | + input { |
| 129 | + color: var(--spx-color-text-default); |
| 130 | + } |
| 131 | + |
| 132 | + label { |
| 133 | + padding: 0px 4px; |
| 134 | + left: calc(var(--spx-input-pd-x) - 4px); |
| 135 | + background: inherit; |
| 136 | + } |
| 137 | + |
| 138 | + input:focus + label { |
| 139 | + transform: translateY(-2.15rem); |
| 140 | + color: var(--spx-color-input-focus); |
| 141 | + } |
| 142 | + |
| 143 | + input:focus + label, |
| 144 | + input:not(:placeholder-shown) + label { |
| 145 | + transform: translateY(-2.15rem); |
| 146 | + font-size: smaller; |
| 147 | + } |
| 148 | +} |
| 149 | + |
| 150 | +.spx-input[spx-variant='outlined']:has(input:focus) { |
| 151 | + border-color: var(--spx-color-input-focus); |
| 152 | +} |
| 153 | + |
| 154 | +.spx-input[spx-variant='outlined']:has(input:invalid) { |
| 155 | + border-color: var(--spx-color-input-error); |
| 156 | + |
| 157 | + label { |
| 158 | + color: var(--spx-color-input-error); |
| 159 | + } |
| 160 | +} |
0 commit comments