Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Recreate Tooltip as a Svelte Action #195

Closed
endigo9740 opened this issue Sep 7, 2022 · 6 comments · Fixed by #311
Closed

Recreate Tooltip as a Svelte Action #195

endigo9740 opened this issue Sep 7, 2022 · 6 comments · Fixed by #311
Assignees
Labels
enhancement New feature or request ready to test Ready to be tested for quality assurance.

Comments

@endigo9740
Copy link
Contributor

endigo9740 commented Sep 7, 2022

Currently the process of wrapping and using slots is a bit limiting. It means the target and tooltip have to live together. Like so:

Screen Shot 2022-09-07 at 1 31 20 PM

However, it may be beneficial to make the break this apart and make the association more abstract and loose. The use case would be able to hover elements on one side of the page, but the tooltip appear elsewhere on the page. Here's an example diagram:

Screen Shot 2022-09-07 at 1 33 18 PM

Svelte Actions (aka Directives) are great a DOM-focused manipulation like this. Though I still think it should be paired with a component for more robust designs within the contents of the popup. By using this we could perhaps provide a cleaner syntax for implementing tooltips.

I'll lead the charge on testing this before we proceed.

@endigo9740 endigo9740 added the enhancement New feature or request label Sep 7, 2022
@endigo9740 endigo9740 self-assigned this Sep 7, 2022
@endigo9740 endigo9740 changed the title Investigate moving Tooltip to a Svelte Action Investigate using Svelte Actions for Tooltips Sep 7, 2022
@endigo9740
Copy link
Contributor Author

NOTE: here's how to ensure param data stays up to date:
https://discord.com/channels/457912077277855764/1023340103071965194/threads/1024077183158845561

@danawoodman
Copy link

+1 for this. I think for a lot of cases a tooltip is the idea candidate for an action:

<button text="Whatever you do, don't press this!" use:tooltip>LAUNCH NUKES!</button>

I wrote up doing this with Tippy.js, but could easily be done with anything else:

https://dev.to/danawoodman/svelte-quick-tip-using-actions-to-integrate-with-javascript-libraries-tippy-tooltips-2m94

@endigo9740
Copy link
Contributor Author

endigo9740 commented Sep 27, 2022

Hey @danawoodman thanks for sharing. That's so funny you would pop up on here, I actually bookmarked a tip you shared on Twitter just last night:
https://twitter.com/DanaWoodman/status/1574493362740084736

More in regards to your usage of the {$$restProps ?? ''} syntax rather than $props. I also referenced your blog post on local storage stores recently, before we migrated over to this:

Also great timing with this comment. My next two areas of focus is going to be tooltips and menus. Literally starting in like 5 minutes from now. I'm planning to use this similar action-based pattern in both. You literally could not have added this as a more perfect time!

You seem like a guy with a wealth of good info so share so I welcome any other feedback you may have for humble project :) No doubt there's lots to improve!

@danawoodman
Copy link

danawoodman commented Sep 28, 2022

Haha nice! You flatter me fine sir! Glad some of the random tidbits I've posted could help!

Oh and keep up the great work, seems like a really cool project!

@endigo9740
Copy link
Contributor Author

endigo9740 commented Sep 28, 2022

Great progress on the tooltips today! These are even more compact than the tooltips, given they are dynamically generated completely by the action.

I've created a draft PR for anyone that wants to review. I'll look to flush things out a bit further and finalize documentation asap.

Screen Shot 2022-09-28 at 6 30 22 PM

Here's an animated preview:

tooltips-preview

@endigo9740 endigo9740 linked a pull request Sep 28, 2022 that will close this issue
@endigo9740 endigo9740 pinned this issue Sep 29, 2022
@endigo9740
Copy link
Contributor Author

I've pushed one more round of updates to the component. It now has many more options for customizing the look and feel, while still leaning into the Tailwind Elements css styles as the defaults. I've also fully documented the usage, params, and classes available. Unless anyone else has feedback this may be the version we merge!

@endigo9740 endigo9740 changed the title Investigate using Svelte Actions for Tooltips Recreate Tooltip as a Svelte Action Sep 29, 2022
@endigo9740 endigo9740 added the ready to test Ready to be tested for quality assurance. label Sep 29, 2022
@endigo9740 endigo9740 unpinned this issue Oct 3, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request ready to test Ready to be tested for quality assurance.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants