Skip to content

Commit

Permalink
[WIP]
Browse files Browse the repository at this point in the history
  • Loading branch information
cmvanb committed Sep 30, 2024
1 parent a2692ee commit 0b6b881
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 19 deletions.
8 changes: 4 additions & 4 deletions frontend/src/components/DrawerMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ function DrawerMenu(props) {
</button>
</nav>
</header>
<a href="/mealplanner">
<a href="/mealplanner" onClick={closeMenu}>
<i>calendar_month</i>
<span>Meal Planner</span>
</a>
<a href="/recipes">
<a href="/recipes" onClick={closeMenu}>
<i>menu_book</i>
<span>Recipes</span>
</a>
<hr class="medium" />
<a href="/settings">
<a href="/settings" onClick={closeMenu}>
<i>settings</i>
<span>Settings</span>
</a>
<a>
<a onClick={closeMenu}>
<i>logout</i>
<span>Log out</span>
</a>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
function MealPlanner() {
return (
<article>
<h4>MEAL PLANNER</h4>
<section class="header center-align">
<h4>Meal Planner</h4>
</section>
</article>
);
}
Expand Down
File renamed without changes.
10 changes: 9 additions & 1 deletion frontend/src/pages/Recipe/Recipe.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
#recipe-controls {
#recipe-close-button {
position: absolute;
top: 0;
right: 0;
z-index: 10;
margin: 0;
}

#recipe-controls {
display: flex;
justify-content: center;
align-items: center;
margin: auto;
}

#recipe-image {
Expand Down
31 changes: 26 additions & 5 deletions frontend/src/pages/Recipe/index.jsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import './Recipe.css';
import { useParams } from '@solidjs/router';

import { useRecipeContext } from '../../contexts/RecipeContext';

import './Recipe.css';

function Recipe() {
const { recipeStore } = useRecipeContext();
const recipe = recipeStore.recipes[0];
const params = useParams();
const recipe = recipeStore.recipes[params.id];

return (
<article class="medium-elevate no-padding">
<nav id="recipe-controls">
<h6 class="max"></h6>
<img class="responsive" id="recipe-image" src="https://www.teaforturmeric.com/wp-content/uploads/2018/06/Chicken-Korma-in-pan.jpg" />
<nav id="recipe-close-button">
<button class="transparent circle extra" onClick={() => location.href='/recipes'}>
<i>close</i>
</button>
</nav>
<img class="responsive" id="recipe-image" src="https://www.teaforturmeric.com/wp-content/uploads/2018/06/Chicken-Korma-in-pan.jpg" />
<div class="padding">
<section class="header center-align">
<h4>{recipe.title}</h4>
Expand All @@ -38,6 +40,25 @@ function Recipe() {
<section class="content center-align">
<p>{recipe.description}</p>
</section>
<section id="recipe-controls" class="content">
<nav class="no-space">
<button class="border fill left-round" onClick={() => console.warn('edit')}>
<i>edit</i>
<span>Edit</span>
</button>
<button class="border fill no-round" onClick={() => console.warn('delete')}>
<i>delete</i>
<span>Delete</span>
</button>
<button class="border fill right-round" onClick={() => console.warn('export')}>
<i>download</i>
<span>Export</span>
</button>
</nav>
</section>
<div>
<hr class="large" />
</div>
<section id="recipe-columns" class="content grid">
<div class="s12 m6 recipe-col">
<h6>Ingredients</h6>
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/pages/Recipes/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ function Recipes() {
</menu>
</div>
<div class="grid">
<For each={recipes}>
{(recipe) => (
<For each={Object.keys(recipes)}>
{(recipeId) => (
<article class="recipe-card medium-elevate no-padding s12 m6 l4">
<a href={`/recipes/${recipe.id}`}>
<a href={`/recipes/${recipeId}`}>
<img class="responsive small" src="https://www.teaforturmeric.com/wp-content/uploads/2018/06/Chicken-Korma-in-pan.jpg" />
<div class="padding">
<h6>{recipe.title}</h6>
<p>{recipe.description}</p>
<h6>{recipes[recipeId].title}</h6>
<p>{recipes[recipeId].description}</p>
</div>
</a>
</article>
Expand Down
File renamed without changes.
File renamed without changes.
14 changes: 11 additions & 3 deletions frontend/src/stores/recipeStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@ import { createStore } from 'solid-js/store';

import { chicken_korma } from './mockData';

const [ recipeStore, setRecipeStore ] = createStore({
recipes: [...Array(12).keys()].map((id) => ({ ...chicken_korma, id: id + 1 }) ),
});
const initialState = {
// That's a lot of korma!
recipes: [...Array(12).keys()]
.map((index) => ({ ...chicken_korma, id: index + 1 }))
.reduce((acc, e) => ({
...acc,
[e['id']]: e,
}), {}),
};

const [ recipeStore, setRecipeStore ] = createStore(initialState);

export { recipeStore, setRecipeStore };

0 comments on commit 0b6b881

Please sign in to comment.