Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Added JS to randomize the homepage's splash image #115

Merged
merged 4 commits into from
Oct 27, 2018
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
1 change: 1 addition & 0 deletions docs/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ group :jekyll_plugins do
gem "jekyll-feed"
gem "jemoji"
gem "jekyll-algolia"
gem "jekyll-include-cache"
end
2 changes: 2 additions & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

remote_theme : "mmistakes/minimal-mistakes"


minimal_mistakes_skin : "von" # "default", "air", "aqua", "contrast", "dark", "dirt", "neon", "mint", "plum", "sunrise"

# Site Settings
Expand Down Expand Up @@ -263,6 +264,7 @@ plugins:
- jekyll-gist
- jekyll-feed
- jemoji
- jekyll-include-cache

# mimic GitHub Pages with --safe
whitelist:
Expand Down
11 changes: 11 additions & 0 deletions docs/_data/hero.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
images:
- url: "/assets/images/svgs/issuer-sitting-3-noshadow-forwhtbk.svg"
class: "issuer-1"
- url: "/assets/images/svgs/licenses-1.svg"
class: "licenses-1"
- url: "/assets/images/svgs/mary-service-card-2-midbk.svg"
class: "mary"
- url: "/assets/images/svgs/licenses-1.svg"
class: "licenses-2"
- url: "/assets/images/svgs/verifier-sitting-1.svg"
class: "issuer-2"
1 change: 1 addition & 0 deletions docs/_includes/footer/custom.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<script src="/assets/js/random-hero-splash.js"></script>
17 changes: 9 additions & 8 deletions docs/_includes/page__hero.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
{% if page.header.image contains "://" %}
{% capture img_path %}{{ page.header.image }}{% endcapture %}
{% else %}
{% capture img_path %}{{ page.header.image | relative_url }}{% endcapture %}
{% endif %}

{% if page.header.primary_cta_url contains "://" %}
{% capture primary_cta_path %}{{ page.header.primary_cta_url }}{% endcapture %}
{% else %}
Expand Down Expand Up @@ -64,8 +58,15 @@ <h1 id="page-title" class="page__title" itemprop="headline">
{% endif %}
</p>
{% endif %}
{% if page.header.image %}
<img src="{{ img_path }}" alt="{{ image_description }}" class="page__hero-image {{ page.header.image_class }}">
{% if site.data.hero.images %}
{% for hero in site.data.hero.images %}
{% if hero.url contains "://" %}
{% capture img_path %}{{ hero.url }}{% endcapture %}
{% else %}
{% capture img_path %}{{ hero.url | relative_url }}{% endcapture %}
{% endif %}
<img src="{{ img_path }}" class="page__hero-image {{ hero.class }}">
{% endfor %}
{% endif %}
{% if page.header.caption %}
<span class="page__hero-caption">{{ page.header.caption | markdownify | remove: "<p>" | remove: "</p>" }}</span>
Expand Down
4 changes: 1 addition & 3 deletions docs/_pages/v2.md → docs/_pages/home.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
---
layout: splash
permalink: /v2/
permalink: /
header:
overlay_color: "#6c98a7"
primary_cta_label: "<i class='fas fa-book-open'></i> Learn More About VON"
primary_cta_url: "/about/"
secondary_cta_label: "<i class='fas fa-people-carry'></i> Get Involved"
secondary_cta_url: "/getting_started/quick-start-guide/"
image: "/assets/images/svgs/licenses-1.svg"
image_class: "licenses-1"
caption:
headline: 'One day, all government-issued documents will be fully digital. We&rsquo;re here to make that happen.'
excerpt: ''
Expand Down
36 changes: 0 additions & 36 deletions docs/_pages/v1.md

This file was deleted.

36 changes: 0 additions & 36 deletions docs/_pages/v3.md

This file was deleted.

36 changes: 0 additions & 36 deletions docs/_pages/v4.md

This file was deleted.

36 changes: 0 additions & 36 deletions docs/_pages/v5.md

This file was deleted.

15 changes: 10 additions & 5 deletions docs/_sass/minimal-mistakes/_page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -268,17 +268,22 @@
-ms-interpolation-mode: bicubic;
position: absolute;
z-index: -1;
display: none;

&.issuer {
max-width: 480px;
right: -100px;
bottom: 0px;
max-height: 600px;
&.active {
display: none;

@include breakpoint($medium-wide) {
display: block;
}
}

&.issuer-1,
&.issuer-2 {
max-width: 480px;
right: -100px;
bottom: 0px;
max-height: 600px;

@include breakpoint($large) {
right: -40px;
Expand Down
24 changes: 24 additions & 0 deletions docs/assets/js/random-hero-splash.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
---

{% assign numberOfHeroOptions = site.data.hero.images | size %}

(function() {
var body = document.body;
var options = [];

{% for hero in site.data.hero.images %}
options.push("{{ hero.class }}");
{% endfor %}

var randomNumber = Math.floor((Math.random() * {{ numberOfHeroOptions }} ));

function hasClass(element, cls) {
return (' ' + element.className + ' ').indexOf(' ' + cls + ' ') > -1;
}

if(hasClass(body, "layout--splash")) {
var randomlySelectedHero = document.getElementsByClassName("page__hero-image " + options[randomNumber])[0];
randomlySelectedHero.className += " active";
}
})();