tabs.wxml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <import src="../common/template/badge.wxml" />
  2. <import src="../common/template/icon.wxml" />
  3. <wxs src="./tabs.wxs" module="filters" />
  4. <wxs src="../common/utils.wxs" module="_" />
  5. <view style="{{_._style([style, customStyle])}}" class="{{_.cls(classPrefix, [placement])}} {{prefix}}-class">
  6. <t-sticky
  7. t-class="{{_.cls(classPrefix + '__sticky', [placement])}}"
  8. disabled="{{ !sticky }}"
  9. z-index="{{ stickyProps.zIndex || '1' }}"
  10. offset-top="{{ stickyProps.offsetTop || 0 }}"
  11. container="{{ stickyProps.container }}"
  12. bind:scroll="onTouchScroll"
  13. >
  14. <view class="{{_.cls(classPrefix + '__wrapper', [theme])}}">
  15. <scroll-view
  16. class="{{_.cls(classPrefix + '__scroll', [placement])}}"
  17. enable-flex
  18. scroll-left="{{offset}}"
  19. scroll-x="{{isScrollX}}"
  20. scroll-y="{{isScrollY}}"
  21. scroll-with-animation
  22. >
  23. <view class="{{_.cls(classPrefix + '__nav', [placement])}}" aria-role="tablist">
  24. <view
  25. wx:for="{{tabs}}"
  26. wx:key="index"
  27. data-index="{{index}}"
  28. class="{{_.cls(classPrefix + '__item', [theme, ['evenly', spaceEvenly], placement, ['disabled', item.disabled], ['active', currentIndex === index]])}} {{currentIndex === index ? prefix + '-class-active' : ''}} {{prefix}}-class-item"
  29. bind:tap="onTabTap"
  30. aria-role="tab"
  31. aria-controls="{{tabID + '_panel_' + index}}"
  32. aria-selected="{{currentIndex === index}}"
  33. aria-disabled="{{item.disabled}}"
  34. >
  35. <view class="{{_.cls(classPrefix + '__item-inner', [theme, ['active', currentIndex === index]])}}">
  36. <template wx:if="{{item.icon}}" is="icon" data="{{ class: classPrefix + '__icon', ...item.icon }}" />
  37. <block wx:if="{{item.badgeProps}}">
  38. <template is="badge" data="{{ ...item.badgeProps, content: item.label }}" />
  39. </block>
  40. <block wx:else>{{item.label}}</block>
  41. </view>
  42. <view wx:if="{{theme == 'card' && currentIndex - 1 == index}}" class="{{classPrefix}}__item-prefix" />
  43. <view wx:if="{{theme == 'card' && currentIndex + 1 == index}}" class="{{classPrefix}}__item-suffix" />
  44. </view>
  45. <view
  46. wx:if="{{theme == 'line' && showBottomLine}}"
  47. class="{{_.cls(classPrefix + '__track', [placement])}} {{prefix}}-class-track"
  48. style="{{trackStyle}}"
  49. />
  50. </view>
  51. </scroll-view>
  52. </view>
  53. </t-sticky>
  54. <view
  55. class="{{_.cls(classPrefix + '__content', [['animated', animation]])}}"
  56. bind:touchstart="onTouchStart"
  57. bind:touchmove="onTouchMove"
  58. bind:touchend="onTouchEnd"
  59. bind:touchcancel="onTouchEnd"
  60. >
  61. <view
  62. class="{{classPrefix}}__content-inner"
  63. style="{{ filters.animate({duration: animation.duration, currentIndex:currentIndex, direction}) }}"
  64. >
  65. <slot />
  66. </view>
  67. </view>
  68. </view>