svecosystem / runed

Magical utilities for your Svelte applications (WIP)
https://runed.dev
MIT License
387 stars 21 forks source link

feat: add `IsHovered` #116

Open Not-Jayden opened 3 weeks ago

Not-Jayden commented 3 weeks ago

https://not-jayden-is-hovered.runed.pages.dev/docs/utilities/is-hovered

changeset-bot[bot] commented 3 weeks ago

🦋 Changeset detected

Latest commit: 21e6e822c20b348f145a98c3f10f432fd00aa82f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ----- | ----- | | runed | Minor |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

github-actions[bot] commented 3 weeks ago
built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
runed ✅ Ready (View Log) Visit Preview 21e6e822c20b348f145a98c3f10f432fd00aa82f
huntabyte commented 3 weeks ago

Thanks for kicking this off!

One thing I think we should handle before merging this is ensuring that emulated mouse events on mobile are ignored. One of the pain points of the :hover pseudo selector is with mobile devices.

Not-Jayden commented 3 weeks ago

Thanks for kicking this off!

One thing I think we should handle before merging this is ensuring that emulated mouse events on mobile are ignored. One of the pain points of the :hover pseudo selector is with mobile devices.

@huntabyte Thanks. I've pushed a quick attempt at detecting hover capability, but based on your comment I'm thinking it's probably not your desired approach. Feel free to revert and/or change as desired if so, as I'm not super across the problem.

Self-review - if this is along the lines of what you had in mind, maybe any-hover and any-pointer would be a better choice to better cover edge cases of mixed inputs (e.g. phone with a mouse)

huntabyte commented 1 week ago

Note to self - I've done something similar with https://github.com/svecosystem/svelte-interactions - specifically the createHover function. Perhaps we could bring that logic in here?

Not-Jayden commented 6 days ago

Note to self - I've done something similar with svecosystem/svelte-interactions - specifically the createHover function. Perhaps we could bring that logic in here?

Oh, I had no idea that existed, nice! I actually prefer actions for this kind of stuff usually anyway, this just felt like a low hanging fruit while I was looking at the repo and comparing to other hook libraries.

I wonder if we can create a more generic adapter to rune-ify all those actions and re-use them rather than duplicating the logic in both places. Just comes with the consideration of whether it's worth making it a dependency 🤷‍♂️