feat: show custom cookbook
This commit is contained in:
31
components/cookbook/CookbookCard.vue
Normal file
31
components/cookbook/CookbookCard.vue
Normal file
@@ -0,0 +1,31 @@
|
||||
<script lang="ts" setup>
|
||||
import type { Cookbook } from '~/types'
|
||||
|
||||
defineProps<{
|
||||
cookbook: Cookbook
|
||||
}>()
|
||||
|
||||
const showDetail = ref(false)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<button
|
||||
class="bg-$c-bg-alt"
|
||||
h-36 w-full inline-flex cursor-pointer items-center justify-center shadow
|
||||
@click="showDetail = true"
|
||||
>
|
||||
<slot />
|
||||
</button>
|
||||
|
||||
<CookbookDetail
|
||||
v-if="showDetail"
|
||||
absolute bottom-17 left-2 right-2 top-2 z-1 overflow-hidden shadow
|
||||
:cookbook="cookbook"
|
||||
>
|
||||
<YlfIconButton
|
||||
icon="i-ri-close-line"
|
||||
class="absolute right-2 top-2"
|
||||
@click="showDetail = false"
|
||||
/>
|
||||
</CookbookDetail>
|
||||
</template>
|
||||
27
components/cookbook/CookbookDetail.vue
Normal file
27
components/cookbook/CookbookDetail.vue
Normal file
@@ -0,0 +1,27 @@
|
||||
<script lang="ts" setup>
|
||||
import type { Cookbook } from '~/types'
|
||||
|
||||
const props = defineProps<{
|
||||
cookbook: Cookbook
|
||||
}>()
|
||||
|
||||
const recipes = ref<Cookbook['recipes']>(props.cookbook.recipes)
|
||||
onMounted(async () => {
|
||||
recipes.value = (await import('../../data/recipe.json')).default
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="bg-$c-bg-alt" flex="~ col">
|
||||
<h3 mt-4 font-bold>
|
||||
{{ cookbook.title }}
|
||||
</h3>
|
||||
<sub op="90" my-3>
|
||||
{{ cookbook.description }}
|
||||
</sub>
|
||||
<div mx-auto mt-2 p-0 border="1px" overflow-y="scroll">
|
||||
<RecipeTable h="full" :recipes="recipes" />
|
||||
</div>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
18
components/cookbook/NewCookbookCard.vue
Normal file
18
components/cookbook/NewCookbookCard.vue
Normal file
@@ -0,0 +1,18 @@
|
||||
<script lang="ts" setup>
|
||||
definePageMeta({
|
||||
layout: 'child',
|
||||
title: '新建食谱书',
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NuxtLink
|
||||
class="bg-$c-bg-alt"
|
||||
h-36 w-full inline-flex cursor-pointer items-center justify-center shadow
|
||||
to="/cookbooks/new"
|
||||
>
|
||||
<slot>
|
||||
<div i-ri-add-line />
|
||||
</slot>
|
||||
</NuxtLink>
|
||||
</template>
|
||||
Reference in New Issue
Block a user