Divider.vue 682 B

12345678910111213141516171819202122232425262728293031323334
  1. <template>
  2. <div :class="['divider', type]"
  3. :style="{
  4. margin: type === 'horizontal' ? `${margin >= 0 ? margin : 24}px 0` : `0 ${margin >= 0 ? margin : 8}px`
  5. }"
  6. ></div>
  7. </template>
  8. <script lang="ts" setup>
  9. withDefaults(defineProps<{
  10. type?: 'horizontal' | 'vertical'
  11. margin?: number
  12. }>(), {
  13. type: 'horizontal',
  14. margin: -1,
  15. })
  16. </script>
  17. <style lang="scss" scoped>
  18. .divider {
  19. &.horizontal {
  20. width: 100%;
  21. margin: 24px 0;
  22. border-block-start: 1px solid rgba(5, 5, 5, .06);
  23. }
  24. &.vertical {
  25. position: relative;
  26. height: 1em;
  27. display: inline-block;
  28. margin: 0 8px;
  29. border-inline-start: 1px solid rgba(5, 5, 5, .06);
  30. }
  31. }
  32. </style>