wd-gap.vue 864 B

123456789101112131415161718192021222324252627282930313233343536
  1. <template>
  2. <view :class="`wd-gap ${safeAreaBottom ? 'wd-gap--safe' : ''} ${customClass}`" :style="rootStyle"></view>
  3. </template>
  4. <script lang="ts">
  5. export default {
  6. name: 'wd-gap',
  7. options: {
  8. addGlobalClass: true,
  9. virtualHost: true,
  10. styleIsolation: 'shared'
  11. }
  12. }
  13. </script>
  14. <script setup lang="ts">
  15. import { type CSSProperties, computed } from 'vue'
  16. import { addUnit, isDef, objToStyle } from '../common/util'
  17. import { gapProps } from './types'
  18. const props = defineProps(gapProps)
  19. const rootStyle = computed(() => {
  20. const rootStyle: CSSProperties = {}
  21. if (isDef(props.bgColor)) {
  22. rootStyle['background'] = props.bgColor
  23. }
  24. if (isDef(props.height)) {
  25. rootStyle['height'] = addUnit(props.height)
  26. }
  27. return `${objToStyle(rootStyle)}${props.customStyle}`
  28. })
  29. </script>
  30. <style lang="scss" scoped>
  31. @import './index.scss';
  32. </style>