<wxs src="../wxs/utils.wxs" module="utils" />
<wxs src="./index.wxs" module="computed" />

<view
  wx:if="{{ fixed && placeholder }}"
  class="smart-nav-bar__placeholder{{ safeAreaInsetTop ? ' smart-nav-bar__placeholder--safe' : '' }}{{ round ? ' smart-nav-bar__placeholder--round' : '' }}"
/>

<view
  class="{{ utils.bem('nav-bar', { fixed, round, safe: safeAreaInsetTop }) }} custom-class {{ border ? 'smart-hairline--bottom' : '' }}"
  style="{{ computed.barStyle({ zIndex, background }) }}; {{ customStyle }}"
>
  <view class="smart-nav-bar__content">
    <view class="{{ computed.leftClass({ sideWidth, leftTextType, leftText, leftArrow, leftIcon }) }}" style="{{ computed.sideStyle({ sideWidth }) }}" bind:tap="onClickLeft">
      <smart-icon
        wx:if="{{ leftArrow }}"
        size="24px"
        hover-class="smart-nav-bar__icon--hover"
        hover-stay-time="70"
        name="{{ leftArrowIcon }}"
        data-type="leftArrow"
        aria-role="button"
        aria-label="{{ leftArrowAriaLabel }}"
        custom-class="smart-nav-bar__arrow"
      />
      <view
        wx:if="{{ leftIcon }}"
        data-type="leftIcon"
        hover-class="smart-nav-bar__icon--hover"
        hover-stay-time="70"
        class="smart-nav-bar__icon-wrap"
        catch:tap="onClickLeftIcon"
        aria-role="button"
        role="button"
        aria-label="{{ leftIconAriaLabel }}"
      >
        <smart-icon 
         class="left-icon-class" 
         custom-class="smart-nav-bar__icon" 
         size="{{ leftIconSize }}" 
         name="{{ leftIcon }}" 
         color="{{ leftIconColor }}" 
        />
      </view>
      <view
        wx:if="{{ leftText }}"
        class="smart-nav-bar__text left-text-class"
        catch:tap="onClickLeftText"
        hover-class="{{ leftTextType === 'back' ? 'smart-nav-bar__text--hover' : '' }}"
        hover-stay-time="70"
      >
        {{ leftText }}
      </view>
      <slot name="left" />
    </view>
    <view class="smart-nav-bar__title title-class smart-ellipsis" bind:tap="onClickTitle">
      <block>{{ title }}</block>
      <slot name="title" />
    </view>
    <view class="{{ computed.rightClass({ sideWidth, rightText }) }}" style="{{ computed.sideStyle({ sideWidth }) }}" bind:tap="onClickRight">
      <view
        wx:if="{{ rightIcon }}"
        data-type="rightIcon"
        hover-class="smart-nav-bar__icon--hover"
        hover-stay-time="70"
        class="smart-nav-bar__icon-wrap"
        bind:tap="onClickRightIcon"
        aria-role="button"
        role="button"
        aria-label="{{ rightIconAriaLabel }}"
      >
        <smart-icon class="right-icon-class" custom-class="smart-nav-bar__icon" size="{{ rightIconSize }}" name="{{ rightIcon }}" color="{{ rightIconColor }}" />
      </view>
      <view
        wx:if="{{ rightText }}"
        class="smart-nav-bar__text right-text-class"
        style="color: {{ rightTextColor }};"
        hover-class="smart-nav-bar__text--hover"
        hover-stay-time="70"
        bind:tap="onClickRightText"
      >
        {{ rightText }}
      </view>
      <slot name="right" />
    </view>
  </view>
</view>
