switch.less 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. .theme-li {
  2. height: 50px;
  3. padding: 15px 8px;
  4. &:hover {
  5. background-color: rgba(0, 0, 0, 0.02);
  6. }
  7. }
  8. body.darktheme .theme-li {
  9. &:hover {
  10. background-color: #262626;
  11. }
  12. }
  13. .theme-toggle {
  14. --ease-3: cubic-bezier(.25, 0, .3, 1);
  15. --ease-out-5: cubic-bezier(0, 0, 0, 1);
  16. --ease-elastic-3: cubic-bezier(.5, 1.25, .75, 1.25);
  17. --ease-elastic-4: cubic-bezier(.5, 1.5, .75, 1.25);
  18. --size: 2rem;
  19. --icon-fill: #abb3ba;
  20. --icon-fill-hover: #e2e6e9;
  21. -webkit-tap-highlight-color: transparent;
  22. aspect-ratio: 1;
  23. background: none;
  24. block-size: var(--size);
  25. border: none;
  26. border-radius: 50%;
  27. cursor: pointer;
  28. inline-size: var(--size);
  29. outline-offset: 5px;
  30. padding: 0;
  31. touch-action: manipulation;
  32. > svg {
  33. stroke-linecap: round;
  34. block-size: 100%;
  35. inline-size: 100%;
  36. }
  37. }
  38. [data-mode=dark].theme-toggle {
  39. --icon-fill: #454d54;
  40. --icon-fill-hover: #22262a;
  41. }
  42. @media (hover: none) {
  43. .theme-toggle {
  44. --size: 48px;
  45. }
  46. }
  47. @media (max-width: 767px) {
  48. .theme-toggle {
  49. --size: 24px;
  50. }
  51. [data-mode=dark].theme-toggle {
  52. --icon-fill: #abb3ba;
  53. --icon-fill-hover: #e2e6e9;
  54. }
  55. }
  56. .sun-and-moon {
  57. > .moon, > .sun, > .sun-beams {
  58. transform-origin: center center;
  59. }
  60. > .moon, > .sun {
  61. fill: var(--icon-fill);
  62. }
  63. > .sun-beams {
  64. stroke: var(--icon-fill);
  65. stroke-width: 2px;
  66. }
  67. }
  68. .theme-toggle:hover > .sun-and-moon {
  69. > .moon, > .sun {
  70. fill: var(--icon-fill-hover);
  71. }
  72. > .sun-beams {
  73. stroke: var(--icon-fill-hover);
  74. }
  75. }
  76. .theme-toggle:focus-visible > .sun-and-moon {
  77. > .moon, > .sun {
  78. fill: var(--icon-fill-hover);
  79. }
  80. > .sun-beams {
  81. stroke: var(--icon-fill-hover);
  82. }
  83. }
  84. [data-mode=light] .sun-and-moon {
  85. > .sun {
  86. transform: scale(1.75);
  87. }
  88. > .sun-beams {
  89. opacity: 0;
  90. }
  91. > .moon > circle {
  92. transform: translate(-7px);
  93. }
  94. }
  95. @supports (cx:1) {
  96. [data-mode=light] .sun-and-moon > .moon > circle {
  97. cx: 17;
  98. transform: translate(0);
  99. }
  100. }
  101. @media (prefers-reduced-motion: no-preference) {
  102. .sun-and-moon {
  103. > .sun {
  104. transition: transform .5s var(--ease-elastic-3);
  105. }
  106. > .sun-beams {
  107. transition: transform .5s var(--ease-elastic-4), opacity .5s var(--ease-3);
  108. }
  109. .moon > circle {
  110. transition: transform .25s var(--ease-out-5);
  111. }
  112. }
  113. @supports (cx:1) {
  114. .sun-and-moon .moon > circle {
  115. transition: cx .25s var(--ease-out-5);
  116. }
  117. }
  118. [data-mode=light] .sun-and-moon {
  119. > .sun {
  120. transform: scale(1.75);
  121. transition-duration: .25s;
  122. transition-timing-function: var(--ease-3);
  123. }
  124. > .sun-beams {
  125. transform: rotate(-25deg);
  126. transition-duration: .15s;
  127. }
  128. > .moon > circle {
  129. transition-delay: .25s;
  130. transition-duration: .5s;
  131. }
  132. }
  133. }