SkeletonBaseBox.vue 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <template>
  2. <view
  3. :class="[
  4. 'nana-skeleton',
  5. type,
  6. { 'anim': context.active.value }
  7. ]"
  8. :style="{
  9. 'background-color': context.color.value,
  10. 'width': themeContext.resolveSize(props.width),
  11. 'height': themeContext.resolveSize(props.height),
  12. ...props.innerStyle,
  13. }"
  14. >
  15. <view class="anim-box" />
  16. </view>
  17. </template>
  18. <script setup lang="ts">
  19. import { inject } from 'vue';
  20. import type { SkeletonContext } from '../Skeleton.vue';
  21. import { useTheme, type ViewStyle } from '@/components/theme/ThemeDefine';
  22. const context = inject('SkeletonContext') as SkeletonContext;
  23. const themeContext = useTheme();
  24. export type SkeletonItemSize = 'small'|'medium'|'large';
  25. export interface SleletonBaseBoxProps {
  26. width?: number;
  27. height?: number;
  28. innerStyle?: ViewStyle,
  29. type?: string,
  30. }
  31. const props = withDefaults(defineProps<SleletonBaseBoxProps>(), {
  32. type: 'base-box',
  33. });
  34. defineOptions({
  35. options: {
  36. virtualHost: true,
  37. styleIsolation: "shared",
  38. },
  39. });
  40. </script>