Recipe Yield

This commit is contained in:
Kuchenpirat 2025-07-30 13:19:38 +00:00
commit 4c79d468d7

View file

@ -24,38 +24,31 @@
</div> </div>
</template> </template>
<script lang="ts"> <script setup lang="ts">
import DOMPurify from "dompurify"; import DOMPurify from "dompurify";
import { useScaledAmount } from "~/composables/recipes/use-scaled-amount"; import { useScaledAmount } from "~/composables/recipes/use-scaled-amount";
export default defineNuxtComponent({ interface Props {
props: { yieldQuantity?: number;
yieldQuantity: { yieldText?: string;
type: Number, scale?: number;
default: 0, color?: string;
}, }
yieldText: { const props = withDefaults(defineProps<Props>(), {
type: String, yieldQuantity: 0,
default: "", yieldText: "",
}, scale: 1,
scale: { color: "accent custom-transparent",
type: Number, });
default: 1,
}, function sanitizeHTML(rawHtml: string) {
color: {
type: String,
default: "accent custom-transparent",
},
},
setup(props) {
function sanitizeHTML(rawHtml: string) {
return DOMPurify.sanitize(rawHtml, { return DOMPurify.sanitize(rawHtml, {
USE_PROFILES: { html: true }, USE_PROFILES: { html: true },
ALLOWED_TAGS: ["strong", "sup"], ALLOWED_TAGS: ["strong", "sup"],
}); });
} }
const yieldDisplay = computed<string>(() => { const yieldDisplay = computed<string>(() => {
const components: string[] = []; const components: string[] = [];
const { scaledAmountDisplay } = useScaledAmount(props.yieldQuantity, props.scale); const { scaledAmountDisplay } = useScaledAmount(props.yieldQuantity, props.scale);
@ -69,11 +62,5 @@ export default defineNuxtComponent({
} }
return sanitizeHTML(components.join(" ")); return sanitizeHTML(components.join(" "));
});
return {
yieldDisplay,
};
},
}); });
</script> </script>