refactor du store et des templates suite à la refont du backend
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import { ref } from 'vue';
|
||||
|
||||
export function useImageModal() {
|
||||
const isModaleOpen = ref(false);
|
||||
const currentImage = ref({ src: '', alt: '' });
|
||||
const swiperPopupContent = ref([]);
|
||||
|
||||
const body = document.querySelector('body');
|
||||
const hamburger = document.querySelector('#hamburger');
|
||||
const menu = document.querySelector('#menu');
|
||||
|
||||
const openImageModale = (src, alt, swiperMedia) => {
|
||||
currentImage.value = { src, alt };
|
||||
swiperPopupContent.value = swiperMedia || [];
|
||||
isModaleOpen.value = true;
|
||||
toggleBodyScroll(true);
|
||||
};
|
||||
|
||||
const closeImageModale = () => {
|
||||
isModaleOpen.value = false;
|
||||
swiperPopupContent.value = [];
|
||||
toggleBodyScroll(false);
|
||||
};
|
||||
|
||||
const toggleBodyScroll = (disableScroll) => {
|
||||
if (disableScroll) {
|
||||
body.classList.add('no-scroll');
|
||||
hamburger.style.opacity = 0;
|
||||
menu.style.display = 'none';
|
||||
} else {
|
||||
body.classList.remove('no-scroll');
|
||||
menu.style.display = 'flex';
|
||||
setTimeout(() => {
|
||||
hamburger.style.opacity = 1;
|
||||
}, 300);
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
isModaleOpen,
|
||||
currentImage,
|
||||
swiperPopupContent,
|
||||
openImageModale,
|
||||
closeImageModale,
|
||||
};
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
export function useUtils() {
|
||||
const isObjectEmpty = (obj) => {
|
||||
if (!obj || typeof obj !== 'object') return true;
|
||||
|
||||
return !Object.keys(obj).some((key) => {
|
||||
const value = obj[key];
|
||||
if (Array.isArray(value)) return value.length > 0;
|
||||
if (typeof value === 'object') return !isObjectEmpty(value);
|
||||
return value !== null && value !== undefined && value !== '';
|
||||
});
|
||||
};
|
||||
|
||||
const scrollTop = () => {
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
};
|
||||
|
||||
return {
|
||||
isObjectEmpty,
|
||||
scrollTop,
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user