Compare commits
15 Commits
PIE-9
...
dce5ba8990
| Author | SHA1 | Date | |
|---|---|---|---|
|
dce5ba8990
|
|||
|
89c04bb909
|
|||
|
4dd50aae36
|
|||
|
aa2409e591
|
|||
|
7c87342dea
|
|||
|
97cc5da5b8
|
|||
|
b9c665860f
|
|||
| 5a171f0f0f | |||
| 88f6628ee0 | |||
| c92c754f5f | |||
| 672191cc5b | |||
| e487637600 | |||
| d191c04bbf | |||
| 8cf8f50ff9 | |||
| 26cab10c14 |
@@ -19,7 +19,7 @@ const tableView = true
|
||||
)}
|
||||
|
||||
{tableView && (
|
||||
<table class={`table-auto text-left bg-[#2a2b2c] rounded-lg ${className} w-full`}>
|
||||
<table class={`table-auto text-left bg-[#2a2b2c] rounded-lg ${className}`}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-4 py-2">Quantity</th>
|
||||
@@ -29,9 +29,9 @@ const tableView = true
|
||||
</thead>
|
||||
<tbody>
|
||||
{
|
||||
ingredients.map(ing => (
|
||||
ingredients.map((ing, index) => (
|
||||
<>
|
||||
<tr class="border-t border-gray-600">
|
||||
<tr class="border-t border-white/10 cursor-pointer hover:bg-white/10 transition-opacity ingredient-row" data-index={index}>
|
||||
<td class="px-4 py-2">{ing.quantity}</td>
|
||||
<td class="px-4 py-2">{ing.unit}</td>
|
||||
<td class="px-4 py-2">{ing.name}</td>
|
||||
@@ -42,3 +42,27 @@ const tableView = true
|
||||
</tbody>
|
||||
</table>
|
||||
)}
|
||||
|
||||
<style>
|
||||
.ingredient-row.completed {
|
||||
/* background-color: rgba(0, 0, 0, 0.4) !important; */
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.ingredient-row.completed td {
|
||||
text-decoration: line-through;
|
||||
color: rgba(255, 255, 255, 0.5);
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const rows = document.querySelectorAll('.ingredient-row');
|
||||
|
||||
rows.forEach(row => {
|
||||
row.addEventListener('click', function() {
|
||||
this.classList.toggle('completed');
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -10,7 +10,7 @@ const ings = await Promise.all(
|
||||
|
||||
<div class={className}>
|
||||
{ings.map(i => (
|
||||
<div>
|
||||
<div class="text-sm">
|
||||
<p>• {i.quantity} {i.unit || " "} {i.name}</p>
|
||||
</div>
|
||||
))}
|
||||
|
||||
@@ -3,10 +3,10 @@ import { record } from "astro:schema"
|
||||
import client from "@/data/pocketbase"
|
||||
import StepIngredientSideView from "./StepIngredientSideView.astro"
|
||||
|
||||
const { steps } = Astro.props
|
||||
const { steps, class: className } = Astro.props
|
||||
---
|
||||
|
||||
<div class="md:ml-5 mt-2 md:mt-0">
|
||||
<div class={className}>
|
||||
<p class="text-[22pt] font-bold md:hidden">Steps</p>
|
||||
{ steps.map(s => (
|
||||
<div class="bg-[#2a2b2c] rounded-lg mb-2 p-3">
|
||||
@@ -15,7 +15,7 @@ const { steps } = Astro.props
|
||||
<div class="flex flex-col md:flex-row md:items-stretch">
|
||||
<p class="w-full md:flex-2/3 pr-1 text-left">{s.instruction}</p>
|
||||
{s.ingredients && s.ingredients.length > 0 && (
|
||||
<div class="w-full md:w-auto md:flex-1/3 mt-2 md:mt-0 md:ml-2 md:pl-3 md:border-l text-white/70 border-white/70">
|
||||
<div class="w-full md:w-auto md:flex-2/5 mt-2 md:mt-0 md:ml-2 md:pl-3 md:border-l text-white/70 border-white/70">
|
||||
<StepIngredientSideView class="text-left" ingredients={s.ingredients} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
</a>
|
||||
|
||||
<div class="ml-auto space-x-5">
|
||||
<a>new</a>
|
||||
<a>tags</a>
|
||||
<a>search</a>
|
||||
<a class="hover:underline underline-offset-4 " href="/recipe/new">new</a>
|
||||
<a class="hover:underline underline-offset-4 " >tags</a>
|
||||
<a class="hover:underline underline-offset-4 " >search</a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -28,10 +28,10 @@ const ingredients = await Promise.all(
|
||||
---
|
||||
|
||||
<SiteLayout>
|
||||
<div class="flex flex-col md:flex-row">
|
||||
<div class="flex flex-col mt-2 md:mt-4 sticky">
|
||||
<div class="flex flex-col md:flex-row mx-auto justify-center w-full lg:max-w-3/4 xl:max-w-2/3 2xl:max-w-1/2">
|
||||
<div class="flex md:flex-1/3 flex-col mt-2 md:mt-4 sticky">
|
||||
<ImageCarousel class="w-full" recipe={re} />
|
||||
<p class=" md:hidden text-[28pt] font-bold leading-none mt-2">{re.name}</p>
|
||||
<p class="text-[28pt] font-bold leading-11 mt-2">{re.name}</p>
|
||||
|
||||
<!-- Details -->
|
||||
<InfoView re={re} />
|
||||
@@ -40,11 +40,9 @@ const ingredients = await Promise.all(
|
||||
<IngredientTableView class:list={['md:w-80', 'px-4']} ingredients={ingredients} />
|
||||
</div>
|
||||
|
||||
<div class="flex w-full flex-col">
|
||||
<p class="hidden md:block text-[28pt] font-bold pl-5">{re.name}</p>
|
||||
|
||||
<div class="flex mt-4 md:flex-2/3 w-full flex-col">
|
||||
<!-- Steps -->
|
||||
<StepView steps={steps} />
|
||||
<StepView class="md:ml-3" steps={steps} />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
135
src/pages/recipe/new.astro
Normal file
135
src/pages/recipe/new.astro
Normal file
@@ -0,0 +1,135 @@
|
||||
---
|
||||
import SiteLayout from "@/layouts/base";
|
||||
|
||||
const { recipeid } = Astro.params;
|
||||
|
||||
// Actually post the recipe with the stored variables
|
||||
async function submitRecipe() {
|
||||
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
<!-- INGREDIENT SCRIPT -->
|
||||
<script>
|
||||
let ingredientFields: HTMLInputElement[] = []
|
||||
let ingredientTable: HTMLTableSectionElement = document.querySelector('#ingredient-table')!
|
||||
let ingredientAddButton: HTMLButtonElement = document.querySelector('#add-ingredient-btn')!
|
||||
|
||||
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 => clearInputFields(e))
|
||||
});
|
||||
|
||||
let ingredients: {qty: string, unit: string, name: string}[] = []
|
||||
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 = `
|
||||
<td class="px-4 py-2 border-t border-white/10">${ing.qty}</td>
|
||||
<td class="px-4 py-2 border-t border-white/10">${ing.unit}</td>
|
||||
<td class="px-4 py-2 border-t border-white/10">${ing.name}</td>
|
||||
`
|
||||
|
||||
ingredientTable.appendChild(newRow)
|
||||
ingredientFields.forEach(f => f.value = '')
|
||||
ingredientAddButton.style.display = 'none'
|
||||
}
|
||||
|
||||
function clearInputFields(e: KeyboardEvent) {
|
||||
// clear input fields
|
||||
if (e.key === 'Enter') {
|
||||
addIngredient()
|
||||
ingredientFields.forEach(f => f.value == '')
|
||||
// move cursor to Qty field again
|
||||
ingredientFields[0].focus()
|
||||
}
|
||||
}
|
||||
|
||||
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'
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<SiteLayout>
|
||||
<div class="flex flex-col md:flex-row mx-auto justify-center w-full lg:max-w-3/4 xl:max-w-2/3 2xl:max-w-1/2">
|
||||
<div class="flex md:flex-1/3 flex-col mt-2 md:mt-4 sticky">
|
||||
<div class="w-full bg-white/10 rounded-lg h-50">
|
||||
Image Upload
|
||||
</div>
|
||||
<!-- <ImageCarousel class="w-full" recipe={re} /> -->
|
||||
<textarea
|
||||
id="rec-name"
|
||||
name="name"
|
||||
rows="1"
|
||||
placeholder="Name"
|
||||
class="text-[28pt] font-bold p-1 leading-none mt-2 bg-white/10 rounded-lg resize-none overflow-hidden"
|
||||
oninput="this.style.height = ''; this.style.height = this.scrollHeight + 'px'"
|
||||
/>
|
||||
<!-- if it works :3 -->
|
||||
|
||||
<!-- Details -->
|
||||
<!-- <InfoView re={re} /> -->
|
||||
|
||||
<div class="flex flex-row align-middle items-center">
|
||||
<p class="mt-4 text-[22pt] font-bold 'mt-4'">Ingredients</p>
|
||||
<button class="hidden" id="add-ingredient-btn">add</button>
|
||||
</div>
|
||||
<table class={`table-fixed text-left bg-[#2a2b2c] rounded-lg w-full`}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-4 py-2 w-18">Qty</th>
|
||||
<th class="px-4 py-2 w-20">Unit</th>
|
||||
<th class="px-4 py-2">Ingredient</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="ingredient-table" class="w-full border-t px-4 py-2 border-gray-600">
|
||||
<tr id="ingredient-input" class="">
|
||||
<td class="px-2 py-1">
|
||||
<input id="ing-qty" class="w-full h-9 bg-white/10 rounded-lg px-2 py-2" type="text" placeholder="Qty">
|
||||
</td>
|
||||
<td class="px-2 py-1">
|
||||
<input id="ing-unit" class="w-full h-9 bg-white/10 rounded-lg px-2 py-2" type="text" placeholder="Unit">
|
||||
</td>
|
||||
<td class="px-2 py-1">
|
||||
<!-- <textarea id="ing-name" class="w-full h-11 bg-white/20 rounded-lg px-2 py-3 mt-1 resize-none leading-tight" placeholder="Ingredient" rows="1"/> -->
|
||||
<input id="ing-name" class="w-full h-9 bg-white/10 rounded-lg px-2 py-2" type="text" placeholder="Ingredient">
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="flex mt-4 md:flex-2/3 w-full flex-col">
|
||||
<!-- <p class="hidden md:block text-[28pt] font-bold pl-5">Helloi</p> -->
|
||||
|
||||
<!-- Steps -->
|
||||
<!-- <StepView steps={steps} /> -->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</SiteLayout>
|
||||
Reference in New Issue
Block a user