portal-vue icon indicating copy to clipboard operation
portal-vue copied to clipboard

allow to wrap portal-target content

Open FranckFreiburger opened this issue 6 years ago • 6 comments

I wondering if it is possible to wrap portal-target content ?

example:

<portal to="destination">
My content
</portal>

<div>
  <portal-target name="destination">
    <h1><slot name="default"></slot></h1>
  </portal-target>
</div>

result: if portal source is defined: <div><h1>My content</h1></div>

if portal source is not defined: <div></div>

FranckFreiburger avatar Jun 15 '18 11:06 FranckFreiburger

Interesting idea! I don't have an immediate idea how to make it work, but we can think about it :)

LinusBorg avatar Jun 15 '18 15:06 LinusBorg

I currently don't see an elegant way to make this possible, and don't want to add too much complexity to this lib any more - it has enogub options as it is, pretty much

LinusBorg avatar Oct 11 '18 06:10 LinusBorg

I was just wondering if recent portal-view changes could make this feature easier to implement ?

FranckFreiburger avatar May 28 '19 11:05 FranckFreiburger

I might have an idea, involving a scoped slot and some trickery with a dynamic component passed as the slot prop ... Not elegant but maybe makes it work.

<div>
  <portal-target name="destination">
    <template v-slot:wrapper="{ content }">
      <h1><span :is="content"></span></h1>
    <template>
  </portal-target>
</div>

Just a spontaneous idea, I'll try it out and report back. Ping me once in a while to keep it from fading into the background again.

LinusBorg avatar May 28 '19 11:05 LinusBorg

Interesting idea! thanks.

FranckFreiburger avatar May 28 '19 11:05 FranckFreiburger

i would realy love to use this feature in order to have a seperator between multiple contents explained: you have a <portal-target multiple> tag, and between each element, i would like to have a line or some kind of separator.

mithom avatar Jun 13 '19 09:06 mithom