SubTitle.vue 1.9 KB

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