-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Добавляет баннер вверх сайта. Ссылка на исследование (#1250)
* Добавляет баннер вверх сайта * Добавляет условие для ссылки * Удаляет hidden * Использует гибкие стили для шрифта и кнопки * Отделяет глаза от зубов * Уменьшает мордашку для экранов поменбше * Увеличивает ссылку на мобильных, чтобы удобнее было нажимать пальцем * Возвращает hidden * Добавляет настройку для стилей * Добавляет скрипт для работы баннера * Меняет имя переменной * Меняет простой шаблон на макрос с шаблоном * Убирает баннер из базового шаблона * Добавляет баннер на все требуемые страницы * Добавляет условия для показа в отсутствии других баннеров * Добавляет дополнительное услловие для закрытого попапа --------- Co-authored-by: Svetlana Korobtseva <[email protected]> Co-authored-by: Igor Korovchenko <[email protected]>
- Loading branch information
1 parent
8109a13
commit 0bf1047
Showing
15 changed files
with
184 additions
and
6 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{% macro topBanner(isMainPage = false) %} | ||
<div class="top-banner notification" hidden> | ||
<p class="top-banner__content">Мы хотим понять, кто нас читает. Поможете нам? Займёт всего 5 минут.</p> | ||
<a class="top-banner__button notification__button button" target="_blank" rel="noreferrer nofollow" href="{% if isMainPage %}https://forms.yandex.ru/cloud/65f1aaf35d2a061e4ff460e0/?utm_source=doka_main{% else %}https://forms.yandex.ru/cloud/65f1aaf35d2a061e4ff460e0/?utm_source=doka_other{% endif %}">Пройти опрос</a> | ||
</div> | ||
{% endmacro %} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
function init() { | ||
const banner = document.querySelector('.top-banner') | ||
const button = banner?.querySelector('.top-banner__button') | ||
const interval = 10000 | ||
const visitedPagesKey = 'pages-list' | ||
const cookieNotificationKey = 'cookie-notification' | ||
const subscriptionPopupKey = 'subscription-form-status' | ||
|
||
if (!banner && !button) { | ||
return | ||
} | ||
|
||
const storageKey = 'top-banner' | ||
|
||
try { | ||
const isBannerAccepted = JSON.parse(localStorage.getItem(storageKey)) | ||
|
||
if (isBannerAccepted) { | ||
return | ||
} | ||
|
||
const visitedPages = localStorage.getItem(visitedPagesKey) | ||
const cookieNotification = localStorage.getItem(cookieNotificationKey) | ||
const subscriptionPopup = localStorage.getItem(subscriptionPopupKey) | ||
const pageList = visitedPages ? JSON.parse(visitedPages) : {} | ||
|
||
let timer = setInterval(() => { | ||
if (pageList && cookieNotification && (subscriptionPopup === 'SHOWN' || subscriptionPopup === 'CLOSED')) { | ||
for (const key in pageList) { | ||
if (pageList[key].duration >= interval * 2) { | ||
banner.hidden = false | ||
clearInterval(timer) | ||
break | ||
} | ||
} | ||
} | ||
}, interval) | ||
} catch (error) { | ||
console.error(error) | ||
} | ||
|
||
button.addEventListener( | ||
'click', | ||
() => { | ||
banner.hidden = true | ||
localStorage.setItem(storageKey, true) | ||
}, | ||
{ once: true }, | ||
) | ||
} | ||
|
||
init() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
.top-banner { | ||
position: relative; | ||
justify-content: space-between; | ||
align-items: center; | ||
padding-inline-start: 150px; | ||
color: #fff; | ||
background-color: #000; | ||
z-index: 999; | ||
} | ||
|
||
.top-banner[hidden] { | ||
display: none; | ||
} | ||
|
||
.top-banner::before { | ||
content: ""; | ||
position: absolute; | ||
inset-inline-start: 15px; | ||
inset-block-start: calc(50% - 15px); | ||
inline-size: 120px; | ||
block-size: 30px; | ||
background-image: url("../../images/top-banner/bat-eyes.svg"); | ||
background-repeat: no-repeat; | ||
background-position: center; | ||
background-size: contain; | ||
} | ||
|
||
.top-banner::after { | ||
content: ""; | ||
position: absolute; | ||
inset-inline-start: 45px; | ||
inset-block-end: -12px; | ||
inline-size: 60px; | ||
block-size: 13px; | ||
background-image: url("../../images/top-banner/bat-teeth.svg"); | ||
background-repeat: no-repeat; | ||
background-position: center; | ||
background-size: contain; | ||
} | ||
|
||
.top-banner__content { | ||
margin: 0; | ||
} | ||
|
||
@media (width <= 1366px) { | ||
.top-banner { | ||
padding-inline-start: 110px; | ||
} | ||
|
||
.top-banner::before { | ||
inset-block-start: calc(50% - 10px); | ||
inline-size: 80px; | ||
block-size: 20px; | ||
} | ||
|
||
.top-banner::after { | ||
inset-inline-start: 33px; | ||
inset-block-end: -8px; | ||
inline-size: 45px; | ||
block-size: 9px; | ||
} | ||
} | ||
|
||
@media (width <= 768px) { | ||
.top-banner { | ||
margin-block-end: 0; | ||
padding-inline-start: 15px; | ||
font-size: 14px; | ||
} | ||
|
||
.top-banner::before, .top-banner::after { | ||
display: none; | ||
} | ||
|
||
.top-banner__button { | ||
padding-block: 0.3em; | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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