SkeletonButton.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <BaseBox
  3. v-bind="props"
  4. :inner-style="{
  5. ...selectStyleType(props.size, 'medium', {
  6. small: themeStyles.skeletonButtonSm.value,
  7. medium: themeStyles.skeletonButtonMd.value,
  8. large: themeStyles.skeletonButtonLg.value,
  9. }),
  10. ...themeStyles.skeletonButton.value,
  11. ...props.innerStyle,
  12. }"
  13. />
  14. </template>
  15. <script setup lang="ts">
  16. import { useTheme } from '@/components/theme/ThemeDefine';
  17. import { DynamicSize, selectStyleType } from '@/components/theme/ThemeTools';
  18. import BaseBox, { type SkeletonItemSize, type SleletonBaseBoxProps } from './SkeletonBaseBox.vue';
  19. const themeContext = useTheme();
  20. const themeStyles = themeContext.useThemeStyles({
  21. skeletonButton: {
  22. borderRadius: DynamicSize('SkeletonButtonRadius', 10),
  23. },
  24. skeletonButtonSm: {
  25. width: DynamicSize('SkeletonButtonWidth', 60),
  26. height: DynamicSize('SkeletonButtonHeight', 42),
  27. },
  28. skeletonButtonMd: {
  29. width: DynamicSize('SkeletonButtonWidth', 155),
  30. height: DynamicSize('SkeletonButtonHeight', 82),
  31. },
  32. skeletonButtonLg: {
  33. width: DynamicSize('SkeletonButtonWidth', 180),
  34. height: DynamicSize('SkeletonButtonHeight', 100),
  35. },
  36. });
  37. /**
  38. * 标题占位组件
  39. */
  40. export interface SkeletonButtonProps extends SleletonBaseBoxProps {
  41. /**
  42. * 大小预设
  43. * @default 'medium'
  44. */
  45. size?: SkeletonItemSize,
  46. }
  47. const props = withDefaults(defineProps<SkeletonButtonProps>(), {
  48. size: 'medium',
  49. });
  50. defineOptions({
  51. options: {
  52. virtualHost: true,
  53. styleIsolation: "shared",
  54. },
  55. });
  56. </script>