theme.uvue 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <template>
  2. <cl-float-view :size="40" :left="20" :bottom="20" :gap="20" v-if="config.showDarkButton">
  3. <view class="theme-set" @tap="toggleTheme()">
  4. <view class="theme-set__inner" :class="{ 'is-dark': isDark }">
  5. <view class="theme-set__icon" v-for="item in list" :key="item">
  6. <cl-icon :name="item" color="white" size="18px"></cl-icon>
  7. </view>
  8. </view>
  9. </view>
  10. </cl-float-view>
  11. </template>
  12. <script setup lang="ts">
  13. import { config } from "@/config";
  14. import { isDark, toggleTheme } from "@/cool";
  15. defineOptions({
  16. name: "cl-page-theme"
  17. });
  18. const list = ["moon-fill", "sun-fill"];
  19. </script>
  20. <style lang="scss" scoped>
  21. .theme-set {
  22. @apply flex flex-col items-center justify-center rounded-full h-full w-full;
  23. @apply bg-primary-500;
  24. &__inner {
  25. @apply flex flex-col duration-300;
  26. transform: translateY(20px);
  27. transition-property: transform;
  28. &.is-dark {
  29. transform: translateY(-20px);
  30. }
  31. }
  32. &__icon {
  33. @apply flex items-center justify-center;
  34. height: 40px;
  35. width: 40px;
  36. }
  37. }
  38. </style>