designtopack/src/stores/virtualSample.js

39 lines
1 KiB
JavaScript
Raw Normal View History

import { defineStore, storeToRefs } from 'pinia';
2025-03-07 17:29:11 +01:00
import { ref, computed, watch } from 'vue';
import { usePageStore } from './page';
import { useDialogStore } from './dialog';
export const useVirtualSampleStore = defineStore('virtual-sample', () => {
2025-03-07 17:29:11 +01:00
const { page } = storeToRefs(usePageStore());
const { openedFile } = storeToRefs(useDialogStore());
2024-11-21 13:20:57 +01:00
const isCompareModeEnabled = ref(false);
const currentFile = ref(null);
const isLoopAnimationEnabled = ref(false);
2025-01-07 16:54:08 +01:00
const isDownloadTriggered = ref(false);
const step = computed(() => {
return page.value.steps.find((step) => step.id === 'virtualSample');
});
const activeTab = computed(() =>
step.value.files.dynamic ? 'dynamic' : 'static'
);
const allVariations = computed(() =>
Object.values(step.value.files?.dynamic).flat(1)
);
watch(activeTab, () => (currentFile.value = null));
2024-12-20 15:52:42 +01:00
return {
activeTab,
currentFile,
step,
allVariations,
2024-12-20 15:52:42 +01:00
isLoopAnimationEnabled,
isCompareModeEnabled,
2025-01-07 16:54:08 +01:00
isDownloadTriggered,
2024-12-20 15:52:42 +01:00
};
});