diff --git a/src/lib/components/ActionButton.svelte b/src/lib/components/ActionButton.svelte index b54d420..f83247a 100644 --- a/src/lib/components/ActionButton.svelte +++ b/src/lib/components/ActionButton.svelte @@ -1,6 +1,7 @@ - + diff --git a/src/lib/components/Card.svelte b/src/lib/components/Card.svelte index 941d9c5..3eddcca 100644 --- a/src/lib/components/Card.svelte +++ b/src/lib/components/Card.svelte @@ -2,6 +2,7 @@ export let recipe export let current_month export let icon_override = false; +export let search = "search_me" if(icon_override){ current_month = recipe.season[0] @@ -29,9 +30,9 @@ if(icon_override){ display: flex; flex-direction: column; justify-content: end; - transition: 200ms; background-color: var(--blue); box-shadow: 0em 0em 2em 0.1em rgba(0, 0, 0, 0.3); + transition: 200ms; } .card .icon{ text-decoration: unset; @@ -45,17 +46,24 @@ if(icon_override){ border-radius:1000px; box-shadow: 0em 0em 2em 0.1em rgba(0, 0, 0, 0.6); } +.card:hover, +.card:focus-within{ + transform: scale(1.02,1.02); + background-color: var(--red); + box-shadow: 0.2em 0.2em 2em 1em rgba(0, 0, 0, 0.3); +} +.card:active{ + scale: 0.95 0.95; +} .card .icon:hover, .card .icon:focus-visible { box-shadow: 0em 0em 1em 0.2em rgba(0, 0, 0, 0.6); transform:scale(1.2, 1.2) } -.card:hover, -.card:focus-within{ - transform: scale(1.02,1.02); - background-color: var(--red); - box-shadow: 0.2em 0.2em 2em 1em rgba(0, 0, 0, 0.3); +.icon:active{ + scale: 0.8 0.8; + rotate: 30deg; } .card img{ @@ -116,7 +124,10 @@ if(icon_override){ background-color: var(--orange); box-shadow: 0.2em 0.2em 0.2em 0.1em rgba(0, 0, 0, 0.3); } - +.card .tag:active{ + transition: 100ms; + scale: 0.8 0.8; +} .card .title .category{ position: absolute; box-shadow: 0em 0em 1em 0.1em rgba(0, 0, 0, 0.6); @@ -138,6 +149,10 @@ if(icon_override){ background-color: var(--nord3); transform: scale(1.05, 1.05) } +.card .category:active{ + scale: 0.9 0.9; +} + .card:hover .icon, .card:focus-visible .icon { @@ -174,7 +189,7 @@ if(icon_override){ } - + {#if icon_override || recipe.season.includes(current_month)} {recipe.icon} {/if} diff --git a/src/lib/components/CardAdd.svelte b/src/lib/components/CardAdd.svelte index 87d9239..67d870e 100644 --- a/src/lib/components/CardAdd.svelte +++ b/src/lib/components/CardAdd.svelte @@ -2,9 +2,15 @@ import Cross from '$lib/assets/icons/Cross.svelte' -export let tags:string[] = [] -let new_tag +// all data shared with rest of page in card_data +export let card_data +if(!card_data.tags){ + card_data.tags = [] +} + +//locals +let new_tag let image_preview_url // Winter: ❄️ @@ -13,7 +19,6 @@ let image_preview_url // Fastenzeit: ✝️ // Herbst: 🍂 // Sommer: ☀️ -import upload_src from "$lib/assets/icons/upload.svg" export function show_local_image(){ @@ -38,15 +43,15 @@ export function remove_selected_images(){ export function add_to_tags(){ if(new_tag){ - if(! tags.includes(new_tag)){ - tags.push(new_tag) - tags = tags; + if(! card_data.tags.includes(new_tag)){ + card_data.tags.push(new_tag) + card_data.tags = card_data.tags; } } new_tag = "" } export function remove_from_tags(tag){ - tags = tags.filter(item => item !== tag) + card_data.tags = card_data.tags.filter(item => item !== tag) } export function add_on_enter(event){ if(event.key === 'Enter'){ @@ -55,14 +60,14 @@ export function add_on_enter(event){ } export function remove_on_enter(event, tag){ if(event.key === 'Enter'){ - tags = tags.filter(item => item !== tag) + card_data.tags = card_data.tags.filter(item => item !== tag) } } -{#each ingredients_lists as list, list_index} +{#each ingredients as list, list_index}

- {#if list.name} +
+ {#if list.name } {list.name} {:else} Leer {/if} - -
+
+ + +

{/each} - -
- - - - - +
+ do_on_key(event, 'Enter', false, add_new_ingredient)}> +
+ do_on_key(event, 'Enter', false, add_new_ingredient)}> + do_on_key(event, 'Enter', false, add_new_ingredient)}> + do_on_key(event, 'Enter', false, add_new_ingredient)}> + +
- - - - - - +
+ - - +

Kategorie umbenennen

+
+ do_on_key(event, 'Enter', false, add_new_ingredient)}> + +
diff --git a/src/lib/components/CreateStepList.svelte b/src/lib/components/CreateStepList.svelte index 1972556..54a18c8 100644 --- a/src/lib/components/CreateStepList.svelte +++ b/src/lib/components/CreateStepList.svelte @@ -6,16 +6,16 @@ import Plus from '$lib/assets/icons/Plus.svelte' import Check from '$lib/assets/icons/Check.svelte' import '$lib/components/nordtheme.css' +import "$lib/css/action_button.css" + +import { do_on_key } from '$lib/components/do_on_key.js' const step_placeholder = "Kartoffeln schälen..." -let instructions = [{ - name: "", - steps: [], -}] +export let instructions let new_step = { name: "", - step: "Kartoffeln schälen..." + step: step_placeholder } let edit_heading = { @@ -37,6 +37,9 @@ export function remove_list(list_index){ } export function add_new_step(){ + if(new_step.step == step_placeholder){ + return + } let list_index = get_sublist_index(new_step.name, instructions) if(list_index == -1){ instructions.push({ @@ -51,9 +54,6 @@ export function add_new_step(){ const el = document.querySelector("#step") el.innerHTML = step_placeholder instructions = instructions //tells svelte to update dom - - new_step.step = "" - add_placeholder() } export function remove_step(list_index, step_index){ @@ -107,7 +107,7 @@ export function clear_step(){ export function add_placeholder(){ const el = document.querySelector("#step") if(el.innerHTML == ""){ - el.innerHTML = "Kartoffeln schälen..." + el.innerHTML = step_placeholder } } @@ -117,6 +117,43 @@ input::placeholder{ all:unset; } + +input.heading{ + all: unset; + background-color: var(--nord0); + padding: 1rem; + padding-inline: 2rem; + font-size: 1.5rem; + width: 100%; + border-radius: 1000px; + color: white; + justify-content: center; + align-items: center; + transition: 200ms; +} +input.heading:hover, +input.heading:focus-visible +{ + background-color: var(--nord1); +} + +.heading_wrapper{ + position: relative; + width: 300px; + margin-inline: auto; + transition: 200ms; +} +.heading_wrapper:hover, +.heading_wrapper:focus-visible +{ + transform:scale(1.1,1.1); +} + +.heading_wrapper button{ + position: absolute; + bottom: -1.5rem; + right: -5rem; +} .adder{ margin-inline: auto; position: relative; @@ -129,24 +166,9 @@ input::placeholder{ box-shadow: 0 0 1em 0.2em rgba(0,0,0,0.3); } .adder button{ - all:unset; position: absolute; right: -1.5rem; bottom: -1.5rem; - cursor: pointer; - display:flex; - justify-content: center; - align-items: center; - background-color: var(--red); - border-radius:100000px; - padding: 1rem; - transition: 100ms; - box-shadow: 0 0 1em 0.4em rgba(0,0,0,0.3); -} -.adder button:hover{ - background-color: var(--nord0); - transform: scale(1.1,1.1); - box-shadow: 0 0 1em 0.8em rgba(0,0,0,0.3); } .category{ all: unset; @@ -164,11 +186,15 @@ input::placeholder{ transition: 100ms; box-shadow: 0.5em 0.5em 1em 0.4em rgba(0,0,0,0.3); } -.category:hover{ +.category:hover, +.category:focus-visible +{ background-color: var(--nord1); transform: scale(1.05,1.05); } -.adder:hover{ +.adder:hover, +.adder:focus-within +{ transform: scale(1.1, 1.1); } @@ -193,9 +219,11 @@ dialog{ box-sizing: content-box; width: 100%; height: 100%; - background-color: rgba(0, 0, 0, 0.6); + background-color: rgba(255,255,255, 0.001); border: unset; + backdrop-filter: blur(10px); margin: 0; + transition: 200ms; } dialog .adder{ margin-top: 5rem; @@ -205,37 +233,23 @@ dialog h2{ font-family: sans-serif; color: white; text-align: center; - margin-top: 30%; + margin-top: 30vh; + margin-top: 30dvh; + filter: drop-shadow(0 0 0.4em black) + drop-shadow(0 0 1em black) + ; } - -@keyframes shake{ - 0%{ - transform: rotate(0) - scale(1,1); +dialog[open]{ + animation: show 200ms ease forwards; +} +@keyframes show{ + from { + backdrop-filter: blur(0px); } - 25%{ - box-shadow: 0em 0em 1em 0.2em rgba(0, 0, 0, 0.6); - transform: rotate(30deg) - scale(1.2,1.2) - ; + to { + backdrop-filter: blur(10px); } - 50%{ - - box-shadow: 0em 0em 1em 0.2em rgba(0, 0, 0, 0.6); - transform: rotate(-30deg) - scale(1.2,1.2); - } - 74%{ - - box-shadow: 0em 0em 1em 0.2em rgba(0, 0, 0, 0.6); - transform: rotate(30deg) - scale(1.2, 1.2); - } - 100%{ - transform: rotate(0) - scale(1,1); - } - } +} @@ -269,10 +283,10 @@ dialog h2{ {/each}
- + do_on_key(event, 'Enter', false , add_new_step)} >
-

- @@ -281,18 +295,21 @@ dialog h2{

Schritt verändern

- + do_on_key(event, 'Enter', false , edit_step_and_close_modal)}>
-

-
- - +

Kategorie umbenennen

+
+ do_on_key(event, 'Enter', false, edit_subheading_steps_and_close_modal)}> + +
diff --git a/src/lib/components/RecipeEditor.svelte b/src/lib/components/RecipeEditor.svelte new file mode 100644 index 0000000..f056c6d --- /dev/null +++ b/src/lib/components/RecipeEditor.svelte @@ -0,0 +1,76 @@ + + + + + + + + + + +

Zutaten

+ +

Zubereitung

+ + diff --git a/src/lib/components/Search.svelte b/src/lib/components/Search.svelte index 8138300..17ed7d0 100644 --- a/src/lib/components/Search.svelte +++ b/src/lib/components/Search.svelte @@ -1,11 +1,10 @@ diff --git a/src/lib/components/SeasonLayout.svelte b/src/lib/components/SeasonLayout.svelte index 905ba63..e3f4f96 100644 --- a/src/lib/components/SeasonLayout.svelte +++ b/src/lib/components/SeasonLayout.svelte @@ -1,12 +1,15 @@ + + +
+{#each months as month} +
+ +
+{/each} +
+ + + diff --git a/src/lib/components/do_on_key.js b/src/lib/components/do_on_key.js new file mode 100644 index 0000000..c892737 --- /dev/null +++ b/src/lib/components/do_on_key.js @@ -0,0 +1,8 @@ +export function do_on_key(event, key, needsctrl, fn){ + if(event.key == key){ + if(needsctrl && !event.ctrlKey){ + return + } + fn() + } +} diff --git a/src/lib/css/action_button.css b/src/lib/css/action_button.css new file mode 100644 index 0000000..8c08183 --- /dev/null +++ b/src/lib/css/action_button.css @@ -0,0 +1,56 @@ +.action_button{ + all: unset; + cursor: pointer; + background-color: var(--red); + transition: 200ms; + box-shadow: 0 0 1em 0.2em rgba(0,0,0,0.3); + padding: 1rem; + border-radius: 1000px; + display: flex; + justify-content: center; + align-items: center; +} +.action_button:hover, +.action_button:focus +{ + background-color: var(--nord0); + transform: scale(1.2,1.2); + box-shadow: 0 0 1em 0.4em rgba(0,0,0,0.3); + animation: shake 0.5s ease forwards; +} + +.action_button:active{ + transition: 50ms; + scale: 0.8 0.8; + rotate: 30deg; +} + + +@keyframes shake{ + 0%{ + transform: rotate(0) + scale(1,1); + } + 25%{ + box-shadow: 0em 0em 1em 0.2em rgba(0, 0, 0, 0.6); + transform: rotate(15deg) + scale(1.2,1.2) + ; + } + 50%{ + + box-shadow: 0em 0em 1em 0.2em rgba(0, 0, 0, 0.6); + transform: rotate(-15deg) + scale(1.2,1.2); + } + 74%{ + + box-shadow: 0em 0em 1em 0.2em rgba(0, 0, 0, 0.6); + transform: rotate(15deg) + scale(1.2, 1.2); + } + 100%{ + transform: rotate(0) + scale(1.2, 1.2); + } + } diff --git a/src/lib/css/nordtheme.css b/src/lib/css/nordtheme.css new file mode 100644 index 0000000..7feacda --- /dev/null +++ b/src/lib/css/nordtheme.css @@ -0,0 +1,25 @@ +:root{ + --nord0: #2E3440; + --nord1: #3B4252; + --nord2: #434C5E; + --nord3: #4C566A; + --nord4: #D8DEE9; + --nord5: #E5E9F0; + --nord6: #ECEFF4; + --nord7: #8FBCBB; + --nord8: #88C0D0; + --nord9: #81A1C1; + --nord10: #5E81AC; + --nord11: #BF616A; + --nord12: #D08770; + --nord13: #EBCB8B; + --nord14: #A3BE8C; + --nord15: #B48EAD; + --lightblue: var(--nord9); + --blue: var(--nord10); + --red: var(--nord11); + --orange: var(--nord12); + --yellow: var(--nord13); + --green: var(--nord14); + --purple: var(--nord15); +} diff --git a/src/models/Recipe.ts b/src/models/Recipe.ts index 93eb1d6..660f632 100644 --- a/src/models/Recipe.ts +++ b/src/models/Recipe.ts @@ -2,7 +2,7 @@ import mongoose from 'mongoose'; const RecipeSchema = new mongoose.Schema( { - short_name: {type: String, required: true}, + short_name: {type: String, required: true, unique: true}, name : {type: String, required: true,}, category : {type: String, required: true,}, icon: {type: String, required: true}, diff --git a/src/routes/api/add/+server.ts b/src/routes/api/add/+server.ts index 990ec83..8f0389b 100644 --- a/src/routes/api/add/+server.ts +++ b/src/routes/api/add/+server.ts @@ -12,12 +12,14 @@ export const POST: RequestHandler = async ({request}) => { console.log("RECIPE:", recipe_json) console.log("BEARER:", bearer_token) if(bearer_token === BEARER_TOKEN){ + console.log("PASSWORD CORRECT") await dbConnect(); await Recipe.create(recipe_json); await dbDisconnect(); - return {status: 400} + return {status: 400} //TODO: cleanup error throwing } else{ + console.log("PASSWORD INCORRECT") return {status: 403} } }; diff --git a/src/routes/api/edit/+server.ts b/src/routes/api/edit/+server.ts new file mode 100644 index 0000000..c06b814 --- /dev/null +++ b/src/routes/api/edit/+server.ts @@ -0,0 +1,25 @@ +import type { RequestHandler } from '@sveltejs/kit'; +import { Recipe } from '../../../models/Recipe'; +import { dbConnect, dbDisconnect } from '../../../utils/db'; +import type {RecipeModelType} from '../../../types/types'; +import { BEARER_TOKEN } from '$env/static/private' +// header: use for bearer token for now +// recipe json in body +export const POST: RequestHandler = async ({request}) => { + console.log("AT EDIT API") + let message = await request.json() + const recipe_json = message.recipe + const bearer_token = message.headers.bearer + console.log("RECIPE:", recipe_json) + console.log("BEARER:", bearer_token) + if(bearer_token === BEARER_TOKEN){ + await dbConnect(); + await Recipe.findOneAndUpdate({short_name: message.old_short_name }, recipe_json); + await dbDisconnect(); + return {status: 400} //TODO: cleanup error throwing + } + else{ + console.log("PASSWORD INCORRECT") + return {status: 403} + } +}; diff --git a/src/routes/rezepte/+page.svelte b/src/routes/rezepte/+page.svelte index 5f441ca..5226dd8 100644 --- a/src/routes/rezepte/+page.svelte +++ b/src/routes/rezepte/+page.svelte @@ -8,30 +8,17 @@ export let data: PageData; export let current_month = new Date().getMonth() + 1 - +

Rezepte

In Saison

{#each data.season as recipe} - + {/each}
- +

Alle Rezepte

{#each data.all_brief as recipe} diff --git a/src/routes/rezepte/add/+page.svelte b/src/routes/rezepte/add/+page.svelte index 4c09ffd..73d66fe 100644 --- a/src/routes/rezepte/add/+page.svelte +++ b/src/routes/rezepte/add/+page.svelte @@ -1,41 +1,43 @@

Rezept hinzufügen

- + + + + + + -

Zutaten

- +

Zubereitung

- + + + diff --git a/src/routes/rezepte/category/[category]/+page.svelte b/src/routes/rezepte/category/[category]/+page.svelte index ea98201..fa42ba5 100644 --- a/src/routes/rezepte/category/[category]/+page.svelte +++ b/src/routes/rezepte/category/[category]/+page.svelte @@ -1,12 +1,14 @@

Rezepte

In Kategorie {data.category}

+
{#each data.recipes as recipe} diff --git a/src/routes/rezepte/edit/.jukit/.jukit_info.json b/src/routes/rezepte/edit/.jukit/.jukit_info.json new file mode 100644 index 0000000..92c7342 --- /dev/null +++ b/src/routes/rezepte/edit/.jukit/.jukit_info.json @@ -0,0 +1 @@ +{"terminal": "nvimterm"} \ No newline at end of file diff --git a/src/routes/rezepte/edit/[name]/+page.svelte b/src/routes/rezepte/edit/[name]/+page.svelte new file mode 100644 index 0000000..26af762 --- /dev/null +++ b/src/routes/rezepte/edit/[name]/+page.svelte @@ -0,0 +1,102 @@ + + + +

Rezept hinzufügen

+ + + + + + +

Zutaten

+ +

Zubereitung

+ + + diff --git a/src/routes/rezepte/edit/[name]/+page.ts b/src/routes/rezepte/edit/[name]/+page.ts new file mode 100644 index 0000000..786ac8f --- /dev/null +++ b/src/routes/rezepte/edit/[name]/+page.ts @@ -0,0 +1,8 @@ +import type { PageLoad } from "./$types"; + +export async function load({ fetch, params}) { + let current_month = new Date().getMonth() + 1 + const res = await fetch(`/api/items/${params.name}`); + const recipe = await res.json(); + return {recipe}; +}; diff --git a/src/routes/rezepte/edit/[name]/.jukit/.jukit_info.json b/src/routes/rezepte/edit/[name]/.jukit/.jukit_info.json new file mode 100644 index 0000000..92c7342 --- /dev/null +++ b/src/routes/rezepte/edit/[name]/.jukit/.jukit_info.json @@ -0,0 +1 @@ +{"terminal": "nvimterm"} \ No newline at end of file diff --git a/src/routes/rezepte/season/+page.svelte b/src/routes/rezepte/season/+page.svelte index 4b22371..cb6c1dc 100644 --- a/src/routes/rezepte/season/+page.svelte +++ b/src/routes/rezepte/season/+page.svelte @@ -11,9 +11,7 @@ -

Rezepte des Monats

- {#each data.season as recipe} diff --git a/src/routes/rezepte/tag/[tag]/+page.svelte b/src/routes/rezepte/tag/[tag]/+page.svelte index b8901bc..ba40020 100644 --- a/src/routes/rezepte/tag/[tag]/+page.svelte +++ b/src/routes/rezepte/tag/[tag]/+page.svelte @@ -4,9 +4,11 @@ export let data: PageData; export let current_month = new Date().getMonth() + 1; import Card from '$lib/components/Card.svelte' + import Search from '$lib/components/Search.svelte';

Rezepte

In Tag {data.tag}

+
{#each data.recipes as recipe}