tab-bar-item.wxml 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <wxs src="../common/utils.wxs" module="_" />
  2. <view
  3. style="{{ customStyle }}"
  4. class="{{_.cls(classPrefix, [['split', split], ['text-only', !icon], ['crowded', crowded], shape])}}"
  5. >
  6. <view
  7. class="{{_.cls(classPrefix + '__content', [['checked', isChecked], theme])}}"
  8. hover-class="{{classPrefix}}__content--active"
  9. hover-stay-time="{{200}}"
  10. bindtap="toggle"
  11. aria-selected="{{(!hasChildren || !isSpread) && isChecked ? true : false}}"
  12. aria-expanded="{{hasChildren && isSpread ? true : ''}}"
  13. aria-role="{{hasChildren ? 'button' : 'tab'}}"
  14. >
  15. <view wx:if="{{icon}}" class="{{classPrefix}}__icon" style="height: {{iconOnly ? 24 : 20}}px">
  16. <t-badge
  17. wx:if="{{badgeProps.dot || badgeProps.count}}"
  18. count="{{badgeProps.count}}"
  19. max-count="{{badgeProps.maxCount || 99}}"
  20. dot="{{badgeProps.dot}}"
  21. content="{{badgeProps.content}}"
  22. size="{{badgeProps.size}}"
  23. visible="{{badgeProps.visible}}"
  24. offset="{{badgeProps.offset || [0,0]}}"
  25. t-class-count="{{prefix + '-badge-class'}}"
  26. >
  27. <t-icon name="{{icon}}" size="{{iconOnly ? 24 : 20}}" />
  28. </t-badge>
  29. <t-icon
  30. wx:else
  31. name="{{icon}}"
  32. size="{{iconOnly ? 24 : 20}}"
  33. aria-label="{{ariaLabel}}"
  34. aria-hidden="{{iconOnly ? false : true}}"
  35. />
  36. <slot name="icon" />
  37. </view>
  38. <view class="{{_.cls(classPrefix + '__text', [['small', !!icon]])}}">
  39. <t-icon wx:if="{{hasChildren}}" name="view-list" size="16" class="{{classPrefix}}__icon-menu" />
  40. <slot />
  41. </view>
  42. </view>
  43. <view class="{{classPrefix}}__spread" wx:if="{{hasChildren && isSpread}}">
  44. <view
  45. class="{{classPrefix}}__spread-item"
  46. hover-class="{{classPrefix}}__spread-item--active"
  47. hover-stay-time="{{200}}"
  48. wx:for="{{subTabBar}}"
  49. wx:for-item="child"
  50. wx:for-index="index"
  51. wx:key="index"
  52. bind:tap="selectChild"
  53. data-value="{{child.value || index}}"
  54. aria-role="tab"
  55. >
  56. <view class="{{classPrefix}}__spread-item-split" wx:if="{{index !== 0}}" />
  57. <view class="{{classPrefix}}__spread-item-text" data-value="{{child.value || index}}">{{ child.label }}</view>
  58. </view>
  59. </view>
  60. </view>