import * as React from 'react' import { default as NextLink } from 'next/link' import { Box, Flex, Card, Heading, Text, Link } from 'theme-ui' import { CardProps } from '@theme-ui/components' import { Clock } from 'phosphor-react' import unwidow from '../utils/unwidow' import minutesToHours from '../utils/minutesToHours' import { Recipe } from '../types/api' import { HStack } from './Stack' interface RecipePreviewProps extends CardProps { recipe: Recipe level?: 'h2' | 'h3' | 'h4' | 'h5' | 'h5' } const RecipePreview: React.FC = ({ recipe, level = 'h3', sx, ...props }) => { const { title, slug, category, tags = [], prepTime = 0, cookTime = 0, } = recipe const totalTime = prepTime + cookTime return ( {category.emoji} {unwidow(title)} 0 ? 4 : 0, }} > 0 ? 4 : 0, }} > {category.title} {tags.length > 0 && ( {tags.map((tag) => ( {tag.title} ))} )} {totalTime > 0 && ( 0 ? 2 : null, fontSize: 0, color: 'muted-text', svg: { marginRight: 2, fontSize: 1, }, }} > {minutesToHours(totalTime)} )} ) } export default RecipePreview