From 4f6c2e95b44a6111ac94ed8dacdd18e85a13b9ba Mon Sep 17 00:00:00 2001 From: Francesco Luzzana Date: Wed, 1 Jun 2022 01:33:31 +0200 Subject: [PATCH] recipes --- components/CookbookForm.js | 10 ++++++--- components/CookbookRecipes.js | 38 +++++++++++++++++++++++++++++++++++ index.html | 9 +++------ style.css | 35 ++++++++++++++++++++++++++++++-- 4 files changed, 81 insertions(+), 11 deletions(-) create mode 100644 components/CookbookRecipes.js diff --git a/components/CookbookForm.js b/components/CookbookForm.js index bffda3a..6ed804a 100644 --- a/components/CookbookForm.js +++ b/components/CookbookForm.js @@ -1,7 +1,7 @@ export default { name: "CookbookForm", setup() { - const { ref } = Vue; + const { ref, computed } = Vue; const title = ref(""); const description = ref(""); @@ -9,6 +9,10 @@ export default { const logs = ref([""]); const who = ref(""); + const disabled = computed(() => { + return [title, description, nature, logs, who].some((input) => input.value == ""); + }); + const submit = function () { fetch("https://hub.xpub.nl/soupboat/cookbook/", { method: "POST", @@ -23,7 +27,7 @@ export default { }); }; - return { title, description, nature, logs, who, submit }; + return { title, description, nature, logs, who, disabled, submit }; }, template: `
@@ -54,7 +58,7 @@ export default {
- +
diff --git a/components/CookbookRecipes.js b/components/CookbookRecipes.js new file mode 100644 index 0000000..e6ee3d2 --- /dev/null +++ b/components/CookbookRecipes.js @@ -0,0 +1,38 @@ +export default { + setup() { + const { ref, computed } = Vue; + + const recipes = ref(null); + + fetch("https://hub.xpub.nl/soupboat/cookbook/get") + .then((res) => res.json()) + .then((data) => (recipes.value = data)); + + const style = function (index) { + return { + transform: `translate(${index * 10}px, ${index * 10}px)`, + }; + }; + + const browse = function () { + let recipe = recipes.value.pop(); + recipes.value.unshift(recipe); + }; + + return { recipes, style, browse }; + }, + + template: ` +
+
+

{{recipe.title}}

+

{{recipe.description}}

+
{{recipe.nature}}
+
    +
  1. {{log}}
  2. +
+

{{recipe.who}}

+
+
+ `, +}; diff --git a/index.html b/index.html index 2c9970e..32a207b 100644 --- a/index.html +++ b/index.html @@ -12,18 +12,15 @@
Archive +
diff --git a/style.css b/style.css index 105474c..6010eb5 100644 --- a/style.css +++ b/style.css @@ -12,11 +12,17 @@ body { #app { width: 100%; + display: flex; + flex-wrap: wrap; +} + +#app > * { + flex-shrink: 0; } section.recipe { - display: block; - margin: 48px auto; + display: inline-block; + margin: 48px; padding: 32px; width: 50ch; border-radius: 0.5rem; @@ -42,6 +48,10 @@ button { font-size: 1rem; } +button { + cursor: pointer; +} + button.add { display: block; width: 48px; @@ -52,6 +62,12 @@ button.add { border-radius: 50%; } +button:disabled { + border: 1px dashed currentColor; + cursor: default; + opacity: 0.5; +} + textarea + textarea { margin-top: 16px; } @@ -76,3 +92,18 @@ label { padding: 0 0.5em; text-decoration: none; } + +.cookbook { + display: inline-block; + position: relative; + min-width: 50ch; + height: 100%; +} + +.cookbook .recipe { + position: absolute; + top: 0; + left: 0; + background-color: #e6b0aa; + cursor: pointer; +}