|
| 1 | +.color_picker { |
| 2 | + --thumb: #{size(4)}; |
| 3 | + |
| 4 | + display: none; |
| 5 | + position: absolute; |
| 6 | + width: size(48); |
| 7 | + z-index: 1000; |
| 8 | + border-radius: rounded("base"); |
| 9 | + background-color: var(--ui-surface-color); |
| 10 | + box-shadow: 0 0 0 1px var(--ui-on-surface-color-lightest), var(--ui-box-shadow-lg); |
| 11 | + user-select: none; |
| 12 | + |
| 13 | + &-open { |
| 14 | + display: block; |
| 15 | + } |
| 16 | + |
| 17 | + &-gradient { |
| 18 | + position: relative; |
| 19 | + width: 100%; |
| 20 | + height: size(24); |
| 21 | + margin-bottom: size(3); |
| 22 | + border-radius: rounded("base") rounded("base") 0 0; |
| 23 | + background-image: #{"linear-gradient(rgba(0,0,0,0), #000), linear-gradient(90deg, #fff, currentColor)"}; |
| 24 | + cursor: pointer; |
| 25 | + } |
| 26 | + |
| 27 | + &-marker { |
| 28 | + position: absolute; |
| 29 | + width: size(3); |
| 30 | + height: size(3); |
| 31 | + margin: size(-1.5) 0 0 size(-1.5); |
| 32 | + border: 1px solid #fff; |
| 33 | + border-radius: 50%; |
| 34 | + background-color: currentColor; |
| 35 | + cursor: pointer; |
| 36 | + |
| 37 | + &:focus { |
| 38 | + outline: none; |
| 39 | + } |
| 40 | + } |
| 41 | + |
| 42 | + input[type="range"] { |
| 43 | + &::-webkit-slider-runnable-track { |
| 44 | + width: 100%; |
| 45 | + height: var(--thumb); |
| 46 | + } |
| 47 | + |
| 48 | + &::-webkit-slider-thumb { |
| 49 | + width: var(--thumb); |
| 50 | + height: var(--thumb); |
| 51 | + -webkit-appearance: none; |
| 52 | + } |
| 53 | + |
| 54 | + &::-moz-range-track { |
| 55 | + width: 100%; |
| 56 | + height: var(--thumb); |
| 57 | + border: 0; |
| 58 | + } |
| 59 | + |
| 60 | + &::-moz-range-thumb { |
| 61 | + width: var(--thumb); |
| 62 | + height: var(--thumb); |
| 63 | + border: 0; |
| 64 | + } |
| 65 | + } |
| 66 | + |
| 67 | + &-hue { |
| 68 | + background-image: #{"linear-gradient(to right, #f00 0%, #ff0 16.66%, #0f0 33.33%, #0ff 50%, #00f 66.66%, #f0f 83.33%, #f00 100%)"}; |
| 69 | + } |
| 70 | + |
| 71 | + &-hue, |
| 72 | + &-alpha { |
| 73 | + position: relative; |
| 74 | + height: size(2); |
| 75 | + margin: size(3) size(4); |
| 76 | + border-radius: rounded("base"); |
| 77 | + } |
| 78 | + |
| 79 | + &-alpha span { |
| 80 | + display: block; |
| 81 | + height: 100%; |
| 82 | + width: 100%; |
| 83 | + border-radius: inherit; |
| 84 | + background-image: #{"linear-gradient(90deg, rgba(0,0,0,0), currentColor)"}; |
| 85 | + } |
| 86 | + |
| 87 | + &-hue input[type="range"], |
| 88 | + &-alpha input[type="range"] { |
| 89 | + position: absolute; |
| 90 | + width: calc(100% + 2 * var(--thumb)); |
| 91 | + height: var(--thumb); |
| 92 | + left: calc(-1 * var(--thumb)); |
| 93 | + top: calc((#{size(2)} - var(--thumb)) / 2); |
| 94 | + margin: 0; |
| 95 | + background-color: transparent; |
| 96 | + opacity: 0; |
| 97 | + cursor: pointer; |
| 98 | + appearance: none; |
| 99 | + -webkit-appearance: none; |
| 100 | + } |
| 101 | + |
| 102 | + &-hue div, |
| 103 | + &-alpha div { |
| 104 | + position: absolute; |
| 105 | + width: var(--thumb); |
| 106 | + height: var(--thumb); |
| 107 | + left: 0; |
| 108 | + top: 50%; |
| 109 | + margin-left: calc(var(--thumb) / -2); |
| 110 | + transform: translateY(-50%); |
| 111 | + border: 2px solid #fff; |
| 112 | + border-radius: 50%; |
| 113 | + background-color: currentColor; |
| 114 | + pointer-events: none; |
| 115 | + } |
| 116 | + |
| 117 | + &-swatches { |
| 118 | + margin: 0 size(4); |
| 119 | + border-top: 1px solid var(--ui-on-surface-color-lightest); |
| 120 | + display: flex; |
| 121 | + flex-wrap: wrap; |
| 122 | + gap: size(2); |
| 123 | + padding: size(3) 0; |
| 124 | + |
| 125 | + &.color_picker-empty { |
| 126 | + display: none; |
| 127 | + } |
| 128 | + |
| 129 | + button { |
| 130 | + position: relative; |
| 131 | + width: size(5); |
| 132 | + height: size(5); |
| 133 | + padding: 0; |
| 134 | + border: 0; |
| 135 | + border-radius: 50%; |
| 136 | + color: inherit; |
| 137 | + text-indent: -1000px; |
| 138 | + white-space: nowrap; |
| 139 | + overflow: hidden; |
| 140 | + cursor: pointer; |
| 141 | + |
| 142 | + &:after { |
| 143 | + content: ''; |
| 144 | + display: block; |
| 145 | + position: absolute; |
| 146 | + width: 100%; |
| 147 | + height: 100%; |
| 148 | + left: 0; |
| 149 | + top: 0; |
| 150 | + border-radius: inherit; |
| 151 | + background-color: currentColor; |
| 152 | + box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); |
| 153 | + } |
| 154 | + } |
| 155 | + } |
| 156 | + |
| 157 | + &-marker, |
| 158 | + &-hue div, |
| 159 | + &-alpha div { |
| 160 | + box-sizing: border-box; |
| 161 | + box-shadow: 0 0 0 1px inset var(--ui-on-surface-color-lighter), 0 0 0 1px var(--ui-on-surface-color-lighter); |
| 162 | + } |
| 163 | + |
| 164 | + &-field { |
| 165 | + display: inline-block; |
| 166 | + position: relative; |
| 167 | + color: transparent; |
| 168 | + |
| 169 | + > input { |
| 170 | + margin: 0; |
| 171 | + direction: ltr; |
| 172 | + } |
| 173 | + |
| 174 | + > span { |
| 175 | + position: absolute; |
| 176 | + width: size(8); |
| 177 | + height: 100%; |
| 178 | + right: 0; |
| 179 | + top: 50%; |
| 180 | + transform: translateY(-50%); |
| 181 | + margin: 0; |
| 182 | + padding: 0; |
| 183 | + border: 0; |
| 184 | + color: inherit; |
| 185 | + text-indent: -1000px; |
| 186 | + white-space: nowrap; |
| 187 | + overflow: hidden; |
| 188 | + pointer-events: none; |
| 189 | + |
| 190 | + &:after { |
| 191 | + content: ''; |
| 192 | + display: block; |
| 193 | + position: absolute; |
| 194 | + width: 100%; |
| 195 | + height: 100%; |
| 196 | + left: 0; |
| 197 | + top: 0; |
| 198 | + border-radius: inherit; |
| 199 | + background-color: currentColor; |
| 200 | + box-shadow: inset 0 0 0 1px var(--ui-on-surface-color-lighter); |
| 201 | + } |
| 202 | + } |
| 203 | + } |
| 204 | + |
| 205 | + &-alpha, |
| 206 | + &-swatches button, |
| 207 | + &-field > span { |
| 208 | + background-image: #{"repeating-linear-gradient(45deg, #aaa 25%, transparent 25%, transparent 75%, #aaa 75%, #aaa), repeating-linear-gradient(45deg, #aaa 25%, #fff 25%, #fff 75%, #aaa 75%, #aaa)"}; |
| 209 | + background-position: 0 0, size(1) size(1); |
| 210 | + background-size: size(2) size(2); |
| 211 | + } |
| 212 | + |
| 213 | + &-keyboard_nav .color_picker-marker:focus, |
| 214 | + &-keyboard_nav .color_picker-hue input:focus + div, |
| 215 | + &-keyboard_nav .color_picker-alpha input:focus + div { |
| 216 | + outline: none; |
| 217 | + box-shadow: 0 0 0 2px var(--ui-selection-color), 0 0 2px 2px #fff; |
| 218 | + } |
| 219 | + |
| 220 | + &-no_alpha .color_picker-alpha { |
| 221 | + display: none; |
| 222 | + } |
| 223 | +} |
0 commit comments