All files / element-ng/navbar-vertical si-navbar-vertical.component.html

65.88% Statements 56/85
54.54% Branches 24/44
66.66% Functions 2/3
67.6% Lines 48/71

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 18855x 55x     14x   55x 55x               55x       5x   14x   55x   14x     55x 14x 55x 14x     55x       14x 14x     55x 1x   55x 14x     14x 55x 96x 26x 78x               18x     14x     14x     55x   14x 14x   14x 18x 5x 5x     18x                   18x 5x                                                                                                                     7x 31x   22x 4x 4x   22x                       22x 4x                           7x    
@if (visible()) {
  @if (smallScreen() && !collapsed()) {
    <div class="modal-backdrop" animate.leave="backdrop-leave" (click)="toggleCollapse()"></div>
  }
  <nav
    class="background-1"
    [class.expanded]="!collapsed()"
    [siSkipLinkTarget]="skipLinkNavigationLabel()"
    [class.text-only]="textOnly()"
  >
    <div class="collapse-toggle ms-auto">
      <div class="mobile-drawer focus-inside navbar-vertical-no-collapse">
        <button
          type="button"
          class="btn btn-icon btn-tertiary-ghost"
          [attr.aria-label]="
            (collapsed() ? navbarExpandButtonText() : navbarCollapseButtonText()) | translate
          "
          [attr.aria-expanded]="!collapsed()"
          (click)="toggleCollapse()"
        >
          <si-icon
            class="flip-rtl"
            [icon]="collapsed() ? icons.elementDoubleRight : icons.elementDoubleLeft"
          />
        </button>
      </div>
    </div>
    @if (searchable()) {
      <div class="nav-search">
        <si-search-bar class="mx-4" colorVariant="base-0" [showIcon]="true">
          <input
            #searchInput
            siSearchBarInput
            [formField]="searchField"
            [placeholder]="searchPlaceholder() | translate"
            [attr.aria-label]="searchPlaceholder() | translate"
          />
        </si-search-bar>
        <button
          type="button"
          class="btn-search background-0 px-3 mx-4 mobile navbar-vertical-no-collapse text-secondary"
          [attr.aria-label]="searchPlaceholder() | translate"
          (click)="expandForSearch()"
        >
          <si-icon class="icon" [icon]="icons.elementSearch" />
        </button>
      </div>
    }
    <div class="nav-scroll">
      @for (item of items(); track $index) {
        @if (isLegacyStyle(item)) {
          <si-navbar-vertical-item-legacy
            [item]="item"
            [navbarExpandButtonText]="navbarExpandButtonText() | translate"
            [navbarCollapseButtonText]="navbarCollapseButtonText() | translate"
            [expanded]="
              (item.id ? uiStateExpandedItems()[item.id] : undefined) ?? item.expanded ?? false
            "
          />
        } @else {
          <ng-container *ngTemplateOutlet="navbarItems; context: { item }" />
        }
      }
    </div>
  </nav>
}
<main
  class="si-layout-inner focus-none"
  tabindex="-1"
  [siSkipLinkTarget]="skipLinkMainContentLabel()"
>
  <ng-content />
</main>
 
<ng-template #navbarItems let-item="item" siNavbarVerticalItemGuard>
  @switch (item.type) {
    @case ('group') {
      <button
        type="button"
        placement="end"
        [si-navbar-vertical-item]="item"
        [stateId]="item.id"
        [siNavbarVerticalGroupTriggerFor]="group"
        [groupData]="{ group: item }"
        [expanded]="
          (item.id ? uiStateExpandedItems()[item.id] : undefined) ?? item.expanded ?? false
        "
        [siTooltip]="item.label | translate"
        [isDisabled]="!collapsed()"
      >
        {{ item.label | translate }}
      </button>
    }
    @case ('action') {
      <button
        type="button"
        placement="end"
        [si-navbar-vertical-item]="item"
        [activeOverride]="item.active"
        [siTooltip]="item.label | translate"
        [isDisabled]="!collapsed()"
      >
        {{ item.label | translate }}
      </button>
    }
    @case ('router-link') {
      <a
        routerLinkActive
        placement="end"
        [routerLinkActiveOptions]="item.activeMatchOptions ?? { exact: false }"
        [si-navbar-vertical-item]="item"
        [routerLink]="item.routerLink"
        [queryParams]="item.extras?.queryParams"
        [queryParamsHandling]="item.extras?.queryParamsHandling"
        [fragment]="item.extras?.fragment"
        [state]="item.extras?.state"
        [relativeTo]="item.extras?.relativeTo ?? this.activatedRoute"
        [preserveFragment]="item.extras?.preserveFragment"
        [skipLocationChange]="item.extras?.skipLocationChange"
        [replaceUrl]="item.extras?.replaceUrl"
        [siTooltip]="item.label | translate"
        [isDisabled]="!collapsed()"
      >
        {{ item.label | translate }}
      </a>
    }
    @case ('link') {
      <a
        placement="end"
        [si-navbar-vertical-item]="item"
        [href]="item.href"
        [target]="item.target"
        [siTooltip]="item.label | translate"
        [isDisabled]="!collapsed()"
      >
        {{ item.label | translate }}
      </a>
    }
    @case ('divider') {
      <si-navbar-vertical-divider />
    }
    @case ('header') {
      <si-navbar-vertical-header>
        {{ item.label | translate }}
      </si-navbar-vertical-header>
    }
  }
</ng-template>
 
<ng-template #group let-group="group" siNavbarVerticalItemGuard>
  <si-navbar-vertical-group routerLinkActive>
    @for (item of group.children; track $index) {
      <!-- a copy from above, but we have to nest the items to make routerLink active work -->
      @switch (item.type) {
        @case ('router-link') {
          <a
            routerLinkActive
            [routerLinkActiveOptions]="item.activeMatchOptions ?? { exact: false }"
            [si-navbar-vertical-item]="item"
            [routerLink]="item.routerLink"
            [queryParams]="item.extras?.queryParams"
            [queryParamsHandling]="item.extras?.queryParamsHandling"
            [fragment]="item.extras?.fragment"
            [state]="item.extras?.state"
            [relativeTo]="item.extras?.relativeTo ?? this.activatedRoute"
            [preserveFragment]="item.extras?.preserveFragment"
            [skipLocationChange]="item.extras?.skipLocationChange"
            [replaceUrl]="item.extras?.replaceUrl"
          >
            {{ item.label | translate }}
          </a>
        }
        @case ('action') {
          <button type="button" [si-navbar-vertical-item]="item" [activeOverride]="item.active">
            {{ item.label | translate }}
          </button>
        }
        @case ('link') {
          <a [si-navbar-vertical-item]="item" [href]="item.href" [target]="item.target">
            {{ item.label | translate }}
          </a>
        }
      }
    }
  </si-navbar-vertical-group>
</ng-template>