From 51854614005db9b2bdfba037e8565a71bf301a40 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 27 Nov 2024 17:38:34 +0100 Subject: [PATCH] Add banner to warn about the Composer 1 EOL --- css/app.scss | 22 ++++++++++++++++++++++ js/app.js | 15 +++++++++++++++ templates/layout.html.twig | 7 ++++++- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/css/app.scss b/css/app.scss index 6d9a1df14..a1fb23bf8 100644 --- a/css/app.scss +++ b/css/app.scss @@ -150,6 +150,28 @@ strong { background: #2d2d32; } +.banner { + position: absolute; + text-align: center; + left: 50%; + top: 9px; + width: 340px; + height: 40px; + margin-left: -170px; + background: red; + padding: 10px; + border-radius: 5px; + &.alert-error::before { + content: ''; + } + z-index: 500; + .banner-close { + float: right; + padding-top: 2px; + cursor: pointer; + } +} + .navbar { margin: 0; border: 0; diff --git a/js/app.js b/js/app.js index 9eb7792c2..0a1f304a7 100644 --- a/js/app.js +++ b/js/app.js @@ -62,6 +62,21 @@ import 'bootstrap'; scrollTo(0, $($(e.target).attr('href')).offset().top - 65); }, 0); }); + + let currentBannerId = $('.banner .banner-close').data('banner-id'); + $('.banner .banner-close').click(function () { + $('.banner').addClass('hidden'); + try { + window.localStorage.setItem('banner-read', currentBannerId); + } catch (e) {} + }); + if (currentBannerId !== undefined) { + try { + if (window.localStorage.getItem('banner-read') !== currentBannerId) { + $('.banner').removeClass('hidden'); + } + } catch (e) {} + } })(jQuery); if (window.trackPageload !== false && location.host === 'packagist.org') { diff --git a/templates/layout.html.twig b/templates/layout.html.twig index 6160245a0..bee7bbab4 100644 --- a/templates/layout.html.twig +++ b/templates/layout.html.twig @@ -42,10 +42,15 @@ {% block head_additions %}{% endblock %} -