Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat : 팝업 기능 구현 #26

Merged
merged 7 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions css/popup.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
.popup-back {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.8);
z-index: 50;
display: none;
}

.main-screen {
width: 508px;
height: 633px;
margin: -316px 0 0 -254px;
color: #fff;
position: absolute;
z-index: 100;
left: 50%;
top: 50%;
border-radius: 8px;
}
.main-outer {
width: 508px;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

혹시 이 여백은 의도하신걸까용?

position: relative;
}
.popup-close {
position: absolute;
top: 0;
right: 0;
z-index: 50;
}

.main-content {
display: block;
position: relative;
width: 420px;
height: 600px;
overflow: hidden;
margin: 0 auto 0 auto;
}
.main-content img {
width: 420px;
height: 600px;
border-radius: 16px;
}

.popup-checkbox {
position: relative;
width: 420px;
margin: 0 auto 0;
}
.popup-checkbox label {
color: #a5a5a5;
font-size: 16px;
margin-top: 20px;
}

.popup-checkbox input[type="checkbox"] {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
border: 0;
}
.popup-checkbox input[type="checkbox"] + label {
display: inline-block;
position: relative;
padding-left: 32px;
cursor: pointer;
}

.popup-checkbox input[type="checkbox"] + label:before {
content: "";
position: absolute;
left: 0;
top: -4px;
width: 23px;
height: 23px;
text-align: center;
box-sizing: border-box;
border: 1px solid #a5a5a5;
}

.popup-checkbox input[type="checkbox"]:checked + label:after {
content: "";
position: absolute;
top: -4px;
left: 0;
width: 23px;
height: 23px;
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABcAAAAXCAYAAADgKtSgAAAAAXNSR0IArs4c6QAAAO9JREFUSA1jFA78+Z+BRoCJRuaCjR01HGvoDv5gYWTE6nAGil3ekcLMcGYaK1bTKTK8J52ZIcWLmWHlgX/UNRxkcII7M0Pfmr8MXSv/Us9wZIPblmE3GGQb1mBZUMbCMLOQmYGFGdNBxBqM0/B95/8xBNsyM8wtZkGxgBSDcRq+aPc/hvLZfxi8LZjgFpBqMMhwRnylYrInE0NnKgvDw5f/GeTFGcGRhy+MQQYiAxZkDjp77vZ/DDycfxhqopkZFu36y0CKwSCz8LocZpm4AAPDyw8wHvE01tSCrp0cg0FmEGU4umXE8kcNxxpSNA0WAAXETbeav2oDAAAAAElFTkSuQmCC)
no-repeat;
background-position: center center;
}

.popup-checkbox input[type="checkbox"] + label span {
font-weight: 400;
font-size: 13px;
line-height: 26px;
letter-spacing: -1px;
color: rgba(0, 0, 0, 0.5);
}
34 changes: 31 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,38 @@
crossorigin
href="https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard-dynamic-subset.min.css"
/>
<link rel="stylesheet" href="css/page/footer.css" />
<link rel="stylesheet" href="./css/footer.css" />
<link rel="stylesheet" href="./css/popup.css" />
<script src="./js/swiper-bundle.min.js"></script>
<script defer src="./js/common.js" type="module"></script>
<script defer src="./js/index.js" type="module"></script>
<script defer src="./js/footer.js"></script>
<script defer src="./js/popup.js"></script>
</head>
<body>
<header>
<div class="popup-back" id="popup_back">
<div class="main-screen">
<div class="main-outer">
<button class="popup-close" id="popup_close">
<img
src="https://www.wavve.com/img/btn-popup-close.1b1a67e7.svg"
alt="팝업 닫기"
/>
</button>
<a class="main-content" href="#">
<img
src="https://image.wavve.com/v1/thumbnails/0_0_20_80/service30/crm/auth_firstbenefit_layerpopup_pc.jpg"
alt="팝업배너"
/>
</a>
<div class="popup-checkbox">
<input type="checkbox" id="popup_checkbox" class="checkbox" />
<label for="popup_checkbox">일주일 동안 보지 않기</label>
</div>
</div>
</div>
</div>
<div class="header-wrap">
<div class="header-nav">
<nav class="header-nav-menu">
Expand All @@ -36,11 +60,15 @@
<li><a class="not-open-link" href="#">웨이브온</a></li>
<li><a class="not-open-link" href="#">이벤트</a></li>
</ul>
<button id="themeBtn" type="button"><span class="blind">테마 변경</span></button>
<button id="themeBtn" type="button">
<span class="blind">테마 변경</span>
</button>
</nav>
</div>
<div class="header-section">
<a href="./index.html" class="logo"><span class="blind">Wavve</span></a>
<a href="./index.html" class="logo"
><span class="blind">Wavve</span></a
>
<nav class="header-menu">
<ul>
<li><a href="#" class="on">홈</a></li>
Expand Down
3 changes: 0 additions & 3 deletions js/footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ let clickTimeout = null;

// 현재 인덱스를 받아서 인덱스 * 지정한 단위높이만큼 ul을 움직이게 한다.
function moveToIndex(index) {
console.log("index, currentIndex : ", index, currentIndex);
let yOffset = -(index * containerHeight);
// 움직여야하는 y높이
if (index === 0) {
Expand All @@ -24,7 +23,6 @@ function moveToIndex(index) {
currentIndex = 0;
++index;
setTimeout(function () {
console.log("두번쨰 움직임", index, containerHeight);
const ul = document.querySelector(".footer-swiper-container ul");
// 두 번째 이동을 위해 transition 설정
ul.style.transition = "transform 300ms"; // 2단계 이동에는 transition 적용
Expand Down Expand Up @@ -73,7 +71,6 @@ document
if (currentIndex === 4) {
return;
}
console.log("내가 막았을텐데??");
clearInterval(autoSlideInterval);
// 타임아웃 클리어
clearTimeout(clickTimeout);
Expand Down
41 changes: 41 additions & 0 deletions js/popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
let checked = false;

function setCookie(name, value, days) {
let date = new Date();
date.setDate(date.getTime() + days * 24 * 60 * 60 * 1000);
document.cookie =
name + "=" + value + "; expires=" + date.toGMTString() + "; path=/;";
}

function getCookie() {
let cookiedata = document.cookie;
if (cookiedata.indexOf("popupSeen=checked") < 0) {
// 없으면?
document.getElementById("popup_back").style.display = "block";
} else {
document.getElementById("popup_back").style.display = "none";
}
}

function closePop() {
// 7일 동안 안보기
if (checked) {
setCookie("popupSeen", "checked", 7);
}
document.getElementById("popup_back").style.display = "none";
}

// 페이지 로드 시 팝업 확인
window.onload = function () {
getCookie();
};
if (document.getElementById("popup_close")) {
document.getElementById("popup_close").addEventListener("click", function () {
closePop();
});
}
document
.getElementById("popup_checkbox")
.addEventListener("click", function () {
checked = this.checked;
});