Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
fe0aaee
Add initial accordion implementation.
jffng Jul 30, 2024
ebfc5f5
Refactor blocks for core loading.
jffng Jul 30, 2024
c58232f
Simplify state getter by storing id in the context.
jffng Aug 1, 2024
4698eee
Clean up tag processing and try to initialize state on the server.
jffng Aug 2, 2024
3c2c54b
Don't enqueue the frontend files if there's no content
luisherranz Aug 6, 2024
d4101b4
Stringify the autoclose value
luisherranz Aug 6, 2024
872ecf1
Refactor to populate `context.isOpen` on the server
luisherranz Aug 6, 2024
5f9e24a
Add comments to the server side rendering functions.
jffng Aug 6, 2024
b790e90
Improve the block editing UX
jffng Aug 6, 2024
7a05993
Reword the auto-close toggle help text.
jffng Aug 12, 2024
cea68d0
Add padding to the content and trigger by default.
jffng Aug 12, 2024
96c37c9
Fix aria-labelledby and aria-controls references.
jffng Aug 14, 2024
151655b
Allow HeadingLevelOptions to be extended.
jffng Aug 14, 2024
37315e4
Only allow bold, italic, image, and strikethrough for the Trigger.
jffng Aug 16, 2024
7f17891
Disable keyboard navigation for focusable elements when aria-hidden i…
jffng Aug 16, 2024
6c91e72
Fix __next40pxDefaultSize linting error.
jffng Aug 16, 2024
72fdd46
Refactor how state and context are initialized to avoid the need for …
jffng Aug 16, 2024
5967cf1
Use strings for openByDefault so boolean is in the generated JSON.
jffng Sep 3, 2024
db03ba8
Use inert instead of aria-hidden.
jffng Sep 3, 2024
93deeee
Rename Trigger and Content to Header and Panel.
jffng Sep 16, 2024
84112e3
Rename interactivity to script modules.
jffng Sep 16, 2024
542ac20
Remove unused watch directive for setting the tabIndex.
jffng Sep 16, 2024
2d07fba
Merge branch 'trunk' into try/accordion-block
mikachan Aug 4, 2025
5ccd5e3
Move icon controls to top level
mikachan Aug 5, 2025
89f3ffd
Fix linting
mikachan Aug 5, 2025
2916ba6
Remove old GB experiments
mikachan Aug 5, 2025
6fa545e
Remove icon selection
mikachan Aug 8, 2025
df7ee79
Select first Accordion Header by default
mikachan Aug 8, 2025
1715381
Fix icon logic in save.js
mikachan Aug 8, 2025
8d3aa4a
Remove layout controls from header and panel
mikachan Aug 8, 2025
0f2ee27
Fix RTL icon position
mikachan Aug 8, 2025
445f1d1
Remove layout from group and item
mikachan Aug 8, 2025
d4bb0e4
Add layout to accordion group
mikachan Aug 11, 2025
f713c57
Rename Accordion Group to Accordions
mikachan Aug 12, 2025
fb546f7
Use single useSelect
mikachan Aug 13, 2025
0be4b65
Move accordion icons to icon library
mikachan Aug 13, 2025
237af26
Remove color and padding from heading styles
mikachan Aug 13, 2025
43dc276
Make heading CSS less specific
mikachan Aug 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename Trigger and Content to Header and Panel.
  • Loading branch information
jffng committed Sep 16, 2024
commit 93deeee8a6699dfd5c38cf89707a5b1989aa89ea
34 changes: 17 additions & 17 deletions docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,6 @@ This page lists the blocks included in the block-library package.

<!-- START TOKEN Autogenerated - DO NOT EDIT -->

## Content

Accordion item content ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/accordion-content))

- **Name:** core/accordion-content
- **Experimental:** true
- **Category:** design
- **Parent:** core/accordion-item
- **Supports:** border, color (background, gradient, text), interactivity, layout, shadow, spacing (blockGap, margin, padding), typography (fontSize, lineHeight)
- **Attributes:** allowedBlocks, isSelected, openByDefault, templateLock

## Accordion Group

A group of headers and associated expandable content. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/accordion-group))
Expand All @@ -30,6 +19,17 @@ A group of headers and associated expandable content. ([Source](https://github.c
- **Supports:** align (full, wide), background (backgroundImage, backgroundSize), color (background, gradient, text), interactivity, layout, shadow, spacing (blockGap, margin, padding), ~~html~~
- **Attributes:** allowedBlocks, autoclose, iconPosition

## Accordion Header

Accordion header. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/accordion-header))

- **Name:** core/accordion-header
- **Experimental:** true
- **Category:** design
- **Parent:** core/accordion-item
- **Supports:** anchor, border, color (background, gradient, text), interactivity, layout, shadow, spacing (margin, padding), typography (fontSize, textAlign), ~~align~~
- **Attributes:** icon, iconPosition, level, levelOptions, openByDefault, textAlignment, title

## Accordion

A single accordion that displays a header and expandable content. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/accordion-item))
Expand All @@ -38,20 +38,20 @@ A single accordion that displays a header and expandable content. ([Source](http
- **Experimental:** true
- **Category:** design
- **Parent:** core/accordion-group
- **Allowed Blocks:** core/accordion-trigger, core/accordion-content
- **Allowed Blocks:** core/accordion-header, core/accordion-panel
- **Supports:** align (full, wide), color (background, gradient, text), interactivity, layout, shadow, spacing (blockGap, margin)
- **Attributes:** openByDefault

## Trigger
## Accordion Panel

Accordion item trigger. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/accordion-trigger))
Accordion Panel ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/accordion-panel))

- **Name:** core/accordion-trigger
- **Name:** core/accordion-panel
- **Experimental:** true
- **Category:** design
- **Parent:** core/accordion-item
- **Supports:** anchor, border, color (background, gradient, text), interactivity, layout, shadow, spacing (margin, padding), typography (fontSize, textAlign), ~~align~~
- **Attributes:** icon, iconPosition, level, levelOptions, openByDefault, textAlignment, title
- **Supports:** border, color (background, gradient, text), interactivity, layout, shadow, spacing (blockGap, margin, padding), typography (fontSize, lineHeight)
- **Attributes:** allowedBlocks, isSelected, openByDefault, templateLock

## Archives

Expand Down
4 changes: 2 additions & 2 deletions lib/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ function gutenberg_reregister_core_block_types() {
$blocks_dirs = array(
__DIR__ . '/../build/block-library/blocks/' => array(
'block_folders' => array(
'accordion-trigger',
'accordion-content',
'accordion-header',
'accordion-panel',
'audio',
'button',
'buttons',
Expand Down
8 changes: 4 additions & 4 deletions packages/block-library/src/accordion-group/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
width: 100%;
}

.is-layout-flow > .wp-block-accordion-content,
.wp-block-accordion-content {
.is-layout-flow > .wp-block-accordion-panel,
.wp-block-accordion-panel {
overflow: hidden;
margin: 0;
}

.accordion-content__wrapper {
.accordion-panel__wrapper {
padding-bottom: var(--wp--preset--spacing--20, 1em);
}

Expand All @@ -54,7 +54,7 @@
background-color: unset;
}

.wp-block-accordion-trigger.icon-position-left .accordion-item__toggle {
.wp-block-accordion-header.icon-position-left .accordion-item__toggle {
/* stylelint-disable-next-line declaration-property-value-allowed-list -- This should be refactored to not use the row-reverse value. */
flex-direction: row-reverse;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "core/accordion-trigger",
"name": "core/accordion-header",
"version": "0.1.0",
"title": "Trigger",
"title": "Accordion Header",
"category": "design",
"description": "Accordion item trigger.",
"description": "Accordion header.",
"example": {},
"__experimental": true,
"parent": [ "core/accordion-item" ],
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/accordion-item/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"example": {},
"__experimental": true,
"parent": [ "core/accordion-group" ],
"allowedBlocks": [ "core/accordion-trigger", "core/accordion-content" ],
"allowedBlocks": [ "core/accordion-header", "core/accordion-panel" ],
"supports": {
"align": [ "wide", "full" ],
"color": {
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/accordion-item/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ export default function Edit( {
},
{
template: [
[ 'core/accordion-trigger', {} ],
[ 'core/accordion-header', {} ],
[
'core/accordion-content',
'core/accordion-panel',
{
isSelected: true,
openByDefault,
Expand Down
6 changes: 3 additions & 3 deletions packages/block-library/src/accordion-item/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ function block_core_accordion_item_render( $attributes, $content ) {
if ( $p->next_tag( array( 'class_name' => 'accordion-item__toggle' ) ) ) {
$p->set_attribute( 'data-wp-on--click', 'actions.toggle' );
$p->set_attribute( 'id', $unique_id );
$p->set_attribute( 'aria-controls', $unique_id . '-content' );
$p->set_attribute( 'aria-controls', $unique_id . '-panel' );
$p->set_attribute( 'data-wp-bind--aria-expanded', 'state.isOpen' );

if ( $p->next_tag( array( 'class_name' => 'wp-block-accordion-content' ) ) ) {
$p->set_attribute( 'id', $unique_id . '-content' );
if ( $p->next_tag( array( 'class_name' => 'wp-block-accordion-panel' ) ) ) {
$p->set_attribute( 'id', $unique_id . '-panel' );
$p->set_attribute( 'aria-labelledby', $unique_id );
Comment thread
jffng marked this conversation as resolved.
$p->set_attribute( 'data-wp-bind--inert', '!state.isOpen' );
$p->set_attribute( 'data-wp-watch', 'callbacks.setTabIndex' );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "core/accordion-content",
"name": "core/accordion-panel",
"version": "0.1.0",
"title": "Content",
"title": "Accordion Panel",
"category": "design",
"description": "Accordion item content",
"description": "Accordion Panel",
"example": {},
"__experimental": true,
"parent": [ "core/accordion-item" ],
Expand Down
8 changes: 4 additions & 4 deletions packages/block-library/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import {
// See https://github.com/WordPress/gutenberg/pull/40655 for more context.
import * as accordionGroup from './accordion-group';
import * as accordionItem from './accordion-item';
import * as accordionTrigger from './accordion-trigger';
import * as accordionContent from './accordion-content';
import * as accordionHeader from './accordion-header';
import * as accordionPanel from './accordion-panel';
import * as archives from './archives';
import * as avatar from './avatar';
import * as audio from './audio';
Expand Down Expand Up @@ -240,8 +240,8 @@ const getAllBlocks = () => {
if ( window?.__experimentalEnableBlockExperiments ) {
blocks.push( accordionGroup );
blocks.push( accordionItem );
blocks.push( accordionTrigger );
blocks.push( accordionContent );
blocks.push( accordionHeader );
blocks.push( accordionPanel );
}

if ( window?.__experimentalEnableFormBlocks ) {
Expand Down