|
| 1 | +/** |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +.switch-label { |
| 21 | + display: inline-block; |
| 22 | + margin: 0; |
| 23 | + cursor: pointer; |
| 24 | +} |
| 25 | + |
| 26 | +.switch-input { |
| 27 | + /* Visusally hidden input but still accessible */ |
| 28 | + position: absolute; |
| 29 | + overflow: hidden; |
| 30 | + clip: rect(1px, 1px, 1px, 1px); |
| 31 | + border: 0; |
| 32 | + width: 1px; |
| 33 | + height: 1px; |
| 34 | + padding: 0; |
| 35 | + white-space: nowrap; |
| 36 | + clip-path: inset(50%); |
| 37 | +} |
| 38 | + |
| 39 | +.switch { |
| 40 | + box-sizing: content-box; |
| 41 | + display: inline-flex; |
| 42 | + align-items: center; |
| 43 | + border-radius: 999px; |
| 44 | + width: 2.5rem; |
| 45 | + padding: 2px; |
| 46 | + background-color: #c4c2c1; |
| 47 | + cursor: pointer; |
| 48 | +} |
| 49 | + |
| 50 | +.switch::before { |
| 51 | + border-radius: 50%; |
| 52 | + width: 1.5rem; |
| 53 | + height: 1.5rem; |
| 54 | + content: ''; |
| 55 | + background-color: #edecec; |
| 56 | + transition-timing-function: ease-in-out; |
| 57 | + transition-duration: 0.25s; |
| 58 | + transition-property: transform, background-color; |
| 59 | +} |
| 60 | + |
| 61 | +.switch-input:checked + .switch { |
| 62 | + background-color: #005c66; |
| 63 | +} |
| 64 | + |
| 65 | +.switch-input:checked + .switch::before { |
| 66 | + background-color: #fffefd; |
| 67 | + transform: translateX(1rem); |
| 68 | +} |
| 69 | + |
| 70 | +.switch-input:focus + .switch { |
| 71 | + box-shadow: 0 0 0 3px rgba(0, 92, 102, 0.4); |
| 72 | +} |
| 73 | + |
| 74 | +.switch-input:focus + .switch::before { |
| 75 | + background-color: #fff; |
| 76 | +} |
| 77 | + |
| 78 | +.switch-input:not(:checked) + .switch:hover { |
| 79 | + background-color: #9e9e9c; |
| 80 | +} |
| 81 | + |
| 82 | +.switch-input:not(:checked) + .switch:hover::before { |
| 83 | + background-color: #f5f5f5; |
| 84 | +} |
0 commit comments