switch.css 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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. @media (prefers-reduced-motion: reduce) {
  65. :root {
  66. --calcite-internal-duration-factor: 0.01;
  67. }
  68. }
  69. /**
  70. * Currently only used in Checkbox.
  71. */
  72. :root {
  73. --calcite-floating-ui-transition: var(--calcite-animation-timing);
  74. }
  75. :host([hidden]) {
  76. display: none;
  77. }
  78. :host([disabled]) {
  79. pointer-events: none;
  80. cursor: default;
  81. -webkit-user-select: none;
  82. user-select: none;
  83. opacity: var(--calcite-ui-opacity-disabled);
  84. }
  85. :host([scale=s]) .container {
  86. block-size: 0.75rem;
  87. }
  88. :host([scale=s]) .track {
  89. block-size: 0.75rem;
  90. inline-size: 1.5rem;
  91. }
  92. :host([scale=s]) .handle {
  93. block-size: 0.5rem;
  94. inline-size: 0.5rem;
  95. }
  96. :host([scale=m]) .container {
  97. block-size: 1rem;
  98. }
  99. :host([scale=m]) .track {
  100. block-size: 1rem;
  101. inline-size: 2rem;
  102. }
  103. :host([scale=m]) .handle {
  104. block-size: 0.75rem;
  105. inline-size: 0.75rem;
  106. }
  107. :host([scale=l]) .container {
  108. block-size: 1.5rem;
  109. }
  110. :host([scale=l]) .track {
  111. block-size: 1.5rem;
  112. inline-size: 3rem;
  113. }
  114. :host([scale=l]) .handle {
  115. block-size: 1.25rem;
  116. inline-size: 1.25rem;
  117. }
  118. :host {
  119. position: relative;
  120. display: inline-block;
  121. inline-size: auto;
  122. cursor: pointer;
  123. -webkit-user-select: none;
  124. user-select: none;
  125. vertical-align: middle;
  126. tap-highlight-color: transparent;
  127. }
  128. :host([disabled]) ::slotted([calcite-hydrated][disabled]),
  129. :host([disabled]) [calcite-hydrated][disabled] {
  130. /* prevent opacity stacking */
  131. opacity: 1;
  132. }
  133. :host {
  134. inline-size: auto;
  135. outline-color: transparent;
  136. }
  137. .track {
  138. pointer-events: none;
  139. position: relative;
  140. box-sizing: border-box;
  141. display: inline-block;
  142. border-radius: 9999px;
  143. border-width: 1px;
  144. border-style: solid;
  145. border-color: var(--calcite-ui-border-2);
  146. background-color: var(--calcite-ui-foreground-2);
  147. vertical-align: top;
  148. transition-property: all;
  149. transition-duration: 150ms;
  150. transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  151. }
  152. .handle {
  153. pointer-events: none;
  154. position: absolute;
  155. display: block;
  156. border-radius: 9999px;
  157. border-width: 2px;
  158. border-style: solid;
  159. border-color: var(--calcite-ui-border-input);
  160. background-color: var(--calcite-ui-foreground-1);
  161. transition-property: all;
  162. transition-duration: 150ms;
  163. transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  164. inset-block-start: -1px;
  165. inset-inline: -1px auto;
  166. }
  167. :host(:hover) .handle,
  168. :host(:focus) .handle {
  169. border-color: var(--calcite-ui-brand);
  170. box-shadow: inset 0 0 0 1px var(--calcite-ui-brand);
  171. }
  172. :host([checked]) .track {
  173. border-color: var(--calcite-ui-brand-hover);
  174. background-color: var(--calcite-ui-brand);
  175. }
  176. :host([checked]) .handle {
  177. border-color: var(--calcite-ui-brand);
  178. inset-inline: auto -1px;
  179. }
  180. :host([checked]:hover) .track {
  181. border-color: var(--calcite-ui-brand-hover);
  182. background-color: var(--calcite-ui-brand);
  183. }
  184. :host([checked]:hover) .handle {
  185. border-color: var(--calcite-ui-brand-hover);
  186. box-shadow: inset 0 0 0 1px var(--calcite-ui-brand-hover);
  187. }
  188. @media (forced-colors: active) {
  189. :host([checked]) .track {
  190. background-color: canvasText;
  191. }
  192. }
  193. .container:focus {
  194. outline: 2px solid var(--calcite-ui-brand);
  195. outline-offset: 2px;
  196. }
  197. ::slotted(input[slot=hidden-form-input]) {
  198. margin: 0 !important;
  199. opacity: 0 !important;
  200. outline: none !important;
  201. padding: 0 !important;
  202. position: absolute !important;
  203. inset: 0 !important;
  204. transform: none !important;
  205. -webkit-appearance: none !important;
  206. z-index: -1 !important;
  207. }