eightshift-frontend-libs
eightshift-frontend-libs copied to clipboard
Add tabs block (WIP)
This PR adds support for a tabs block.
https://user-images.githubusercontent.com/1742806/127016659-f4598d09-112a-4cc7-8e1c-281e1a0acf4a.mov
It's a work in progress, and remaining tasks include (along with anything else you can think of):
- [x] improving accessibility and UX
- [ ] adding options (currently, the only useful option I can think of is what tab is opened by default)
- [x] cleaning up code (some SCSS is duplicated needlessly, and some whitespace lines remain in JavaScript)
- [ ] fixing the example modal (which currently doesn't work because the block relies on
wp.data.select('core/block-editor')
- [x] adding icons for the
tabs
andtab
blocks - [ ] adding storybook
I'm also not sure that this is the best way to do implement this, so any and all suggestions would be welcome.
As for how this works, this commit introduces a parent block tabs
that contains a tab
block which contains InnerBlocks
(akin to the way columns work). The tabs
block looks up what its InnerBlocks are by using getBlock
, while the currently active tab is stored as an attribute (that's set using updateBlock
) and provided in context to tab
blocks to toggle visibility classes.
@goranalkovic-infinum do you think you'll be able to pick this one up? I think having tabs would be a nice addition to the libs 🙂
@goranalkovic-infinum do you think you'll be able to pick this one up? I think having tabs would be a nice addition to the libs 🙂
this is in plan after the "redesign" that Goc is doing
Hmm.. nice option for tab will be "remeber me" like when user open tab and then navigate to other page when he returns to page with tabs then that tab with flag remeber me know the state of closed/opened ....put it in localstorage....
Nice work and a block we definitely need as part of the libs 😄
Also it would be nice:
- to add
aria
attributes - to add keyboard support for switching tabs
I think this is pretty nice example of this: https://codepen.io/heydon/pen/veeaEa
goodbye to this PR 👋