Skip to content

Commit 0b69036

Browse files
committed
resolves #1 by only showing logo every 24hrs
1 parent d54dc4c commit 0b69036

File tree

4 files changed

+35
-6
lines changed

4 files changed

+35
-6
lines changed

_includes/head.html

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,24 @@
1515
{% include head--icons.html %}
1616

1717
<script>
18-
// when the whole document has loaded, add a CSS class
18+
19+
// global vars
20+
var today = new Date();
21+
var tomorrow = new Date();
22+
tomorrow.setDate(tomorrow.getDate() + 1);
23+
var playLogo = false;
24+
25+
// if we have localstorage,
26+
// see if the logo_expiry has happened or not
27+
if (window.localStorage) {
28+
var expires = new Date(localStorage.getItem('logo_expiry'));
29+
playLogo = (today - expires > 0);
30+
}
31+
32+
// if the logo animation has been played already, just load the content
1933
window.onload = function(){
20-
var body = document.getElementsByTagName('body')[0]
21-
if (body.className.indexOf('home') == -1) {
34+
var body = document.getElementsByTagName('body')[0];
35+
if (!playLogo || body.className.indexOf('home') < 0) {
2236
body.className += ' loaded';
2337
}
2438
};

_includes/header.html

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
<script>
2+
var body = document.getElementsByTagName('body')[0];
3+
24
// we add this inline to let the CSS know we have JS capability
35
// as soon as humanly possible.
4-
document.getElementsByTagName('body')[0].className += ' js';
6+
body.className += ' js';
7+
8+
// if our logo animation hasn't been played in 24 hours,
9+
// clear the localstorage ready to play it (next code block)
10+
if (playLogo) {
11+
localStorage.removeItem('logo_expiry');
12+
}
13+
14+
// if we're on the homepage, and the logo animation hasn't played before
15+
// add an "animate" css class and set the localstorage item
16+
if (body.className.indexOf('home') > -1 && playLogo && window.localStorage) {
17+
body.className += ' animate-logo';
18+
localStorage.setItem("logo_expiry", tomorrow);
19+
}
520
</script>
621

722
<header class="site-header">

_sass/logo.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ svg { display:block; margin: 0 auto; width: 280px; max-width: 80vw; }
1616

1717
#logomark path { fill: $brand-color; }
1818

19-
.home{
19+
.home.animate-logo{
2020

2121
svg {
2222
width: 100%;

css/main.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
/**
7171
* homepage content animation
7272
*/
73-
.home {
73+
.home.animate-logo {
7474
.page-content {
7575
animation: movein 1.5s ease-out forwards 4s;
7676
opacity: 0;

0 commit comments

Comments
 (0)