new x-portal directive for alpinejs #3574
nabeghe
started this conversation in
3. Feature Ideas
Replies: 2 comments 2 replies
-
|
It's likely what you're describing can and should be done with css only, or just have multiple instances would be fine as well. |
Beta Was this translation helpful? Give feedback.
2 replies
-
|
I've just unleashed my custom x-portal directive available to everyone: alpine-portal |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, there is a directive called x-teleport in AlpineJS that helps to move an element from one part of the page to another. However, I need a feature (directive) that allows me to specify that if the screen size is greater or less than a certain value, the element must be moved to another location, and when the condition is not met, it must return to its original position. I don't know if AlpineJS has this capability or not, and I think the name
x-portalwould be better suited for this directive, as it is similar to a portal that moves from one world (screen) to another and also moves the portal when we switch between worlds (screens). 😂My design with TailwindCSS was mobile-first, and I wanted to move some elements to the sidebar on desktop on xl screen, and then return them to their original position if the screen size became smaller again. I implemented this feature temporarily with a custom directive in my project, but if it is added to the AlpineJS core, it would be a useful feature alongside teleport.
This feature can be implemented by receiving an object with three keys: target, screen, and is, as follows:
<div x-portal="{target: '#id', screen='lg', is=false}" ></div>The screen key can receive a name or a number. These names can be default values in TailwindCSS or can be user-configured. Also, the 'is' specifies whether the size is greater or less than the given screen value, or it can be specified using greater-than and less-than signs on the screen value.
Of course, this was just my suggestion, and it may be possible to specify it with
x-portal:target,x-portal:screen, and so on, or even add it tox-teleportitself.Thank you for your efforts, dears.
Beta Was this translation helpful? Give feedback.
All reactions