All files / src/components/modal/actions PanAction.vue

100% Statements 9/9
100% Branches 2/2
100% Functions 1/1
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  4x                                         2x       2x 2x   2x     2x 2x 2x 2x      
<template>
  <Action
    :text="t('labels.pan')"
    icon="pan_tool"
    :color="enabled ? 'blue-lighten-1' : 'white'"
    :variant="variant"
    @click="toggle"
    data-testid="button"
  />
</template>
 
<script setup lang="ts">
import { ref } from 'vue';
import { ScanView } from '@3cr/types-ts';
import { useViewer3cr } from '@/composables/useViewer3cr';
import { useI18n } from 'vue-i18n';
 
interface Props {
  view: ScanView;
  variant?: 'button' | 'menu-item';
}
 
const props = withDefaults(defineProps<Props>(), {
  variant: 'button',
});
 
const { t } = useI18n();
const viewer3cr = useViewer3cr();
 
const enabled = ref<boolean>(false);
 
async function toggle(): Promise<void> {
  const state = !enabled.value;
  const message = { Version: '0.0.0', View: props.view, Visibility: state };
  await viewer3cr.pan({ message });
  enabled.value = state;
}
</script>