ImageButton.vue 963 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <template>
  2. <Touchable
  3. :activeOpacity="activeOpacity"
  4. :touchable="touchable"
  5. :innerStyle="innerStyle"
  6. position="relative"
  7. center
  8. @click="emit('click')"
  9. >
  10. <Image v-bind="props" :innerStyle="imageStyle" />
  11. <slot>
  12. <FlexCol center position="absolute" inset="0">
  13. <Text v-if="text" :text="text" v-bind="textProps" />
  14. </FlexCol>
  15. </slot>
  16. </Touchable>
  17. </template>
  18. <script setup lang="ts">
  19. import Touchable from '../feedback/Touchable.vue';
  20. import FlexCol from '../layout/FlexCol.vue';
  21. import type { ImageProps } from './Image.vue';
  22. import Image from './Image.vue';
  23. import Text from './Text.vue';
  24. import type { TextProps } from './Text';
  25. const props = withDefaults(defineProps<ImageProps & {
  26. activeOpacity?: number;
  27. touchable?: boolean;
  28. text?: string;
  29. textProps?: TextProps;
  30. imageStyle?: object;
  31. }>(), {
  32. activeOpacity: 0.7,
  33. touchable: true,
  34. });
  35. const emit = defineEmits(['click']);
  36. </script>