/** 1920 / 1200 设计稿与 xuexiaole-web 一致 */

export const px2vw = (px: number | string) => {
  const v = Number(px)
  return Number.isNaN(v) ? String(px) : `${(v / 1920) * 100}vw`
}

export const px2vh = (px: number | string) => {
  const v = Number(px)
  return Number.isNaN(v) ? String(px) : `${(v / 1200) * 100}vh`
}

export const px2px = (px: number | string) => {
  const v = Number(px)
  return Number.isNaN(v) ? Math.round(Number(px)) : Math.round((v / 1920) * window.innerWidth)
}

export const px2px_h = (px: number | string) => {
  const v = Number(px)
  return Number.isNaN(v) ? Math.round(Number(px)) : Math.round((v / 1200) * window.innerHeight)
}
