layout-tabs.vue 931 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. defineOptions({ name: 'LayoutTabs' });
  16. const props = withDefaults(defineProps<Props>(), {
  17. backgroundColor: 'hsl(var(--color-background))',
  18. fixed: true,
  19. height: 30,
  20. });
  21. const hiddenStyle = computed((): CSSProperties => {
  22. const { height } = props;
  23. return {
  24. height: `${height}px`,
  25. };
  26. });
  27. const style = computed((): CSSProperties => {
  28. const { backgroundColor } = props;
  29. return {
  30. ...hiddenStyle.value,
  31. backgroundColor,
  32. display: 'flex',
  33. };
  34. });
  35. </script>
  36. <template>
  37. <section :style="style" class="border-border flex w-full border-b">
  38. <slot></slot>
  39. <div class="flex items-center">
  40. <slot name="toolbar"></slot>
  41. </div>
  42. </section>
  43. </template>