diff --git a/content/_index.md b/content/_index.md index a9dd5d71a..f839a0028 100644 --- a/content/_index.md +++ b/content/_index.md @@ -6,10 +6,15 @@ layout: single ## What do you want to cook? - + @@ -26,6 +31,13 @@ document.addEventListener("DOMContentLoaded", () => { const oldheading = document.getElementById("newest-recipes"); const clearSearch = document.getElementById("clear-search"); const artlist = document.getElementById("artlist"); + const random = document.getElementById("random"); + + random.addEventListener("click", () => { + const recipe = recipes[Math.floor(Math.random() * recipes.length)]; + const url = recipe.getElementsByTagName("a")[0].href + window.location.href = url; + }) search.addEventListener("input", () => { // grab search input value diff --git a/static/style.css b/static/style.css index 39b5f056e..5986df57a 100644 --- a/static/style.css +++ b/static/style.css @@ -146,12 +146,19 @@ input#search { width: 100%; } -.search { +.search-container { width: 400px; max-width: 85vw; position: relative; margin: 0.5rem auto 1.2rem; display: flex; + gap: .5rem; +} + +.search { + position: relative; + display: flex; + flex-grow: 1; } button#clear-search { @@ -169,6 +176,20 @@ button#clear-search:hover { color: #eee; } +button#random { + all: unset; + background: #222; + color: #888; + border-radius: 5px; + padding: .7rem 1rem; + height: 100%; + cursor: pointer; + transition: color 180ms ease-in-out; +} + +button#random:hover { + color: #eee; +} .matched-recipe { font-size: x-large ;