toolbar.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <script setup lang="ts">
  2. import { computed } from 'vue';
  3. import {
  4. AuthenticationColorToggle,
  5. AuthenticationLayoutToggle,
  6. LanguageToggle,
  7. ThemeToggle,
  8. } from '../widgets';
  9. interface Props {
  10. toolbarList?: ('color' | 'language' | 'layout' | 'theme')[];
  11. }
  12. defineOptions({
  13. name: 'AuthenticationToolbar',
  14. });
  15. const props = withDefaults(defineProps<Props>(), {
  16. toolbarList: () => ['color', 'language', 'layout', 'theme'],
  17. });
  18. const showColor = computed(() => props.toolbarList.includes('color'));
  19. const showLayout = computed(() => props.toolbarList.includes('layout'));
  20. const showLanguage = computed(() => props.toolbarList.includes('language'));
  21. const showTheme = computed(() => props.toolbarList.includes('theme'));
  22. </script>
  23. <template>
  24. <div
  25. :class="{
  26. 'bg-background dark:bg-accent rounded-3xl px-3 py-1':
  27. toolbarList.length > 1,
  28. }"
  29. class="flex-center absolute right-2 top-4"
  30. >
  31. <!-- Only show on medium and larger screens -->
  32. <div class="hidden md:flex">
  33. <AuthenticationColorToggle v-if="showColor" />
  34. <AuthenticationLayoutToggle v-if="showLayout" />
  35. </div>
  36. <!-- Always show Language and Theme toggles -->
  37. <LanguageToggle v-if="showLanguage" />
  38. <ThemeToggle v-if="showTheme" />
  39. </div>
  40. </template>