\ No newline at end of file
diff --git a/src/script/newRecipe.ts b/src/script/newRecipe.ts
new file mode 100644
index 0000000..8367fe8
--- /dev/null
+++ b/src/script/newRecipe.ts
@@ -0,0 +1,69 @@
+let ingredientFields: HTMLInputElement[] = []
+let ingredientTable: HTMLTableSectionElement = document.querySelector('#ingredient-table')!
+let ingredientAddButton: HTMLButtonElement = document.querySelector('#add-ingredient-btn')!
+
+// - VARS
+let ingredients: {qty: string, unit: string, name: string}[] = []
+let steps: {
+ name: string,
+ description: string,
+ servings: number,
+ rating: number,
+ worktime: number,
+ waittime: number,
+ images: string[], // record ID of uploaded image
+
+}[] = []
+
+// - INIT
+document.addEventListener('DOMContentLoaded', function() {
+
+ ingredientFields.push(
+ document.querySelector('#ing-qty')!,
+ document.querySelector('#ing-unit')!,
+ document.querySelector('#ing-name')!
+ )
+
+ // show plus button once the user clicks off one of the text fields
+ ingredientFields.forEach(f => f.addEventListener('beforeinput', showAddIngredientButton))
+ // onclick for add button
+ document.querySelector('#add-ingredient-btn')?.addEventListener('click', addIngredient);
+ // for pressing enter to reset cursor
+ ingredientFields[2].addEventListener('keyup', e => {if (e.key === 'Enter') addIngredient()} )
+});
+
+// - ADD
+function addIngredient() {
+ const ing = {
+ qty: ingredientFields[0].value,
+ unit: ingredientFields[1].value,
+ name: ingredientFields[2].value
+ }
+
+ ingredients.push(ing)
+
+ const newRow = document.createElement('tr')
+ newRow.innerHTML = `
+
${ing.qty} |
+
${ing.unit} |
+
${ing.name} |
+ `
+
+ // Add row to table and clear fields
+ ingredientTable.appendChild(newRow)
+ ingredientFields.forEach(f => f.value = '')
+ ingredientAddButton.style.display = 'none' // Hide Add Ingredient button
+ // move cursor to Qty field again
+ ingredientFields[0].focus()
+}
+
+// - UTILS
+function showAddIngredientButton() {
+ // only show if there is text in the field
+
+ if (ingredientFields[0].value && ingredientFields[2].value) {
+ ingredientAddButton.style.display = 'block'
+ } else {
+ ingredientAddButton.style.display = 'hidden'
+ }
+}
\ No newline at end of file
diff --git a/tsconfig.json b/tsconfig.json
index ccf6cb5..a95a021 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -7,6 +7,7 @@
"paths": {
"@/components/*": ["src/components/*.astro"],
"@/layouts/*": ["src/layouts/*.astro"],
+ "@/script/*": ["src/script/*"],
"@/utils": ["src/utils/index.ts"],
"@/data/*": ["src/data/*"],
"@/site-config": ["src/site.config.ts"]