@heyframe/composables
Version:
HeyFrame Frontends composables for Vue
26 lines (21 loc) • 704 B
text/typescript
import { inject } from "vue";
import { computed } from "vue";
import type { ComputedRef } from "vue";
import type { Schemas } from "#heyframe";
import { useCmsElementConfig } from "../index";
import type { BoxLayout, CmsElementProductBox } from "../types";
export type UseCmsElementProductBox = {
product: Schemas["Product"];
boxLayout: ComputedRef<BoxLayout>;
};
export function useCmsElementProductBox(
element: CmsElementProductBox,
): UseCmsElementProductBox {
const product = inject("product", element.data.product);
const { getConfigValue } = useCmsElementConfig(element);
const boxLayout = computed(() => getConfigValue("boxLayout"));
return {
product,
boxLayout,
};
}