SubTitle.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <script setup lang="ts">
  2. import { useTheme, type ThemePaddingMargin, type ThemePaddingMarginProp } from '@/components/theme/ThemeDefine';
  3. import Icon from '@/components/basic/Icon.vue';
  4. import Text, { type TextProps } from '@/components/basic/Text.vue';
  5. import Touchable from '@/components/feedback/Touchable.vue';
  6. import FlexRow from '@/components/layout/FlexRow.vue';
  7. import Width from '@/components/layout/space/Width.vue';
  8. defineEmits([ 'moreClicked' ])
  9. const props = withDefaults(defineProps<{
  10. title?: string,
  11. moreText?: string,
  12. showMore?: boolean,
  13. badgeColor?: string,
  14. backgroundColor?: string,
  15. padding?: ThemePaddingMarginProp,
  16. titleProps?: TextProps,
  17. badgeStyle?: object,
  18. }>(), {
  19. title: '',
  20. moreText: '更多',
  21. showMore: false,
  22. badgeColor: 'primary',
  23. padding: () => [ 0, 0, 30, 0 ],
  24. })
  25. const theme = useTheme();
  26. const finalBadgeStyle = theme.useThemeStyle({
  27. width: '10rpx',
  28. height: '32rpx',
  29. borderRadius: '5rpx',
  30. marginRight: '14rpx',
  31. ...props.badgeStyle,
  32. })
  33. </script>
  34. <template>
  35. <FlexRow
  36. justify="space-between"
  37. align="center"
  38. :padding="padding"
  39. :backgroundColor="backgroundColor"
  40. >
  41. <FlexRow align="center">
  42. <slot name="icon">
  43. <view :style="{
  44. ...finalBadgeStyle,
  45. backgroundColor: theme.resolveThemeColor(badgeColor),
  46. }"></view>
  47. </slot>
  48. <slot name="titlePrefix" />
  49. <Text fontConfig="h4" :text="title" v-bind="titleProps" />
  50. <slot name="titleSuffix" />
  51. </FlexRow>
  52. <FlexRow align="center">
  53. <slot name="right" />
  54. <Touchable v-if="showMore" align="center" touchable @click="$emit('moreClicked')">
  55. <Text fontConfig="subText" :text="moreText" />
  56. <Width :size="10" />
  57. <Icon icon="arrow-right" :size="26" />
  58. </Touchable>
  59. </FlexRow>
  60. </FlexRow>
  61. </template>