All files / src/components/Appointment/AppointmentSelection CalendarListToggle.vue

100% Statements 10/10
100% Branches 6/6
100% Functions 2/2
100% Lines 9/9

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  103x 4x               4x                 98x               98x       98x 103x     103x     103x                                                
<template>
  <div class="calendar-list-toggle-container">
    <h2 id="viewToggleLabel">
      {{ t("time") }}
    </h2>
    <muc-toggle
      :model-value="isListView"
      :label-left="t('calendarView')"
      :label-right="t('listView')"
      :aria-label="toggleAriaLabel"
      @update:model-value="emit('update:isListView', $event)"
    />
  </div>
</template>
 
<script setup lang="ts">
import { MucToggle } from "@muenchen/muc-patternlab-vue";
import { computed } from "vue";
 
const props = withDefaults(
  defineProps<{
    t: (key: string) => string;
    isListView: boolean;
  }>(),
  { isListView: false }
);
 
const emit = defineEmits<{
  (e: "update:isListView", value: boolean): void;
}>();
 
const toggleAriaLabel = computed(() => {
  const current = props.isListView
    ? props.t("listViewActiveLabel")
    : props.t("calendarViewActiveLabel");
  const action = props.isListView
    ? props.t("switchToCalendarViewAriaLabel")
    : props.t("switchToListViewAriaLabel");
  return `${current} ${action}`;
});
</script>
 
<style lang="scss" scoped>
@use "@/styles/breakpoints.scss" as *;
 
.calendar-list-toggle-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 20px;
  padding: 16px 0;
}
 
/* Responsive layout: on larger screens, display toggle to the right of heading */
@include xs-up {
  .calendar-list-toggle-container {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
  }
}
</style>