1.6.2 • Published 3 years ago
lcp-common-window-dialog v1.6.2
About The Project
Chrome 개발자 버전 92부터 iframe 내부에서 alert, confirm을 사용할 수 없게됩니다. 이를 위해 window 객체의 alert와 confirm을 오버라이딩 하여 사용하게끔 만들어진 라이브러리 입니다.
Built With
Features
- sweet alert의 디자인과 같지만 실제로 필요한 기능들만을 구현하여 해당 패키지의 7%도 되지 않는 bundle size를 가지고 있습니다.
- jss(css-in-js)의 사용을 통해 global css scrope를 침범하지 않도록 만들었고, 크로스 브라우징에서 자유롭습니다. preset을 사용하지 않음으로써 bundle size를 더욱 줄일 수 있었습니다.
- @babel/plugin-transform-runtime 플러그인을 도입, corejs:3 옵션을 활용하여 전역 스코프 오염을 방지
- bundle size 감소를 위하여 terser를 활용한 minify 적용
Note!
- 하위 호환을 위해 confirm 함수 사용시 string 인자 하나만 주어진다면 native confirm이 호출되도록 설정해두었습니다.
- alert()시에 페이지 이동과 같은 행동을 위해 alert에도 두 번째 인자로 callback을 받도록 설정하였습니다.
Installation
git clone https://github.com/Dailyscat/lcp-common-window-dialog.git
cd lcp-common-window-dialog
npm install
npm run build
Usage
import windowDialog from "lcp-common-window-dialog";
window.alert("wow");
window.confirm("Which one would you choose?", bool => {
<!-- write -->
})
License
Distributed under the MIT License. See LICENSE
for more information.
Contact
Dailyscat - dailyscat@gmail.com
Project Link: https://github.com/dailyscat/lcp-common-window-dialog