-
-
Notifications
You must be signed in to change notification settings - Fork 322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recreate Menu as a Svelte Action #196
Comments
NOTE: here's how to ensure param data stays up to date: |
Useful reference here: Direct link: |
I've submitted a draft PR showcasing my first version of this change. These make use of both Tailwind Elements (for canned class styles) as well as a dedicated Svelte Action. Usage is pretty straight forward, you create a wrapping element, add a trigger, add a menu. Then link the two together via the action, via the target and data attribute. Given it's a Tailwind Element there's plenty of style options available: Likewise I've made the auto-origin the default, but you can still set a fixed value if you wish: I'll most likely pick up and improve this tomorrow, so expect more updates then. However feel free to try the PR and submit feedback! |
In case you're wondering, the goal with the data attribute is to make the linking arbitrary. This opens the door to crazy stuff like this: <div class="hidden absolute top-4 right-4 card card-body w-64 shadow-xl" data-menu-1>(menu)</div>
<button class="btn btn-ghost" use:menu={{ target: '1', fixed: true }}>Menu 1</button> Where the menu is not required to be relative to the trigger, but rather it can appear anywhere you want on the page. |
I've worked up a REPL of some potential updates: General idea:
|
FYI I've attempted to setup test cases for this action. However, this is not operating as expected. I'd welcome feedback from anyone that can shed light on this: For now the test is present but skipped. |
Similar to Tooltips (#195) I believe Menus could benefit from making breaking out of the confines of a target/content sibling relationship.
I'll investigate the use of Svelte Actions (read: directives) to make this possible.
The text was updated successfully, but these errors were encountered: