|
@@ -1,45 +1,69 @@
|
|
|
import React, { Component } from 'react';
|
|
import React, { Component } from 'react';
|
|
|
|
|
+import IRecipe from '../../types/recipes';
|
|
|
|
|
+import Card, {
|
|
|
|
|
+ CardActions,
|
|
|
|
|
+ CardActionButtons,
|
|
|
|
|
+ CardPrimaryContent,
|
|
|
|
|
+ CardMedia,
|
|
|
|
|
+} from "@material/react-card";
|
|
|
|
|
+import Icon from 'components/Icon';
|
|
|
|
|
+import moment from 'moment';
|
|
|
|
|
|
|
|
-import './styles.scss';
|
|
|
|
|
-
|
|
|
|
|
-type Ingredient = {
|
|
|
|
|
- name: string,
|
|
|
|
|
- ingredients: {
|
|
|
|
|
- name: string,
|
|
|
|
|
- quantity: number,
|
|
|
|
|
- unit: string,
|
|
|
|
|
- _original: string,
|
|
|
|
|
- }[],
|
|
|
|
|
-}
|
|
|
|
|
|
|
+import sample_img from "components/Card/sample.png";
|
|
|
|
|
+import { ReactComponent as Preparation } from 'svgs/preparation.svg';
|
|
|
|
|
+import { ReactComponent as Cooking } from 'svgs/cooking.svg';
|
|
|
|
|
+import { ReactComponent as Servings } from 'svgs/servings.svg';
|
|
|
|
|
|
|
|
-export type Recipe = {
|
|
|
|
|
- _id: string,
|
|
|
|
|
- name: string,
|
|
|
|
|
- author: {
|
|
|
|
|
- name: string,
|
|
|
|
|
- },
|
|
|
|
|
- details: {
|
|
|
|
|
- preparationTime: string,
|
|
|
|
|
- cookingTime: string,
|
|
|
|
|
- servings: number,
|
|
|
|
|
- },
|
|
|
|
|
- ingredients: Ingredient[],
|
|
|
|
|
- instructions: string[],
|
|
|
|
|
- summary: string,
|
|
|
|
|
- tags: string[],
|
|
|
|
|
-}
|
|
|
|
|
|
|
+import './styles.scss';
|
|
|
|
|
|
|
|
type RecipeCardProps = {
|
|
type RecipeCardProps = {
|
|
|
- recipe: Recipe,
|
|
|
|
|
- actions?: boolean,
|
|
|
|
|
|
|
+ recipe: IRecipe,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-export class RecipeCard extends Component<RecipeCardProps, {}> {
|
|
|
|
|
- render() {
|
|
|
|
|
- return (
|
|
|
|
|
- <h2>recipeCard</h2>
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
|
|
+function CBKRecipeCard(props: RecipeCardProps) {
|
|
|
|
|
+ const { recipe } = props;
|
|
|
|
|
+ const prepTime = moment.duration(recipe.details.preparationTime).humanize();
|
|
|
|
|
+ const cookTime = moment.duration(recipe.details.cookingTime).humanize();
|
|
|
|
|
+ const servings = recipe.details.servings;
|
|
|
|
|
+
|
|
|
|
|
+ return (
|
|
|
|
|
+ <Card outlined className='cbk-recipe-card'>
|
|
|
|
|
+ <div className='cbk-recipe-card__primary'>
|
|
|
|
|
+ <CardMedia square imageUrl={sample_img} className='cbk-recipe-card__primary__image'/>
|
|
|
|
|
+ <div className='cbk-recipe-card__primary__title'>
|
|
|
|
|
+ <h6>{recipe.name}</h6>
|
|
|
|
|
+ <p>{recipe.summary}</p>
|
|
|
|
|
+ <ul>
|
|
|
|
|
+ <li>
|
|
|
|
|
+ <Icon width={32} height={32}><Preparation/></Icon>
|
|
|
|
|
+ <label>{prepTime}</label>
|
|
|
|
|
+ </li>
|
|
|
|
|
+ <li>
|
|
|
|
|
+ <Icon width={32} height={32}><Cooking/></Icon>
|
|
|
|
|
+ <label>{cookTime}</label>
|
|
|
|
|
+ </li>
|
|
|
|
|
+ <li>
|
|
|
|
|
+ <Icon width={32} height={32}><Servings/></Icon>
|
|
|
|
|
+ <label>{servings}</label>
|
|
|
|
|
+ </li>
|
|
|
|
|
+ </ul>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div className='cbk-recipe-card__content'>
|
|
|
|
|
+ <div className='cbk-recipe-card__content__ingredients'>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div className='cbk-recipe-card__content__instructions'>
|
|
|
|
|
+ <ol>
|
|
|
|
|
+ {
|
|
|
|
|
+ recipe.instructions.map((instruction, i) => (
|
|
|
|
|
+ <li key={i}>{instruction}</li>
|
|
|
|
|
+ ))
|
|
|
|
|
+ }
|
|
|
|
|
+ </ol>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </Card>
|
|
|
|
|
+ )
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-export default RecipeCard;
|
|
|
|
|
|
|
+export default CBKRecipeCard;
|