Skip to content

Commit

Permalink
Change the hero layout and improve class replace script
Browse files Browse the repository at this point in the history
Add floating ship —instead of old hero image—
Add versatility to the class replace script so that
it is possible to add multiple classes for each value
  • Loading branch information
7Skiez committed May 11, 2021
1 parent 3d75e6c commit 00912a2
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 19 deletions.
2 changes: 1 addition & 1 deletion public/themes/tailwind/css/app.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/themes/tailwind/js/app.js

Large diffs are not rendered by default.

21 changes: 18 additions & 3 deletions resources/views/themes/tailwind/assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,25 @@ window.csrf = document.querySelector("meta[name='csrf-token']").getAttribute("co
document.addEventListener("DOMContentLoaded", function(){
var replacers = document.querySelectorAll('[data-replace]');
for(var i=0; i<replacers.length; i++){
let replaceClasses = JSON.parse(replacers[i].dataset.replace.replace(/'/g, '"'));
Object.keys(replaceClasses).forEach(function(key) {
let inputClasses = JSON.parse(replacers[i].dataset.replace.replace(/'/g, '"'));
//replace white-space seperated values in inputClasses with array of classes
var replacementClasses = new Array();
Object.keys(inputClasses).forEach(function(key, i) {
replacementClasses[i] = inputClasses[key].match(/(\s+)/)
? inputClasses[key].split(/(\s+)/).filter((e) => e.trim().length > 0)
: inputClasses[key];
inputClasses[key] = replacementClasses[i];
});

Object.keys(inputClasses).forEach(function(key) {
replacers[i].classList.remove(key);
replacers[i].classList.add(replaceClasses[key]);

if(typeof(inputClasses[key]) === 'string'){
replacers[i].classList.add(inputClasses[key]);
}else if(typeof(inputClasses[key]) === 'object'){
replacers[i].classList.add(...inputClasses[key]);

}
});
}
});
Expand Down
19 changes: 18 additions & 1 deletion resources/views/themes/tailwind/assets/sass/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,23 @@ svg {
to {transform: translateX(-100%);}
}

.ship {
animation: ship 6s linear infinite;
}
@keyframes ship {
0% {
transform: rotate(0deg) translateY(0.75vh);
}

50%{
transform: rotate(0.25deg) translateY(0);
}

100% {
transform: rotate(0deg) translateY(0.75vh);
}
}

.form-control{
@apply form-input w-full;
}
Expand All @@ -65,4 +82,4 @@ svg {
background-size: 1.5em 1.5em;
padding:.5rem 2.5rem .5rem .75rem;
background-repeat: no-repeat;
}
}
27 changes: 14 additions & 13 deletions resources/views/themes/tailwind/home.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,30 @@
</div>
</div>

<div class="flex w-full mb-16 lg:w-1/2 lg:mb-0">

<div class="relative invisible transition-none duration-1000 delay-100 transform translate-x-12 opacity-0" data-replace='{ "transition-none": "transition-all", "invisible": "visible", "translate-x-12": "translate-y-0", "opacity-0": "opacity-100" }'>
<img src="{{ Voyager::image(theme('home_promo_image')) }}" class="w-full max-w-3xl sm:w-auto">
</div>

</div>
</div>
</div>

</div>

<div class="relative flex items-center z-10 -mt-32 sm:mt-auto xl:-mt-40">
<div
class="absolute w-auto right-0.5 invisible transition-none transform translate-x-12 -translate-y-3/7 opacity-0 float-right -z-1"
data-replace='{ "transition-none": "transition-all duration-1000 delay-100", "invisible": "visible", "translate-x-12": "sm:-translate-x-6", "opacity-0": "opacity-100" }'>

</div>
<img src="{{ Voyager::image(theme('home_promo_image')) }}"
class="w-4/5 m-auto max-w-xl sm:w-auto lg:max-w-xl xl:max-w-3xl 2xl:max-w-4xl ship">

<div class="relative z-40 -mt-64">
</div>

<svg viewBox="0 0 120 28" class="-mt-64">
<svg viewBox="0 0 120 28" class="-mt-1/2" fill-rule="evenodd">
<defs>
<path id="wave" d="M 0,10 C 30,10 30,15 60,15 90,15 90,10 120,10 150,10 150,15 180,15 210,15 210,10 240,10 v 28 h -240 z" />
{{-- Editted the svg path using https://yqnn.github.io/svg-path-editor/ --}}
<path id="wave"
d="M 0 13 C 30 13 30 15 60 15 C 90 15 90 13 120 13 C 150 13 150 15 180 15 C 210 15 210 13 240 13 v 28 h -240 z" />
</defs>
<use id="wave3" class="wave" xlink:href="#wave" x="0" y="-2"></use>
<use id="wave3" class="wave" xlink:href="#wave" x="0" y="-0.5"></use>
<use id="wave2" class="wave" xlink:href="#wave" x="0" y="0"></use>
<use id="wave1" class="wave" xlink:href="#wave" x="0" y="1" />
<use id="wave1" class="wave" xlink:href="#wave" x="0" y="0.25" />
</svg>
</div>

Expand Down
7 changes: 7 additions & 0 deletions resources/views/themes/tailwind/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ module.exports = {
800: '#002F73',
900: '#00204D',
},
},
zIndex: {
"-1": "-1",
},
spacing: {
'3/7': '42.8571429%',
'9/20': '45%',
}
}
},
Expand Down
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 00912a2

Please sign in to comment.