UNPKG

@alessiofrittoli/web-utils

Version:
1 lines 630 B
import {Url}from'@alessiofrittoli/url-utils';var g=e=>typeof window<"u"?window.matchMedia(e).matches:false;var a=e=>new Map(e);var P=(e={})=>{let i=Math.max(100,e.width||600),p=Math.max(100,e.height||800),{url:t,context:d}=e,{features:u={}}=e,{left:h=window.screen.width/2-(i/2+10),top:f=window.screen.height/2-(p/2+50),...y}=u,s=a([["popup","yes"],["width",i.toString()],["height",p.toString()],["left",h.toString()],["top",f.toString()]]);Object.entries(y).map(([r,w])=>{s.set(r,w);});let T=Array.from(s).map(r=>r.join("=")).join(",");return window.open(t&&Url.format(t),d,T)};export{g as getMediaMatches,P as openBrowserPopUp};