Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

switch.css 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. :root {
  2. --switch-checked-background-color: var(--switch-highlight-color); /* background color active */
  3. --switch-thumb-background-color: white;
  4. --switch-thumb-border-color: var(--border-color);
  5. --switch-thumb-border-color-active: var(--switch-highlight-color);
  6. --switch-height: 32px;
  7. --switch-width: 51px;
  8. --switch: {
  9. display: inline-block;
  10. vertical-align: top;
  11. @apply(--reset-box-model);
  12. @apply(--hide-input-parent);
  13. min-width: 51px;
  14. }
  15. --switch__toggle: {
  16. position: relative;
  17. display: inline-block;
  18. vertical-align: top;
  19. @apply(--reset-box-model);
  20. @apply(--reset-base);
  21. @apply(--reset-cursor);
  22. }
  23. }
  24. /*~
  25. name: Switch
  26. category: Switch
  27. elements: ons-switch
  28. markup: |
  29. <label class="switch">
  30. <input type="checkbox" class="switch__input">
  31. <div class="switch__toggle">
  32. <div class="switch__handle"></div>
  33. </div>
  34. </label>
  35. <label class="switch">
  36. <input type="checkbox" class="switch__input" checked>
  37. <div class="switch__toggle">
  38. <div class="switch__handle"></div>
  39. </div>
  40. </label>
  41. <label class="switch">
  42. <input type="checkbox" class="switch__input" disabled>
  43. <div class="switch__toggle">
  44. <div class="switch__handle"></div>
  45. </div>
  46. </label>
  47. */
  48. .switch {
  49. @apply(--switch);
  50. font-size: var(--font-size);
  51. padding: 0 20px;
  52. border: none;
  53. overflow: visible;
  54. width: var(--switch-width);
  55. height: var(--switch-height);
  56. z-index: 0;
  57. text-align: left;
  58. }
  59. .switch__input {
  60. @apply(--hide-input);
  61. z-index: 0;
  62. }
  63. /* switch toggle background */
  64. .switch__toggle {
  65. background-color: var(--switch-background-color);
  66. position: absolute;
  67. top: 0;
  68. left: 0;
  69. right: 0;
  70. bottom: 0;
  71. border-radius: 30px;
  72. transition-property: all;
  73. transition-duration: 0.35s;
  74. transition-timing-function: ease-out;
  75. box-shadow: inset 0 0 0 2px var(--switch-border-color);
  76. }
  77. /* switch toggle circle */
  78. .switch__handle {
  79. @apply(--reset-box-model);
  80. position: absolute;
  81. content: '';
  82. border-radius: 28px;
  83. height: 28px;
  84. width: 28px;
  85. background-color: var(--switch-thumb-background-color);
  86. left: 1px;
  87. top: 2px;
  88. transition-property: all;
  89. transition-duration: 0.35s;
  90. transition-timing-function: cubic-bezier(.59, .01, .5, .99);
  91. box-shadow: 0 0 1px 0 rgba(0, 0, 0, 0.25), 0 3px 2px rgba(0, 0, 0, 0.25);
  92. }
  93. .switch--active__handle {
  94. transition: none;
  95. }
  96. :checked + .switch__toggle {
  97. box-shadow: inset 0 0 0 2px var(--switch-checked-background-color);
  98. background-color: var(--switch-checked-background-color);
  99. }
  100. :checked + .switch__toggle > .switch__handle {
  101. left: 21px;
  102. box-shadow: 0 3px 2px rgba(0, 0, 0, 0.25);
  103. }
  104. :disabled + .switch__toggle {
  105. @apply(--disabled);
  106. }
  107. .switch__touch {
  108. position: absolute;
  109. top: -5px;
  110. bottom: -5px;
  111. left: -10px;
  112. right: -10px;
  113. }
  114. /*~
  115. name: Material Switch
  116. category: Switch
  117. elements: ons-switch
  118. markup: |
  119. <label class="switch switch--material">
  120. <input type="checkbox" class="switch__input switch--material__input">
  121. <div class="switch__toggle switch--material__toggle">
  122. <div class="switch__handle switch--material__handle">
  123. </div>
  124. </div>
  125. </label>
  126. <label class="switch switch--material">
  127. <input type="checkbox" class="switch__input switch--material__input" checked>
  128. <div class="switch__toggle switch--material__toggle">
  129. <div class="switch__handle switch--material__handle">
  130. </div>
  131. </div>
  132. </label>
  133. <label class="switch switch--material">
  134. <input type="checkbox" class="switch__input switch--material__input" disabled>
  135. <div class="switch__toggle switch--material__toggle">
  136. <div class="switch__handle switch--material__handle">
  137. </div>
  138. </div>
  139. </label>
  140. */
  141. .switch--material {
  142. width: 36px;
  143. height: 24px;
  144. padding: 0 10px;
  145. min-width: 36px;
  146. }
  147. .switch--material__toggle {
  148. background-color: var(--material-switch-inactive-background-color);
  149. margin-top: 5px;
  150. height: 14px;
  151. box-shadow: none;
  152. }
  153. .switch--material__input {
  154. @apply(--hide-input);
  155. z-index: 0;
  156. }
  157. .switch--material__handle {
  158. background-color: var(--material-switch-inactive-thumb-color);
  159. left: 0;
  160. margin-top: -5px;
  161. width: 20px;
  162. height: 20px;
  163. @apply(--material-shadow-2);
  164. }
  165. :checked + .switch--material__toggle {
  166. background-color: var(--material-switch-active-background-color);
  167. box-shadow: none;
  168. }
  169. :checked + .switch--material__toggle > .switch--material__handle {
  170. left: 16px;
  171. background-color: var(--material-switch-active-thumb-color);
  172. @apply(--material-shadow-1);
  173. }
  174. :disabled + .switch--material__toggle {
  175. @apply(--disabled);
  176. }
  177. .switch--material__handle:before {
  178. background: transparent;
  179. content: '';
  180. display: block;
  181. width: 100%;
  182. height: 100%;
  183. border-radius: 50%;
  184. z-index: 0;
  185. box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.12);
  186. transition: box-shadow 0.1s linear;
  187. }
  188. .switch--material__toggle > .switch--active__handle:before {
  189. box-shadow: 0 0 0 14px rgba(0, 0, 0, 0.12);
  190. }
  191. :checked + .switch--material__toggle > .switch--active__handle:before {
  192. box-shadow: 0 0 0 14px color(var(--material-switch-active-thumb-color) alpha(20%));
  193. }
  194. .switch--material__touch {
  195. position: absolute;
  196. top: -10px;
  197. bottom: -10px;
  198. left: -15px;
  199. right: -15px;
  200. }