-
Notifications
You must be signed in to change notification settings - Fork 1
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
Implement Accordion Block Plugin #16
base: trunk
Are you sure you want to change the base?
Conversation
In such a case, do we need the Content block? Couldn't everything inside the accordion block that isn't the trigger be treated as content? That's that tripped me off; if Content is the container, why couldn't I put inside multiple sections inside like you describe?
Those icons don't come from the default WP set, but they do look similar. We can create our own and make sure they match what's being displayed on the front-end. AFAIK, there's no easy way to display individual Gutenberg icons on the front-end, so we may need to use custom icons anyway. Added a bunch to the Figma.
100% agree. @jffng, one more thing: can we repeat some settings across the inner blocks and keep them in sync? For example, it'd be great to show the icon picker when the trigger block is selected. Currently, it's only displayed in the parent, which some folks may never discover. The same goes for the icon position.
Here's the SVG file! Let me know if it works. |
Hmm that link is not allowing me to download it. |
@jarekmorawski Can you "copy as svg" from Figma and paste in a code block (or point me to the icon in Figma)? There might be some issues with masking or layer order in the SVG code, I can help sort it out if needed. |
Sure thing. FWIW, you can right-click on that SVG and download it like any other image. Here's the code:
|
Bump version.
Okay, I made the following changes:
A demo and plugin download is available at https://cool-tools.mystagingwebsite.com/2024/07/12/accordion/ https://cloudup.com/cBIxzqcM2Ym One follow up for sure I want to do is to add a setting to adjust the icon size. |
Wow, looking awesome!!! Love all the options for the trigger 🤡
I'm thinking about any "default styles" we might want to include (@jarekmorawski may have input here). To me, this is pretty much the default I'd want to go for: To achieve this:
|
Good points on everything, @jarekmorawski.
I also didn't notice that there was a "none" option for the icon, hah. I'd vote for
I tested this out with 2024, and h5 feels too small (I'm stress testing over on this page, btw). h4 works better (although I am also still a fan of h3, too). @jffng is there any guidance around semantic hierarchy of DOM elements for block defaults? Like, I'd almost want to make it an h2, then size the text smaller, but that's probably a bad idea, haha. h4 probably is the way to go. Another note...
|
Another Q for @jffng... following up on the chat we had yesterday, I see there are focus styles applied at the block level, specifically to this class: I previously thought these were inherited, but if they're not, can we remove it from the |
👍
👍
I find it a little confusing what accordion is being referred to by "this" and "another one" — is it the accordion group or accordion item? Technically this is a setting of the group, but it affects the behavior of accordions inside the group. Also something to consider is when this setting is enabled and multiple accordion items are open by default, clicking any open section actually closes all of them. What do you think about
I think it depends what's on the page already and where the accordion appears (i.e. is there a h2 placed right before it that acts to describe / label the accordion?). Then h3 would be the correct level. Also different themes and style variations are going to change the size of an h3/4/5. With that in mind, do you still think h4 or h5 is best for the default, or can we keep it h3?
👍 FYI I'm going to continue working on this over here, can we pick up the discussion / feedback there? 🙏 |
What
This PR implements an Accordion block. It's an alternative to #6.
This approach actually is composed using four blocks:
Without getting too much into the weeds, this was done because it was the simplest way I could figure out how to allow user styling of the trigger and content separately, while maintaining the accessibility and semantic needs of an accordion pattern.
Highlights
Demo & Download
https://cool-tools.mystagingwebsite.com/2024/07/12/accordion/
Video Walkthrough
https://video.wordpress.com/embed/AfzRE5Om