feat: AcfMedia component (image + aspect + object-fit)
This commit is contained in:
@@ -248,5 +248,5 @@
|
|||||||
"graphql_types": "",
|
"graphql_types": "",
|
||||||
"acfe_meta": "",
|
"acfe_meta": "",
|
||||||
"acfe_note": "",
|
"acfe_note": "",
|
||||||
"modified": 1769779217
|
"modified": 1769779666
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
fragment AcfMedia on GroupAbstractMedia_Fields {
|
||||||
|
image {
|
||||||
|
node {
|
||||||
|
...AcfImage
|
||||||
|
}
|
||||||
|
}
|
||||||
|
aspectRatio
|
||||||
|
objectFit
|
||||||
|
}
|
||||||
36
wp-content/themes/moonshine/app/components/acf/AcfMedia.vue
Normal file
36
wp-content/themes/moonshine/app/components/acf/AcfMedia.vue
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { tv, type VariantProps } from "tailwind-variants";
|
||||||
|
import type { AcfMediaFragment } from "#graphql/operations";
|
||||||
|
|
||||||
|
const tvAcfMedia = tv({
|
||||||
|
slots: {
|
||||||
|
image: "w-full",
|
||||||
|
},
|
||||||
|
variants: {
|
||||||
|
aspectRatio: {
|
||||||
|
square: { image: "aspect-[1/1]" },
|
||||||
|
video: { image: "aspect-video" },
|
||||||
|
portrait: { image: "aspect-[2/3]" },
|
||||||
|
auto: { image: "aspect-auto" },
|
||||||
|
},
|
||||||
|
objectFit: {
|
||||||
|
cover: { image: "object-cover" },
|
||||||
|
contain: { image: "object-contain" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
defaultVariants: {
|
||||||
|
aspectRatio: "auto",
|
||||||
|
objectFit: "cover",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const props = defineProps<{ media?: AcfMediaFragment }>();
|
||||||
|
const classes = tvAcfMedia({
|
||||||
|
aspectRatio: props.media?.aspectRatio,
|
||||||
|
objectFit: props.media?.objectFit,
|
||||||
|
} as VariantProps<typeof tvAcfMedia>);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<AcfImage v-if="media?.image?.node" :image="media.image.node" :class="classes.image()" />
|
||||||
|
</template>
|
||||||
Reference in New Issue
Block a user