XiongAmao / vue-easy-lightbox

A tiny lightbox component for Vue.js 3.0 :tada::tada: https://xiongamao.github.io/vue-easy-lightbox/
MIT License
409 stars 68 forks source link

Feature request - disable escaping for titles. #139

Closed chryssalid closed 9 months ago

chryssalid commented 11 months ago

It would be great to use HTML in titles.

XiongAmao commented 9 months ago

Hi, you can use HTML in v-slot:title.

<vue-easy-lightbox>
  <template #title>
    <div class="vel-img-title">Test</div>
  </template>
</vue-easy-lightbox>
chryssalid commented 7 months ago

@XiongAmao yes but does this allow me to use it for a group of images where every one has it's unique title?

XiongAmao commented 7 months ago

You can use this feature: https://vuejs.org/guide/components/slots.html#scoped-slots

Current image { src?: string, title?: string, alt?: string } passed by slotProps. These come from what you passed to prop imgs.

<template #title="{ currentImg }">
   <div class="vel-img-title">{{ currentImg?.title }}</div>
</template>

Source code:

https://github.com/XiongAmao/vue-easy-lightbox/blob/69e4f42f34f4d470f16cb58dce51c3bf612d86d4/src/vue-easy-lightbox.tsx#L668-L672