layout-tabbar.vue 855 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <script setup lang="ts">
  2. import type { CSSProperties } from 'vue';
  3. import { computed } from 'vue';
  4. interface Props {
  5. /**
  6. * 背景颜色
  7. */
  8. backgroundColor?: string;
  9. /**
  10. * 高度
  11. * @default 30
  12. */
  13. height?: number;
  14. }
  15. const props = withDefaults(defineProps<Props>(), {
  16. backgroundColor: 'hsl(var(--background))',
  17. fixed: true,
  18. height: 30,
  19. });
  20. const hiddenStyle = computed((): CSSProperties => {
  21. const { height } = props;
  22. return {
  23. height: `${height}px`,
  24. };
  25. });
  26. const style = computed((): CSSProperties => {
  27. const { backgroundColor } = props;
  28. return {
  29. ...hiddenStyle.value,
  30. backgroundColor,
  31. };
  32. });
  33. </script>
  34. <template>
  35. <section :style="style" class="border-border flex w-full">
  36. <slot></slot>
  37. <div class="flex items-center">
  38. <slot name="toolbar"></slot>
  39. </div>
  40. </section>
  41. </template>