toolbar.vue 1.4 KB

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