diff --git a/app/__test__/page.test.tsx b/app/__test__/page.test.tsx index 576bebd..c4b2b2d 100644 --- a/app/__test__/page.test.tsx +++ b/app/__test__/page.test.tsx @@ -37,7 +37,7 @@ describe("HomePage", () => { ).toBeVisible() }) - it("displays 6 recipe cards", () => { - expect(screen.getAllByRole("link")).toHaveLength(6) + it("displays 5 recipe cards", () => { + expect(screen.getAllByRole("link")).toHaveLength(5) }) }) diff --git a/app/helpers/__test__/getRecipesDetails.test.ts b/app/helpers/__test__/getRecipesDetails.test.ts index a5e5dc3..7348765 100644 --- a/app/helpers/__test__/getRecipesDetails.test.ts +++ b/app/helpers/__test__/getRecipesDetails.test.ts @@ -1,6 +1,6 @@ import { mockedRecipes } from "@/testUtils/mockedRecipes" -import { getRecipesDetails } from "../getRecipesDetails" +import getRecipesDetails from "../getRecipesDetails" jest.mock("../../../data/recipes.ts", () => ({ recipes: mockedRecipes, @@ -14,39 +14,33 @@ describe("getRecipesDetails", () => { { category: "bread", title: "title1", - caloriesInfo: "99 kcal/kus", + caloriesInfo: "99 kcal/piece", href: "/dummy-recipe1", }, { category: "dessert", title: "title2", - caloriesInfo: "600 kcal/piece", + caloriesInfo: "600 kcal/serving", href: "/dummy-recipe2", }, { category: "main", title: "title3", - caloriesInfo: "133 kcal/kus", + caloriesInfo: "133 kcal/piece", href: "/dummy-recipe3", }, { category: "bread", title: "title4", - caloriesInfo: "250 kcal/porce", + caloriesInfo: "700 kcal/serving", href: "/dummy-recipe4", }, { category: "dessert", title: "title5", - caloriesInfo: "85 kcal/serving", + caloriesInfo: "85 kcal/piece", href: "/dummy-recipe5", }, - { - category: "main", - title: "title6", - caloriesInfo: "700 kcal/porcia", - href: "/dummy-recipe6", - }, ]) }) }) diff --git a/app/helpers/getRecipesDetails.ts b/app/helpers/getRecipesDetails.ts index 21304f2..a577531 100644 --- a/app/helpers/getRecipesDetails.ts +++ b/app/helpers/getRecipesDetails.ts @@ -1,29 +1,18 @@ import { recipes } from "@/data/recipes" import { RecipeDetail } from "@/types" -const amountOptions = { - piece: { - czech: "kus", - english: "piece", - slovak: "kus", - }, - serving: { - czech: "porce", - english: "serving", - slovak: "porcia", - }, -} - -export const getRecipesDetails = (): RecipeDetail[] => { - return recipes.map(({ id, category, language, amount, totalKcal, title }) => { - const { count, type } = amount - const recalculatedKcal = Math.floor(totalKcal / count) +const getRecipesDetails = (): RecipeDetail[] => { + return recipes.map(({ id, category, yields, totalKcal, title }) => { + const { amount, type } = yields + const recalculatedKcal = Math.floor(totalKcal / amount) return { category: category, title: title, - caloriesInfo: `${recalculatedKcal} kcal/${amountOptions[type][language]}`, + caloriesInfo: `${recalculatedKcal} kcal/${type}`, href: `/${id}`, } }) } + +export default getRecipesDetails diff --git a/app/page.tsx b/app/page.tsx index ccdcb79..aa7a362 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -2,7 +2,7 @@ import React from "react" import RecipeDetailCard from "@/app/components/RecipeDetailCard" -import { getRecipesDetails } from "./helpers/getRecipesDetails" +import getRecipesDetails from "./helpers/getRecipesDetails" const Home = () => { const recipesDetails = getRecipesDetails() diff --git a/data/recipes.ts b/data/recipes.ts index c0065b6..d124783 100644 --- a/data/recipes.ts +++ b/data/recipes.ts @@ -2,9 +2,8 @@ import { Recipe } from "@/types" export const recipes: Recipe[] = [ { - id: "kefirova-buchta", + id: "kefir-cake", category: "dessert", - language: "czech", time: 50, totalKcal: 2589, nutrients: { @@ -12,48 +11,47 @@ export const recipes: Recipe[] = [ carbohydrates: 316.8, fat: 115.9, }, - amount: { count: 8, type: "piece" }, - title: "Kefírová buchta", + yields: { amount: 8, type: "piece" }, + title: "Kefir cake", ingredients: [ - { amount: "2", ingredient: "vejce", unitType: "count", unit: "piece" }, - { amount: "120", ingredient: "cukr", unitType: "weight", unit: "grams" }, - { amount: "100", ingredient: "řepkový olej", unitType: "weight", unit: "grams" }, - { amount: "380", ingredient: "kefír", unitType: "weight", unit: "grams" }, - { amount: "135", ingredient: "hrubá mouka", unitType: "weight", unit: "grams" }, + { amount: "2", ingredient: "eggs", unitType: "count", unit: "piece" }, + { amount: "120", ingredient: "sugar", unitType: "weight", unit: "grams" }, + { amount: "100", ingredient: "rapeseed oil", unitType: "weight", unit: "grams" }, + { amount: "380", ingredient: "kefir", unitType: "weight", unit: "grams" }, + { amount: "135", ingredient: "coarse flour", unitType: "weight", unit: "grams" }, { amount: "130", - ingredient: "celozrnná hladká ječná mouka", + ingredient: "whole-wheat flour", unitType: "weight", unit: "grams", }, - { amount: "2", ingredient: "kakao", unitType: "volume", unit: "tablespoon" }, - { amount: "1", ingredient: "jedlá soda", unitType: "volume", unit: "teaspoon" }, - { amount: "1", ingredient: "sůl", unitType: "count", unit: "pinch" }, + { amount: "2", ingredient: "cocoa", unitType: "volume", unit: "tablespoon" }, + { amount: "1", ingredient: "baking soda", unitType: "volume", unit: "teaspoon" }, + { amount: "1", ingredient: "salt", unitType: "count", unit: "pinch" }, ], extraIngredients: [ - "moučkový cukr na posypání", - "máslo na vymazání formy, strouhanka nebo hrubá mouka na vysypání", + "powdered sugar for sprinkling", + "butter for greasing the form, breadcrumbs or coarse flour for dusting", ], instructions: [ - "Troubu rozehřejte na 200 °C, kulatou formu vymažte máslem a vysypte hrubou moukou nebo strouhankou.", - "Vejce dobře prošlehejte s cukrem (můžete šlehat ručně kuchyňskou metlou), přilijte olej nebo máslo a nakonec i kefír. Důkladně prošlehejte, aby se všechny suroviny dobře spojily. Aby byl výsledek perfektní, pro jistotu si všechny studené suroviny vyndejte z lednice 30 minut předem.", - "V jiné misce si smíchejte obě mouky, kakao, jedlou sodu a špetku soli. Sypké suroviny můžete prosít, budou vzdušnější.Pokud jste na prosívání líní, alespoň je dobře promíchejte suchou metlou. Ta vás alespoň částečně zbaví hrudek a mouku provzdušní.", - "Nyní vešlehejte „suché“ ingredience po částech do těch „mokrých“. Míchejte jen tak dlouho, aby se spojily v hladké těsto.Pracujete se sodou, proto neztrácejte čas a nevymíchávejte těsto příliš dlouho, připravíte se tak o bublinky.", - "Těsto nalijte do připravené koláčové formy, vložte do předehřáté trouby a teplotu pečení snižte na 180 °C. Pečte přibližně 30-35 minut, ke konci pečení zkontrolujte dřevěnou špejlí nebo párátkem. Vyjde-li z těsta čisté a bez drobečků, máte hotovo.", + "Preheat the oven to 200 °C, grease a round form with butter and dust with coarse flour or breadcrumbs.", + "Beat the eggs well with the sugar (you can beat by hand with a kitchen whisk), add the oil or butter and finally the kefir. Whisk thoroughly to combine all the ingredients well. To ensure the best result, take all the cold ingredients out of the fridge 30 minutes beforehand.", + "In another bowl, mix both flours, cocoa, baking soda, and a pinch of salt. You can sift the dry ingredients to make them more airy. If you are too lazy to sift, at least mix them well with a dry whisk. This will help eliminate lumps and aerate the flour.", + "Now whisk the 'dry' ingredients into the 'wet' ones in parts. Mix just until they combine into a smooth batter. Since you are working with baking soda, don't waste time and don't overmix the batter to preserve the bubbles.", + "Pour the batter into the prepared cake form, place it in the preheated oven, and reduce the baking temperature to 180 °C. Bake for approximately 30-35 minutes, and towards the end of baking, check with a wooden skewer or toothpick. If it comes out clean and without crumbs, the cake is done.", ], credit: "https://karolinafour.cz/recepty/rychla-kefirova-buchta/", }, { id: "pancakes-batter", category: "dessert", - language: "english", totalKcal: 1675, nutrients: { protein: 59.8, carbohydrates: 199.5, fat: 69, }, - amount: { count: 9, type: "piece" }, + yields: { amount: 9, type: "piece" }, title: "Pancakes batter", ingredients: [ { amount: "3", ingredient: "eggs", unitType: "count", unit: "piece" }, @@ -73,31 +71,30 @@ export const recipes: Recipe[] = [ }, { - id: "housky", + id: "buns", category: "bread", - language: "czech", totalKcal: 1864, nutrients: { protein: 47.9, carbohydrates: 302.6, fat: 46.7, }, - amount: { count: 8, type: "piece" }, - title: "Housky", + yields: { amount: 8, type: "piece" }, + title: "Buns", ingredients: [ - { amount: "400", ingredient: "hladká mouka", unitType: "weight", unit: "grams" }, - { amount: "200", ingredient: "voda", unitType: "weight", unit: "grams" }, - { amount: "50", ingredient: "řepkový olej/máslo", unitType: "weight", unit: "grams" }, - { amount: "1", ingredient: "cukr", unitType: "volume", unit: "teaspoon" }, - { amount: "1", ingredient: "sůl", unitType: "volume", unit: "teaspoon" }, - { amount: "25", ingredient: "droždí", unitType: "weight", unit: "grams" }, + { amount: "400", ingredient: "all-purpose flour", unitType: "weight", unit: "grams" }, + { amount: "200", ingredient: "water", unitType: "weight", unit: "grams" }, + { amount: "50", ingredient: "rapeseed oil", unitType: "weight", unit: "grams" }, + { amount: "1", ingredient: "sugar", unitType: "volume", unit: "teaspoon" }, + { amount: "1", ingredient: "salt", unitType: "volume", unit: "teaspoon" }, + { amount: "25", ingredient: "yeast", unitType: "weight", unit: "grams" }, ], instructions: [ - "Vše dáme do mixéru s hákem a vypracujeme těsto.", - "Přendáme na vál, lehce pomoučníme.", - "Rozdělíme na 8 dílů a z každého vytvarujeme housky.", - "Troubu předehřejeme na 230 stupňů a než se trouba předehřeje jsou pletýnky nakynuté", - "Pečeme cca 12 minut dozlatova", + "Put everything into a mixer with a hook and work the dough.", + "Transfer to a work surface, lightly flour.", + "Divide into 8 parts and shape each into rolls.", + "Preheat the oven to 230 degrees and while the oven is preheating, the rolls will rise.", + "Bake for about 12 minutes until golden brown.", ], }, ] diff --git a/tailwind.config.ts b/tailwind.config.ts index 429c41a..cf95dcd 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -1,4 +1,5 @@ import type { Config } from "tailwindcss" +import plugin from "tailwindcss/plugin" const config: Config = { content: [ @@ -21,6 +22,7 @@ const config: Config = { dark: "#4A5759", medium: "#B0C4B1", light: "#DEDBD2", + lightest: "#EBEAE4", }, red: { primary: "#d8003e", @@ -31,8 +33,16 @@ const config: Config = { primary: "#ffd634", }, }, + backgroundImage: { + defaultGreen: + "linear-gradient(to right bottom, #dedbd2, #d5d5c8, #cacfbf, #bec9b7, #b0c4b1)", + }, }, }, - plugins: [], + plugins: [ + plugin(function ({ addVariant }) { + addVariant("hocus", ["&:hover", "&:focus"]) + }), + ], } export default config diff --git a/testUtils/mockedRecipes.ts b/testUtils/mockedRecipes.ts index 6cb7bbc..d67f988 100644 --- a/testUtils/mockedRecipes.ts +++ b/testUtils/mockedRecipes.ts @@ -1,55 +1,39 @@ import { Recipe } from "@/types" -export const mockedRecipes: Pick< - Recipe, - "id" | "category" | "language" | "amount" | "totalKcal" | "title" ->[] = [ +export const mockedRecipes: Pick[] = [ { id: "dummy-recipe1", category: "bread", - language: "czech", - amount: { count: 2, type: "piece" }, + yields: { amount: 2, type: "piece" }, totalKcal: 199, title: "title1", }, { id: "dummy-recipe2", category: "dessert", - language: "english", - amount: { count: 3, type: "piece" }, + yields: { amount: 3, type: "serving" }, totalKcal: 1800, title: "title2", }, { id: "dummy-recipe3", category: "main", - language: "slovak", - amount: { count: 3, type: "piece" }, + yields: { amount: 3, type: "piece" }, totalKcal: 400, title: "title3", }, { id: "dummy-recipe4", category: "bread", - language: "czech", - amount: { count: 2, type: "serving" }, - totalKcal: 500, + yields: { amount: 1, type: "serving" }, + totalKcal: 700, title: "title4", }, { id: "dummy-recipe5", category: "dessert", - language: "english", - amount: { count: 7, type: "serving" }, + yields: { amount: 7, type: "piece" }, totalKcal: 600, title: "title5", }, - { - id: "dummy-recipe6", - category: "main", - language: "slovak", - amount: { count: 1, type: "serving" }, - totalKcal: 700, - title: "title6", - }, ] diff --git a/tsconfig.json b/tsconfig.json index e7ff90f..f64fdbf 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,6 +4,7 @@ "allowJs": true, "skipLibCheck": true, "strict": true, + "noImplicitAny": true, "noEmit": true, "esModuleInterop": true, "module": "esnext", diff --git a/types/index.ts b/types/index.ts index 8576187..32c1695 100644 --- a/types/index.ts +++ b/types/index.ts @@ -1,34 +1,40 @@ export type Category = "bread" | "dessert" | "main" -export type Language = "czech" | "english" | "slovak" - type Nutrients = { protein: number carbohydrates: number fat: number } -export type Amount = { - count: number +export type Yields = { + amount: number type: "serving" | "piece" } +export type UnitType = "count" | "volume" | "weight" + +export type CountUnit = "piece" | "pinch" + type CountUnitType = { unitType: "count" - unit: "piece" | "pinch" + unit: CountUnit } +export type VolumeUnit = "teaspoon" | "tablespoon" | "millilitre" | "litre" + type VolumeUnitType = { unitType: "volume" - unit: "teaspoon" | "tablespoon" | "millilitre" | "litre" + unit: VolumeUnit } +export type WeightUnit = "grams" | "kilograms" + type WeightUnitType = { unitType: "weight" - unit: "grams" | "kilograms" + unit: WeightUnit } -type Ingredient = { +export type Ingredient = { amount: string ingredient: string } & (CountUnitType | VolumeUnitType | WeightUnitType) @@ -36,11 +42,10 @@ type Ingredient = { export type Recipe = { id: string category: Category - language: Language time?: number totalKcal: number nutrients: Nutrients - amount: Amount + yields: Yields title: string ingredients: Ingredient[] extraIngredients?: string[]