diff --git a/src/App.tsx b/src/App.tsx
index e96d0fb..2f4c83a 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,5 +1,5 @@
import { FileLoader } from "./components/FileLoader/FileLoader";
-import { RecipeViewer } from "./components/RecipeViewer/RecipeViewer";
+import { RecipeViewerWrapper } from "./components/RecipeViewerWrapper/RecipeViewerWrapper";
// import { TargetScaleSetter } from "./components/TargetScaleSetter/TargetScaleSetter";
import { ScalerWrapper } from "./context/ScalerContext";
import "@mantine/core/styles.css";
@@ -13,8 +13,8 @@ const App = () => {
Bakers Mode
-
-
+
+
diff --git a/src/components/RecipeViewer/RecipeViewer.tsx b/src/components/RecipeViewer/RecipeViewer.tsx
index f646bdf..2b37084 100644
--- a/src/components/RecipeViewer/RecipeViewer.tsx
+++ b/src/components/RecipeViewer/RecipeViewer.tsx
@@ -4,38 +4,45 @@ import { RecipeStepDisplay } from "../RecipeStepDisplay/RecipeStepDisplay";
import { TargetScaleSetter } from "../TargetScaleSetter/TargetScaleSetter";
export const RecipeViewer = () => {
- const { scaledRecipe, ingredientList } = useContext(
+ const { scaledRecipe, ingredientList, isRecipeLoaded } = useContext(
ScalerContext
) as ScalerContextType;
const stepCount = scaledRecipe.steps.length;
- return (
-
- {scaledRecipe.title}
- {scaledRecipe.description}
-
- Steps
+ if (isRecipeLoaded) {
+ return (
+
+ {scaledRecipe.title}
+ {scaledRecipe.description}
+
+ Steps
-
- {scaledRecipe.steps.map((step, index) => {
- return (
- -
-
-
- );
- })}
-
- Cooking Notes
-
- {scaledRecipe.cookingNotes.map((item) => {
- return - {item}
;
- })}
-
-
- );
+
+ {scaledRecipe.steps.map((step, index) => {
+ return (
+ -
+
+
+ );
+ })}
+
+ Cooking Notes
+
+ {scaledRecipe.cookingNotes.map((item) => {
+ return - {item}
;
+ })}
+
+
+ );
+ } else {
+ return ;
+ }
};
diff --git a/src/components/RecipeViewerWrapper/RecipeViewerWrapper.tsx b/src/components/RecipeViewerWrapper/RecipeViewerWrapper.tsx
new file mode 100644
index 0000000..a4a4265
--- /dev/null
+++ b/src/components/RecipeViewerWrapper/RecipeViewerWrapper.tsx
@@ -0,0 +1,8 @@
+import { useContext } from "react";
+import { ScalerContext, ScalerContextType } from "../../context/ScalerContext";
+import { RecipeViewer } from "../RecipeViewer/RecipeViewer";
+// RecipeViewerWrapper: a component that displays the recipe viewer if a recipe is loaded. If not it displays placeholder element
+export const RecipeViewerWrapper = () => {
+ const { isRecipeLoaded } = useContext(ScalerContext) as ScalerContextType;
+ return isRecipeLoaded ? : Recipe not loaded?
;
+};
diff --git a/src/index.tsx b/src/index.tsx
index e6a0350..e91ad13 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -10,7 +10,6 @@ const root = ReactDOM.createRoot(
root.render(
- {" "}