mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 06:23:34 -07:00
Recipe Header Image
This commit is contained in:
parent
9b7d961db2
commit
7980c8e054
1 changed files with 36 additions and 49 deletions
|
@ -12,60 +12,47 @@
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script setup lang="ts">
|
||||||
import { useStaticRoutes, useUserApi } from "~/composables/api";
|
import { useStaticRoutes, useUserApi } from "~/composables/api";
|
||||||
import type { HouseholdSummary } from "~/lib/api/types/household";
|
import type { HouseholdSummary } from "~/lib/api/types/household";
|
||||||
import { usePageState, usePageUser } from "~/composables/recipe-page/shared-state";
|
import { usePageState, usePageUser } from "~/composables/recipe-page/shared-state";
|
||||||
import type { Recipe } from "~/lib/api/types/recipe";
|
import type { Recipe } from "~/lib/api/types/recipe";
|
||||||
import type { NoUndefinedField } from "~/lib/api/types/non-generated";
|
import type { NoUndefinedField } from "~/lib/api/types/non-generated";
|
||||||
|
|
||||||
export default defineNuxtComponent({
|
interface Props {
|
||||||
props: {
|
recipe: NoUndefinedField<Recipe>;
|
||||||
recipe: {
|
maxWidth?: string;
|
||||||
type: Object as () => NoUndefinedField<Recipe>,
|
}
|
||||||
required: true,
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
},
|
maxWidth: undefined,
|
||||||
maxWidth: {
|
|
||||||
type: String,
|
|
||||||
default: undefined,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
setup(props) {
|
|
||||||
const { $vuetify } = useNuxtApp();
|
|
||||||
const { recipeImage } = useStaticRoutes();
|
|
||||||
const { imageKey } = usePageState(props.recipe.slug);
|
|
||||||
const { user } = usePageUser();
|
|
||||||
|
|
||||||
const recipeHousehold = ref<HouseholdSummary>();
|
|
||||||
if (user) {
|
|
||||||
const userApi = useUserApi();
|
|
||||||
userApi.households.getOne(props.recipe.householdId).then(({ data }) => {
|
|
||||||
recipeHousehold.value = data || undefined;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const hideImage = ref(false);
|
|
||||||
const imageHeight = computed(() => {
|
|
||||||
return $vuetify.display.xs.value ? "200" : "400";
|
|
||||||
});
|
|
||||||
|
|
||||||
const recipeImageUrl = computed(() => {
|
|
||||||
return recipeImage(props.recipe.id, props.recipe.image, imageKey.value);
|
|
||||||
});
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => recipeImageUrl.value,
|
|
||||||
() => {
|
|
||||||
hideImage.value = false;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
|
||||||
recipeImageUrl,
|
|
||||||
imageKey,
|
|
||||||
hideImage,
|
|
||||||
imageHeight,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { $vuetify } = useNuxtApp();
|
||||||
|
const { recipeImage } = useStaticRoutes();
|
||||||
|
const { imageKey } = usePageState(props.recipe.slug);
|
||||||
|
const { user } = usePageUser();
|
||||||
|
|
||||||
|
const recipeHousehold = ref<HouseholdSummary>();
|
||||||
|
if (user) {
|
||||||
|
const userApi = useUserApi();
|
||||||
|
userApi.households.getOne(props.recipe.householdId).then(({ data }) => {
|
||||||
|
recipeHousehold.value = data || undefined;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const hideImage = ref(false);
|
||||||
|
const imageHeight = computed(() => {
|
||||||
|
return $vuetify.display.xs.value ? "200" : "400";
|
||||||
|
});
|
||||||
|
|
||||||
|
const recipeImageUrl = computed(() => {
|
||||||
|
return recipeImage(props.recipe.id, props.recipe.image, imageKey.value);
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => recipeImageUrl.value,
|
||||||
|
() => {
|
||||||
|
hideImage.value = false;
|
||||||
|
},
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue