toolbar.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <script setup lang="ts">
  2. import type { ToolbarType } from './types';
  3. import { computed } from 'vue';
  4. import {
  5. AuthenticationColorToggle,
  6. AuthenticationLayoutToggle,
  7. LanguageToggle,
  8. ThemeToggle,
  9. } from '../widgets';
  10. interface Props {
  11. toolbarList?: ToolbarType[];
  12. }
  13. defineOptions({
  14. name: 'AuthenticationToolbar',
  15. });
  16. const props = withDefaults(defineProps<Props>(), {
  17. toolbarList: () => ['color', 'language', 'layout', 'theme'],
  18. });
  19. const showColor = computed(() => props.toolbarList.includes('color'));
  20. const showLayout = computed(() => props.toolbarList.includes('layout'));
  21. const showLanguage = computed(() => props.toolbarList.includes('language'));
  22. const showTheme = computed(() => props.toolbarList.includes('theme'));
  23. </script>
  24. <template>
  25. <div
  26. :class="{
  27. 'bg-accent z-10 rounded-3xl px-3 py-1': 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>