This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as esbuild from "esbuild" | |
import {sassPlugin} from "esbuild-sass-plugin" | |
import manifestPlugin from "esbuild-plugin-manifest" | |
import svgPlugin from "esbuild-svg" | |
import tailwindPlugin from "esbuild-plugin-tailwindcss" | |
await esbuild.build({ | |
entryPoints: ["./src/index.ts"], | |
bundle: true, | |
outdir: "./dist", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let filterAbortController: AbortController | null = null | |
const responseSettings = { | |
method: "GET", | |
} | |
const filterProducts = async (page?: string) => { | |
// Abort the previous request if it exists | |
if (filterAbortController) { | |
filterAbortController.abort() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @example | |
* addGlobalEventListener("click", ".i-usp", (clickedElement) => { | |
* console.log(clickedElement) | |
* }) | |
*/ | |
export function addGlobalEventListener( | |
type: string, | |
selector: string, | |
callback: (clickedElement: Element, event: Event) => void, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const tabsGroup = document.querySelectorAll(".js-tabs") | |
tabsGroup.forEach(tabGroup => { | |
const tabItems = tabGroup.querySelectorAll(".js-tabs__tab-item") | |
const panels = tabGroup.querySelectorAll(".js-tabs__panel") | |
const closeAllPanels = () => panels.forEach(content => content.classList.remove("--active")) | |
const resetAllTabItems = () => tabItems.forEach(link => link.classList.remove("--active")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const sameHeight = ( | |
group: Element, | |
elements: string | NodeListOf<HTMLElement> | HTMLElement[], | |
byRow = false, | |
parentRowSelector: string = "", | |
) => { | |
const targets = | |
elements instanceof NodeList | |
? Array.from(elements) | |
: typeof elements === "string" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const myElementSelector = ".my-element" | |
document.addEventListener("click", ({target}) => { | |
if (target instanceof Element && !target?.closest(myElementSelector)) { | |
console.log("click outside") | |
} else { | |
console.log("click in") | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mobileQuery = window.matchMedia("(max-width: 74.999em)") // Change to your needs | |
const handleMobileChange = (mediaQueryList: MediaQueryListEvent | MediaQueryList) => { | |
if (mediaQueryList.matches) { | |
// Its Mobile | |
} else { | |
// Its Desktop | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const handle = () => { | |
console.log("Yo my size changed, do something with me") | |
} | |
const resizeObserver = new ResizeObserver(handle) | |
resizeObserver.observe(myElement) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.models = { | |
initModel: function ( | |
modelName, | |
positionX, | |
positionY, | |
positionZ, | |
rotationX, | |
rotationY, | |
rotationZ, | |
rotationAnimationX, |