diff --git a/RecipeCard/c71c62b2-501b-45e0-9a13-34c9729e2b14.json b/RecipeCard/c71c62b2-501b-45e0-9a13-34c9729e2b14.json deleted file mode 100644 index c27880a..0000000 --- a/RecipeCard/c71c62b2-501b-45e0-9a13-34c9729e2b14.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "data": { - "meta": { - "adoptsFrom": { - "name": "RecipeCard", - "module": "../recipe-card" - } - }, - "type": "card", - "attributes": { - "tags": [], - "tips": null, - "cuisine": null, - "cardInfo": { - "name": null, - "notes": null, - "summary": null, - "cardThumbnailURL": null - }, - "cookTime": null, - "prepTime": null, - "servings": null, - "difficulty": null, - "recipeName": "Aglio Olio Pasta", - "description": null, - "ingredients": [], - "instructions": null - }, - "relationships": { - "cardInfo.theme": { - "links": { - "self": null - } - } - } - } -} \ No newline at end of file diff --git a/recipe-card.gts b/recipe-card.gts deleted file mode 100644 index 4fb3aad..0000000 --- a/recipe-card.gts +++ /dev/null @@ -1,1167 +0,0 @@ -import { and } from '@cardstack/boxel-ui/helpers'; -// ═══ [EDIT TRACKING: ON] Mark all changes with ⁿ ═══ -import { - CardDef, - FieldDef, - field, - contains, - containsMany, - Component, -} from 'https://cardstack.com/base/card-api'; // ¹ -import StringField from 'https://cardstack.com/base/string'; // ² -import NumberField from 'https://cardstack.com/base/number'; // ³ -import TextAreaField from 'https://cardstack.com/base/text-area'; // ⁴ -import MarkdownField from 'https://cardstack.com/base/markdown'; // ⁵ -import enumField from 'https://cardstack.com/base/enum'; // ⁶ -import UtensilsIcon from '@cardstack/boxel-icons/utensils'; // ⁷ -import ClockIcon from '@cardstack/boxel-icons/clock'; // ⁸ -import UsersIcon from '@cardstack/boxel-icons/users'; // ⁹ -import ChefHatIcon from '@cardstack/boxel-icons/chef-hat'; // ¹⁰ - -// ¹¹ Difficulty enum -const DifficultyField = enumField(StringField, { - options: ['Easy', 'Medium', 'Hard', 'Expert'], -}); - -// ¹² Ingredient field definition -export class IngredientField extends FieldDef { - // ¹³ - static displayName = 'Ingredient'; - - @field name = contains(StringField); // ¹⁴ - @field amount = contains(StringField); // ¹⁵ - @field unit = contains(StringField); // ¹⁶ - @field notes = contains(StringField); // ¹⁷ - - static embedded = class Embedded extends Component { - // ¹⁸ - - }; - - static atom = class Atom extends Component { - // ¹⁹ - - }; -} - -// ²⁰ Main recipe card -export class RecipeCard extends CardDef { - // ²¹ - static displayName = 'Recipe'; - static icon = UtensilsIcon; // ²² - static prefersWideFormat = true; // ²³ - - @field recipeName = contains(StringField); // ²⁴ - @field description = contains(TextAreaField); // ²⁵ - @field prepTime = contains(NumberField); // ²⁶ in minutes - @field cookTime = contains(NumberField); // ²⁷ in minutes - @field servings = contains(NumberField); // ²⁸ - @field difficulty = contains(DifficultyField); // ²⁹ - @field cuisine = contains(StringField); // ³⁰ - @field ingredients = containsMany(IngredientField); // ³¹ - @field instructions = contains(MarkdownField); // ³² - @field tips = contains(TextAreaField); // ³³ - @field tags = containsMany(StringField); // ³⁴ - - @field cardTitle = contains(StringField, { - // ³⁵ - computeVia: function (this: RecipeCard) { - return this.cardInfo?.name ?? this.recipeName ?? 'Untitled Recipe'; - }, - }); - - // ³⁶ Total time computed - get totalTimeDisplay() { - // ³⁷ - try { - const prep = this.prepTime ?? 0; - const cook = this.cookTime ?? 0; - const total = prep + cook; - if (total === 0) return null; - if (total >= 60) { - const hours = Math.floor(total / 60); - const mins = total % 60; - return mins > 0 ? `${hours}h ${mins}m` : `${hours}h`; - } - return `${total}m`; - } catch (e) { - return null; - } - } - - // ³⁸ Isolated format - static isolated = class Isolated extends Component { - get prepDisplay() { - // ³⁹ - try { - const v = this.args.model?.prepTime; - if (!v) return null; - return v >= 60 - ? `${Math.floor(v / 60)}h ${v % 60 > 0 ? (v % 60) + 'm' : ''}`.trim() - : `${v}m`; - } catch (e) { - return null; - } - } - - get cookDisplay() { - // ⁴⁰ - try { - const v = this.args.model?.cookTime; - if (!v) return null; - return v >= 60 - ? `${Math.floor(v / 60)}h ${v % 60 > 0 ? (v % 60) + 'm' : ''}`.trim() - : `${v}m`; - } catch (e) { - return null; - } - } - - get totalDisplay() { - // ⁴¹ - try { - const prep = this.args.model?.prepTime ?? 0; - const cook = this.args.model?.cookTime ?? 0; - const total = prep + cook; - if (total === 0) return null; - return total >= 60 - ? `${Math.floor(total / 60)}h ${total % 60 > 0 ? (total % 60) + 'm' : ''}`.trim() - : `${total}m`; - } catch (e) { - return null; - } - } - - get difficultyColor() { - // ⁴² - const map: Record = { - Easy: 'var(--chart-2)', - Medium: 'var(--chart-3)', - Hard: 'var(--chart-4)', - Expert: 'var(--chart-1)', - }; - return ( - map[this.args.model?.difficulty ?? ''] ?? 'var(--muted-foreground)' - ); - } - - - }; - - // ⁴⁴ Embedded format - static embedded = class Embedded extends Component { - get totalDisplay() { - // ⁴⁵ - try { - const prep = this.args.model?.prepTime ?? 0; - const cook = this.args.model?.cookTime ?? 0; - const total = prep + cook; - if (total === 0) return null; - return total >= 60 - ? `${Math.floor(total / 60)}h ${total % 60 > 0 ? (total % 60) + 'm' : ''}`.trim() - : `${total}m`; - } catch (e) { - return null; - } - } - - - }; - - // ⁴⁶ Fitted format - static fitted = class Fitted extends Component { - get totalDisplay() { - // ⁴⁷ - try { - const prep = this.args.model?.prepTime ?? 0; - const cook = this.args.model?.cookTime ?? 0; - const total = prep + cook; - if (total === 0) return null; - return total >= 60 - ? `${Math.floor(total / 60)}h ${total % 60 > 0 ? (total % 60) + 'm' : ''}`.trim() - : `${total}m`; - } catch (e) { - return null; - } - } - - - }; -} diff --git a/tests/acceptance/catalog-app-test.gts b/tests/acceptance/catalog-app-test.gts index 6b799e1..8580762 100644 --- a/tests/acceptance/catalog-app-test.gts +++ b/tests/acceptance/catalog-app-test.gts @@ -1973,7 +1973,7 @@ module('Acceptance | Catalog | catalog app tests', function (hooks) { const commandService = getService('command-service'); const command = new ListingCreateCommand(commandService.commandContext); const result = await command.execute({ - openCardId: cardId, + openCardIds: [cardId], codeRef: { module: `${mockCatalogURL}author/author.gts`, name: 'Author', @@ -2058,7 +2058,7 @@ module('Acceptance | Catalog | catalog app tests', function (hooks) { const commandService = getService('command-service'); const command = new ListingCreateCommand(commandService.commandContext); await command.execute({ - openCardId: cardId, + openCardIds: [cardId], codeRef: { module: `${mockCatalogURL}card-with-unrecognised-imports.gts`, name: 'UnrecognisedImports', @@ -2097,7 +2097,7 @@ module('Acceptance | Catalog | catalog app tests', function (hooks) { const commandService = getService('command-service'); const command = new ListingCreateCommand(commandService.commandContext); const createResult = await command.execute({ - openCardId: cardId, + openCardIds: [cardId], codeRef: { module: `${mockCatalogURL}blog-app/blog-app.gts`, name: 'BlogApp', @@ -2326,7 +2326,7 @@ module('Acceptance | Catalog | catalog app tests', function (hooks) { const command = new ListingCreateCommand(commandService.commandContext); let r = await command.execute({ - openCardId: cardId, + openCardIds: [cardId], codeRef: { module: `${mockCatalogURL}author/author.gts`, name: 'Author',