From 2ba62592b3e89195dfd3bd0e079b6b63e4758ed1 Mon Sep 17 00:00:00 2001 From: Alexander Bocken Date: Mon, 11 Dec 2023 21:32:16 +0100 Subject: [PATCH] initial move entries setup --- .../components/CreateIngredientList.svelte | 73 +++++++++++++++-- src/lib/components/CreateStepList.svelte | 79 ++++++++++++++++++- 2 files changed, 143 insertions(+), 9 deletions(-) diff --git a/src/lib/components/CreateIngredientList.svelte b/src/lib/components/CreateIngredientList.svelte index b64c960..a5b3538 100644 --- a/src/lib/components/CreateIngredientList.svelte +++ b/src/lib/components/CreateIngredientList.svelte @@ -1,5 +1,6 @@ @@ -283,7 +314,6 @@ dialog h2{ .mod_icons{ display: flex; flex-direction: row; - margin-left: 2rem; } .button_subtle{ padding: 0em; @@ -295,20 +325,36 @@ dialog h2{ .button_subtle:hover{ scale: 1.2 1.2; } +.move_buttons_container{ + display: flex; + flex-direction: column; +} +.move_buttons_container button{ + background-color: transparent; + border: none; + padding: 0; + margin: 0; + transition: 200ms; +} +.move_buttons_container button:hover{ + scale: 1.4; +} h3{ width: fit-content; display: flex; flex-direction: row; + align-items: center; max-width: 1000px; justify-content: space-between; user-select: none; cursor: pointer; + gap: 1em; } .ingredients_grid{ box-sizing: border-box; display: grid; font-size: 1.1em; - grid-template-columns: 2fr 3fr 1fr; + grid-template-columns: 0.5fr 2fr 3fr 1fr; grid-template-rows: auto; grid-auto-flow: row; align-items: center; @@ -359,8 +405,17 @@ h3{

Zutaten

{#each ingredients as list, list_index} -

-
+

+
+ + +
+ +
{#if list.name } {list.name} {:else} @@ -375,7 +430,15 @@ h3{

- {#each list.list as ingredient, ingredient_index} + {#each list.list as ingredient, ingredient_index (ingredient_index)} +
+ + +
show_modal_edit_ingredient(list_index, ingredient_index)} >{ingredient.amount} {ingredient.unit}
diff --git a/src/lib/components/CreateStepList.svelte b/src/lib/components/CreateStepList.svelte index 7278f1e..0e7491e 100644 --- a/src/lib/components/CreateStepList.svelte +++ b/src/lib/components/CreateStepList.svelte @@ -117,13 +117,66 @@ export function add_placeholder(){ el.innerHTML = step_placeholder } } + +export function update_list_position(list_index, direction){ + if(direction == 1){ + if(list_index == 0){ + return + } + instructions.splice(list_index - 1, 0, instructions.splice(list_index, 1)[0]) + } + else if(direction == -1){ + if(list_index == instructions.length - 1){ + return + } + instructions.splice(list_index + 1, 0, instructions.splice(list_index, 1)[0]) + } + instructions = instructions //tells svelte to update dom +} +export function update_step_position(list_index, step_index, direction){ + if(direction == 1){ + if(step_index == 0){ + return + } + instructions[list_index].steps.splice(step_index - 1, 0, instructions[list_index].steps.splice(step_index, 1)[0]) + } + else if(direction == -1){ + if(step_index == instructions[list_index].steps.length - 1){ + return + } + instructions[list_index].steps.splice(step_index + 1, 0, instructions[list_index].steps.splice(step_index, 1)[0]) + } + instructions = instructions //tells svelte to update dom +}