Random card order :)

This commit is contained in:
Henrique Dias 2018-07-18 07:38:39 +01:00
parent 0544b37ba3
commit 390088c7f2
2 changed files with 10 additions and 1 deletions

View File

@ -17,6 +17,13 @@ const cards = Array.from(document.querySelectorAll('.Card'))
return 0
})
function randomizr () {
const cards = document.querySelector('.CardContainer')
for (var i = cards.children.length; i >= 0; i--) {
cards.appendChild(cards.children[Math.random() * i | 0])
}
}
function update (display) {
cards.forEach((c) => {
if (display.indexOf(c.dataset.ref) >= 0) {
@ -29,6 +36,8 @@ function update (display) {
})
}
randomizr()
if (search) {
search.classList.remove('dn')
const input = search.querySelector('input')

View File

@ -11,7 +11,7 @@
type="text" />
</div>
<main class="mv4 flex flex-wrap justify-between" >
<main class="CardContainer mv4 flex flex-wrap justify-between" >
{{ range (sort . "Params.index") -}}
<article data-ref="{{ .Params.index }}" class="Card flex flex-column bg-white shadow-4 grow2 br1 dark-gray b--black-10 flex-grow-1 ma2">
{{ $cat := index .Params.categories 0 }}