# All files BreadcrumbsContainer.vue

98.65% Statements 147/149
87.5% Branches 7/8
100% Functions 4/4
98.65% Lines 147/149

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
    1501x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    3x
    3x
    3x
    3x
    3x
    3x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    3x

    3x
    1x
    1x
    16x
    2x
    16x
    14x
    14x
    1x
    1x
    4x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
     <template>
      <div>
        <div
          ref="answerBox"
          v-resize="calcIsMore"
          class="answer-box"
          :class="{ 'show-more': !showMore }"
          data-test="answerBox"
        >
          <div v-for="(item, index) in breadcrumbs" class="answer" data-test="breadcrumbs" :key="`answer-${index}`">
            <span class="NavigatorSummaryKeyClass">{{ item.label ? item.label + ":" : "" }} </span>

            <span v-if="showIconForError && isErrorType(item.type)" :class="getValueClass(item.type)">
              <v-tooltip location="top" max-width="350px">
                <template v-slot:activator="{ props }">
                  <v-icon v-bind="props">mdi-close-circle-outline</v-icon>
                </template>
                <span>{{ item.value }}</span>
              </v-tooltip>
            </span>

            <span v-else :class="getValueClass(item.type)">{{ item.value }}</span>
          </div>
        </div>
        <div v-if="showMoreLess" class="more" data-test="moreLessButton" @click="showMore = !showMore">
          {{ showMore ? "More..." : "Less" }}
        </div>
      </div>
    </template>

    <script setup>
    import { unref } from "vue";
    import { ref, watch, nextTick, toRefs } from "vue";

    const showMore = ref(true);
    const showMoreLess = ref(false);
    const answerBoxOverflowHeight = ref(Number.MAX_SAFE_INTEGER);
    const answerBox = ref(null);

    const props = defineProps({
      breadcrumbs: {
        type: Array,
        default: () => [],
      },
      showIconForError: {
        type: Boolean,
        default: false,
      },
    });

    const { breadcrumbs } = toRefs(props);

    watch(
      breadcrumbs,
      (val) => {
        if (val && val.length > 0) {
          // Wait until the virtual dom is updated to calc heights
          nextTick(() => {
            calcIsMore();
          });
        }
      },
      {
        flush: "post",
      },
    );

    const calcIsMore = () => {
      if (unref(answerBox).clientHeight < unref(answerBox).scrollHeight - 8) {
        answerBoxOverflowHeight.value = unref(answerBox).clientHeight;
      }
      showMoreLess.value = unref(answerBoxOverflowHeight) < unref(answerBox).scrollHeight - 8;
    };
    const getValueClass = (type) => {
      if (type === "warning") {
        return "NavigatorSummaryWarningValueClass";
      } else {
        return "NavigatorSummaryValueClass";
      }
    };
    const isErrorType = (type) => {
      return type === "warning";
    };
    defineExpose({
      calcIsMore,
      showMoreLess,
    });
    </script>

    <style lang="scss">
    $line-height: 1.42rem; // Approximation of line height (`lh` not available)

    .breadcrumbs-container {
      color: var(--vscode-foreground, #616161);
      .answer-box {
        /* 5 lines */
        max-height: calc(5 * #{$line-height});
        transition: 0.3s max-height ease-in-out;
        overflow: hidden;
        &.show-more {
          max-height: calc(100 * #{$line-height});
        }
        .answer {
          padding-top: 5px;
          padding-bottom: 5px;
          text-overflow: ellipsis;
          overflow: hidden;
          display: -webkit-box;
          -webkit-line-clamp: 3;
          -webkit-box-orient: vertical;
          line-break: anywhere;
          &:first-child {
            padding-top: 0px;
          }
        }
        .answer span:first-child {
          font-weight: 700;
          text-transform: capitalize;
        }
      }
      .more {
        color: var(--vscode-textLink-foreground, #3794ff);
        text-decoration-line: underline;
        cursor: pointer;
        padding-top: 5px;
        width: fit-content;
        &:hover {
          text-decoration-line: none;
        }
      }
    }
    .NavigatorSummaryValueClass {
      font-family: var(--vscode-font-family, Arial, Helvetica, sans-serif);
      margin-left: 4pt;
      font-weight: 800;
      font-size: 12px;
    }
    .NavigatorSummaryKeyClass {
      font-family: var(--vscode-font-family, Arial, Helvetica, sans-serif);
      font-size: 12px;
    }
    .NavigatorSummaryWarningValueClass {
      font-family: var(--vscode-font-family, Arial, Helvetica, sans-serif);
      margin-left: 4px;
      font-weight: 800;
      font-size: 12px;
      color: var(--vscode-notificationsErrorIcon-foreground, #f14c4c);
    }
    </style>