r/reactjs • u/[deleted] • Sep 21 '20
Show /r/reactjs A responsive multi-level menu component I created using react hooks
25
u/voxgtr Sep 21 '20
Seeing what people are able to make with Framer Motion is pretty impressive to see.
6
17
Sep 21 '20
Thanks everyone. Pretty new to web programing. I will fix the errors you pointed. It uses react portal to mount the container. Dragable button is just for testing position in various places. I used a custom hook to detect outside click which work in react portals. I will fix the hook to detect any activity outside element.
28
u/Brahminmeat Sep 21 '20
You should lock the drag of the ellipsis button when the menu is open. Right now I can open the menu and drag the icon away, leaving the menu behind.
10
17
u/Brahminmeat Sep 21 '20
That, or fire a close event on the menu when the button is dragged
10
4
u/aadil_hasan Sep 21 '20
Hey that's just beautiful, is it open source?, I would like to use that in my extension https://getprotab.com.
2
Sep 21 '20
Thank you.. Yes it is open source https://github.com/ruvkr/react-components-by-ruvkr
3
u/ollir Sep 21 '20
sample_items.js has an item "short by". Surely you meant "sort by"? But looking nice!
Edit: nvm, wasn't first to notice it
6
Sep 21 '20
What about accessibility? If it’s accessible then you’ve really outdone yourself. If not and you’re up for a challenge, try making it accessible.
1
3
u/GSN__ Sep 21 '20
Nice work, I have just started learning react and this project is definitely going to be in my to learn list. Just a small spelling mistake though, its "Sort by" not "Short by". Hope you dont mind :)
3
Sep 21 '20
I'm pretty new too. I only started learning js last year.
1
2
2
u/gavlois1 I ❤️ hooks! 😈 Sep 21 '20
It looks great! However, it doesn't seem to be usable via keyboard (apart from opening and closing the menu), so I suspect this isn't accessible. If this can be made to be accessible, that would be totally awesome.
I noticed you mentioned you were pretty new to web programming. If so, then it's a perfect time to get the fundamentals of building accessible UIs.
1
14
u/jpsreddit85 Sep 21 '20
Amazing coding, don't want to take away from that. But for usability, I personally hate menus where the back and cancel buttons jump around all over the place forcing me to mouse search for them. If I used this for any length of time I'd be cursing you.
1
u/cYzzie Sep 22 '20
Just tried it on an ipad pro and there is a weird flickering when opening 2nd level submenus- maybe try checking that out.
1
Sep 22 '20
Do you mean the stretching of close button when changing levels?
1
u/cYzzie Sep 22 '20
no its really like a flickering of the text as if they are loaded/unloaded multiple times, do you have access to an ios device? i am sure its pretty easy to reproduce, if not just tell me again and i will do a screen recording
1
Sep 22 '20
Sorry I don't have access to an ios device, a screen recording would be great. Can you test this in google chrome or firefox.
1
u/style-112 Sep 22 '20
great design... now step up your game and make ist accessible. e.g. with Reakit:
https://codesandbox.io/s/reakit-combobox-menu-with-submenu-28tl6?file=/src/styles.css
1
2
1
1
1
1
1
1
1
1
1
1
1
u/akza07 Sep 22 '20
I wish my Desktop OS had this kind of Aesthetically pleasing animation & colour scheme.
1
1
u/DJCowGaming Oct 07 '20
I'm not a js programer, but good job, very impressive! I totally know what this is...
0
Sep 22 '20
[deleted]
1
Sep 22 '20
That is framer motion layout animation. https://www.framer.com/api/motion/animation/#layout-animations
32
u/[deleted] Sep 21 '20
Demo https://react-components-by-ruvkr.web.app/