switch.css 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /* mixins & extensions */
  2. @keyframes in {
  3. 0% {
  4. opacity: 0;
  5. }
  6. 100% {
  7. opacity: 1;
  8. }
  9. }
  10. @keyframes in-down {
  11. 0% {
  12. opacity: 0;
  13. transform: translate3D(0, -5px, 0);
  14. }
  15. 100% {
  16. opacity: 1;
  17. transform: translate3D(0, 0, 0);
  18. }
  19. }
  20. @keyframes in-up {
  21. 0% {
  22. opacity: 0;
  23. transform: translate3D(0, 5px, 0);
  24. }
  25. 100% {
  26. opacity: 1;
  27. transform: translate3D(0, 0, 0);
  28. }
  29. }
  30. @keyframes in-scale {
  31. 0% {
  32. opacity: 0;
  33. transform: scale3D(0.95, 0.95, 1);
  34. }
  35. 100% {
  36. opacity: 1;
  37. transform: scale3D(1, 1, 1);
  38. }
  39. }
  40. :root {
  41. --calcite-animation-timing: calc(150ms * var(--calcite-internal-duration-factor));
  42. --calcite-internal-duration-factor: var(--calcite-duration-factor, 1);
  43. --calcite-internal-animation-timing-fast: calc(100ms * var(--calcite-internal-duration-factor));
  44. --calcite-internal-animation-timing-medium: calc(200ms * var(--calcite-internal-duration-factor));
  45. --calcite-internal-animation-timing-slow: calc(300ms * var(--calcite-internal-duration-factor));
  46. }
  47. .calcite-animate {
  48. opacity: 0;
  49. animation-fill-mode: both;
  50. animation-duration: var(--calcite-animation-timing);
  51. }
  52. .calcite-animate__in {
  53. animation-name: in;
  54. }
  55. .calcite-animate__in-down {
  56. animation-name: in-down;
  57. }
  58. .calcite-animate__in-up {
  59. animation-name: in-up;
  60. }
  61. .calcite-animate__in-scale {
  62. animation-name: in-scale;
  63. }
  64. /**
  65. * Currently only used in Checkbox.
  66. */
  67. :root {
  68. --calcite-popper-transition: var(--calcite-animation-timing);
  69. }
  70. :host([hidden]) {
  71. display: none;
  72. }
  73. :host([scale=s]) .container {
  74. height: 0.75rem;
  75. }
  76. :host([scale=s]) .track {
  77. height: 0.75rem;
  78. width: 1.5rem;
  79. }
  80. :host([scale=s]) .handle {
  81. height: 0.5rem;
  82. width: 0.5rem;
  83. }
  84. :host([scale=m]) .container {
  85. height: 1rem;
  86. }
  87. :host([scale=m]) .track {
  88. height: 1rem;
  89. width: 2rem;
  90. }
  91. :host([scale=m]) .handle {
  92. height: 0.75rem;
  93. width: 0.75rem;
  94. }
  95. :host([scale=l]) .container {
  96. height: 1.5rem;
  97. }
  98. :host([scale=l]) .track {
  99. height: 1.5rem;
  100. width: 3rem;
  101. }
  102. :host([scale=l]) .handle {
  103. height: 1.25rem;
  104. width: 1.25rem;
  105. }
  106. :host {
  107. position: relative;
  108. display: inline-block;
  109. width: auto;
  110. cursor: pointer;
  111. -webkit-user-select: none;
  112. user-select: none;
  113. vertical-align: middle;
  114. tap-highlight-color: transparent;
  115. }
  116. :host([disabled]) {
  117. pointer-events: none;
  118. cursor: default;
  119. -webkit-user-select: none;
  120. user-select: none;
  121. opacity: var(--calcite-ui-opacity-disabled);
  122. }
  123. :host([disabled]) ::slotted([calcite-hydrated][disabled]),
  124. :host([disabled]) [calcite-hydrated][disabled] {
  125. /* prevent opacity stacking */
  126. opacity: 1;
  127. }
  128. :host {
  129. width: auto;
  130. outline-offset: 0;
  131. outline-color: transparent;
  132. transition: outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;
  133. }
  134. .track {
  135. pointer-events: none;
  136. position: relative;
  137. box-sizing: border-box;
  138. display: inline-block;
  139. border-radius: 9999px;
  140. border-width: 1px;
  141. border-style: solid;
  142. border-color: var(--calcite-ui-border-2);
  143. background-color: var(--calcite-ui-foreground-2);
  144. vertical-align: top;
  145. transition-property: all;
  146. transition-duration: 150ms;
  147. transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  148. }
  149. .handle {
  150. pointer-events: none;
  151. position: absolute;
  152. display: block;
  153. border-radius: 9999px;
  154. border-width: 2px;
  155. border-style: solid;
  156. border-color: var(--calcite-ui-border-input);
  157. background-color: var(--calcite-ui-foreground-1);
  158. transition-property: all;
  159. transition-duration: 150ms;
  160. transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  161. top: -1px;
  162. inset-inline: -1px auto;
  163. }
  164. :host(:hover) .handle, :host(:focus) .handle {
  165. border-color: var(--calcite-ui-brand);
  166. box-shadow: inset 0 0 0 1px var(--calcite-ui-brand);
  167. }
  168. :host([checked]) .track {
  169. border-color: var(--calcite-ui-brand-hover);
  170. background-color: var(--calcite-ui-brand);
  171. }
  172. :host([checked]) .handle {
  173. border-color: var(--calcite-ui-brand);
  174. inset-inline: auto -1px;
  175. }
  176. :host([checked]:hover) .track {
  177. border-color: var(--calcite-ui-brand-hover);
  178. background-color: var(--calcite-ui-brand);
  179. }
  180. :host([checked]:hover) .handle {
  181. border-color: var(--calcite-ui-brand-hover);
  182. box-shadow: inset 0 0 0 1px var(--calcite-ui-brand-hover);
  183. }
  184. @media (forced-colors: active) {
  185. :host([checked]) .track {
  186. background-color: canvasText;
  187. }
  188. }
  189. .container:focus {
  190. outline: 2px solid var(--calcite-ui-brand);
  191. outline-offset: 2px;
  192. }
  193. ::slotted(input[slot=hidden-form-input]) {
  194. bottom: 0 !important;
  195. left: 0 !important;
  196. margin: 0 !important;
  197. opacity: 0 !important;
  198. outline: none !important;
  199. padding: 0 !important;
  200. position: absolute !important;
  201. right: 0 !important;
  202. top: 0 !important;
  203. transform: none !important;
  204. -webkit-appearance: none !important;
  205. z-index: -1 !important;
  206. }