Compare commits

..

26 Commits

Author SHA1 Message Date
1bcc10575a padding change 2025-08-15 16:01:45 +12:00
1841aa9cba Colour transition for button disabling 2025-08-15 15:55:29 +12:00
fbef074912 Keep focus on new step field when pressing add 2025-08-15 15:37:20 +12:00
a9e4d5fb50 Enter key navigation for ingredient fields, great for mobile 2025-08-15 15:21:48 +12:00
4dc45b4e70 Add step button which acts like a click 2025-08-15 15:11:36 +12:00
0e469e6024 Always show add ingredient button and alter disable value. Also much better handling of the state too 2025-08-15 14:58:55 +12:00
2604d438f7 ultra small but fixed padding issue on textbox 2025-08-15 14:48:12 +12:00
c420a63a2c Step re-ordering implemented but at what (technical) cost man... 2025-08-15 14:41:55 +12:00
5949c7e35c Fix shift+enter leaving a new line in input 2025-08-15 14:23:09 +12:00
8c22c92dee Initial implementation of adding new steps 2025-08-15 14:20:42 +12:00
691a340ad4 Refactored AddRecipe to its own script file, started implementing adding steps 2025-08-15 13:32:58 +12:00
c52d9f79bb Style add button to be presentable 2025-08-14 23:12:44 +12:00
dce5ba8990 Pressing enter/return clears the fields and returns the cursor to the Qty input 2025-08-14 18:48:03 +12:00
89c04bb909 Add ingredients as rows to the column, and reset the form 2025-08-14 18:29:39 +12:00
4dd50aae36 Starting to add script for adding ingredients 2025-08-14 18:04:21 +12:00
aa2409e591 Change leading in recipe title 2025-08-14 11:37:12 +12:00
7c87342dea name field expands when overflow 2025-08-14 11:31:09 +12:00
97cc5da5b8 Fix table rows being out of alignment 2025-08-14 11:23:51 +12:00
b9c665860f Use fixed table widths 2025-08-14 11:19:34 +12:00
5a171f0f0f Fix styling for new ingredient table 2025-08-14 11:08:25 +12:00
88f6628ee0 Change ratio and text size of step ingredient list 2025-08-14 11:08:25 +12:00
c92c754f5f Changed formatting to have title on left column at all times 2025-08-14 11:08:25 +12:00
672191cc5b fix edge-case layout bug 2025-08-14 11:08:25 +12:00
e487637600 Added basic new recipe page 2025-08-14 11:08:25 +12:00
d191c04bbf i keep getting distracted bruh 2025-08-14 11:08:25 +12:00
8cf8f50ff9 Add underline feedback for top bar 2025-08-14 11:08:25 +12:00
4 changed files with 24 additions and 91 deletions

View File

@@ -1,11 +1,4 @@
import Pocketbase, { type RecordListOptions } from "pocketbase" import Pocketbase from "pocketbase"
import {
type Recipe,
type Ingredient,
type Step,
type Tag,
Collection
} from './schema'
const client = new Pocketbase("http://localhost:4321") const client = new Pocketbase("http://localhost:4321")
client.autoCancellation(false) client.autoCancellation(false)
@@ -16,27 +9,4 @@ client.files.getRelativeURL = (record: { [key: string]: any; }, filename: string
return res.substring(21) return res.substring(21)
} }
export default client; export default client;
class APIClient {
client: Pocketbase
constructor() {
this.client = new Pocketbase("http://localhost:4321")
this.client.autoCancellation(false)
}
async getRecipesPaginated(page: number, perPage: number = 30, options: RecordListOptions) {
return await this.client.collection<Recipe>(Collection.RECIPES).getList(page, perPage, options)
}
async getAllRecipes() {
return await this.client.collection<Recipe>(Collection.RECIPES).getFullList({ expand: "steps,ingredients,tags" })
}
async getRecipe(id: string) {
return await this.client.collection<Recipe>(Collection.RECIPES).getOne(id, { expand: 'ingredients,tags,steps' })
}
}
export const client2 = new APIClient()

View File

@@ -1,53 +0,0 @@
// Base PB type
export interface BaseRecord {
id: string,
created: string,
updated: string
}
export interface Ingredient extends BaseRecord {
quantity: string,
unit: string,
name: string
}
export interface Step extends BaseRecord {
index: number,
instruction: string,
ingredients?: Ingredient[]
}
export interface Tag extends BaseRecord {
name: string
}
// not sure Image is the best type cos it might be quite heavy to get all the fields every time but
// it is here in case it is (a good idea)
export interface Image extends BaseRecord {
id: string
}
export interface Recipe extends BaseRecord {
name: string,
description?: string,
servings?: number,
images?: string[], // image IDs
ingredients: string[]
steps: string[],
tags?: string[]
expand: {
images?: Image[], // image IDs,
ingredients: Ingredient[]
steps: Step[],
tags?: Tag[]
}
}
export const Collection = {
RECIPES: 'recipes',
STEPS: 'steps',
INGREDIENTS: 'ingredients',
TAGS: 'tags',
IMAGES: 'images'
}

View File

@@ -5,7 +5,8 @@ import type { APIRoute } from "astro";
const getProxyUrl = (request: Request) => { const getProxyUrl = (request: Request) => {
const proxyUrl = new URL(import.meta.env.PUBLIC_PB_URL); const proxyUrl = new URL(import.meta.env.PUBLIC_PB_URL);
const requestUrl = new URL(request.url); const requestUrl = new URL(request.url);
return new URL(requestUrl.pathname + requestUrl.search, proxyUrl);
return new URL(requestUrl.pathname, proxyUrl);
}; };
export const ALL: APIRoute = async ({ request }) => { export const ALL: APIRoute = async ({ request }) => {

View File

@@ -1,6 +1,5 @@
--- ---
import client, { client2 } from "@/data/pocketbase"; import client from "@/data/pocketbase";
import SiteLayout from "@/layouts/base"; import SiteLayout from "@/layouts/base";
import ImageCarousel from "@/components/Detail/ImageCarousel"; import ImageCarousel from "@/components/Detail/ImageCarousel";
import IngredientTableView from "@/components/Detail/IngredientTableView"; import IngredientTableView from "@/components/Detail/IngredientTableView";
@@ -9,7 +8,23 @@ import InfoView from "@/components/Detail/InfoView";
const { recipeid } = Astro.params; const { recipeid } = Astro.params;
const re = await client2.getRecipe(recipeid as string) const re = await client.collection("recipes").getOne(recipeid ?? "0");
const stepIds = re.steps
let steps = await Promise.all(
stepIds.map(async s =>
await client.collection("steps").getOne(s)
)
)
steps = steps.sort((a, b) => a.index - b.index);
const ingredients = await Promise.all(
re.ingredients.map(async s =>
await client.collection("ingredients").getOne(s)
)
)
--- ---
<SiteLayout> <SiteLayout>
@@ -22,12 +37,12 @@ const re = await client2.getRecipe(recipeid as string)
<InfoView re={re} /> <InfoView re={re} />
<p class="text-[22pt] font-bold 'md:mt-4'">Ingredients</p> <p class="text-[22pt] font-bold 'md:mt-4'">Ingredients</p>
<IngredientTableView class:list={['md:w-80', 'px-4']} ingredients={re.expand.ingredients} /> <IngredientTableView class:list={['md:w-80', 'px-4']} ingredients={ingredients} />
</div> </div>
<div class="flex mt-4 md:flex-2/3 w-full flex-col"> <div class="flex mt-4 md:flex-2/3 w-full flex-col">
<!-- Steps --> <!-- Steps -->
<StepView class="md:ml-3" steps={re.expand.steps} /> <StepView class="md:ml-3" steps={steps} />
</div> </div>
</div> </div>