NEW FEATURE: travel back in time

This commit is contained in:
Jeroen De Meerleer 2021-08-06 09:51:41 +02:00
parent 541b62f296
commit f9cdcdc7c6
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
7 changed files with 45 additions and 3 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 KiB

View File

@ -1,7 +1,10 @@
import Cookies from 'js-cookie';
document.addEventListener("readystatechange", event => { document.addEventListener("readystatechange", event => {
if(event.target.readyState === 'complete') { if(event.target.readyState === 'complete') {
initOverflow(); initOverflow();
initExternalLinks(); initExternalLinks();
initNinetiesToggle();
} }
}); });
@ -12,6 +15,19 @@ function initOverflow() {
} }
} }
function initNinetiesToggle() {
document.querySelector('.nineties-toggle').addEventListener('click', function() {
let body = document.querySelector('body');
if (body.classList.contains('nineties')) {
body.classList.remove('nineties');
Cookies.remove('nineties');
} else {
body.classList.add('nineties');
Cookies.set('nineties', true, { sameSite: 'strict' });
}
})
}
function initExternalLinks() { function initExternalLinks() {
document.querySelectorAll('a').forEach(elem => { document.querySelectorAll('a').forEach(elem => {
if(isExternalURL(elem.getAttribute('href'))) { if(isExternalURL(elem.getAttribute('href'))) {

View File

@ -15,6 +15,23 @@ body {
font-family: $font; font-family: $font;
height: 100%; height: 100%;
margin: 0 10px; margin: 0 10px;
&.nineties {
color: $black;
background-image: url("../images/background-1990.gif");
font-family: 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue', sans-serif;
a{
color: $black;
}
}
.nineties-toggle {
position: absolute;
top: 0;
right: 0;
}
a { a {
color: $orange; color: $orange;
} }

5
package-lock.json generated
View File

@ -3621,6 +3621,11 @@
} }
} }
}, },
"js-cookie": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/js-cookie/-/js-cookie-3.0.0.tgz",
"integrity": "sha512-oUbbplKuH07/XX2YD2+Q+GMiPpnVXaRz8npE7suhBH9QEkJe2W7mQ6rwuMXHue3fpfcftQwzgyvGzIHyfCSngQ=="
},
"js-tokens": { "js-tokens": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",

View File

@ -7,7 +7,8 @@
"lib": "lib" "lib": "lib"
}, },
"dependencies": { "dependencies": {
"bootstrap": "^5.1.0" "bootstrap": "^5.1.0",
"js-cookie": "^3.0.0"
}, },
"devDependencies": { "devDependencies": {
"@symfony/webpack-encore": "^1.5.0", "@symfony/webpack-encore": "^1.5.0",

View File

@ -18,6 +18,8 @@ class DefaultController extends Controller
return $this->render('/page.html.twig', [ return $this->render('/page.html.twig', [
'header' => $page['header'], 'header' => $page['header'],
'content' => $page['content'], 'content' => $page['content'],
'title' => $page['title']], $page['status']); 'title' => $page['title'],
'nineties' => (isset($_COOKIE['nineties']))
], $page['status']);
} }
} }

View File

@ -11,7 +11,8 @@
</head> </head>
<body> <body{% if nineties %} class="nineties"{% endif %}>
<div class="nineties-toggle">{% if nineties %}My eyes hurt{% else %}Take me back in time{% endif %}</div>
<div class="container"> <div class="container">
{% block content %}{% endblock %} {% block content %}{% endblock %}
{% block extrahtml %}{% endblock %} {% block extrahtml %}{% endblock %}