Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
10 changes: 5 additions & 5 deletions docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ A single tab button in the tab list. ([Source](https://github.com/WordPress/gute
- **Experimental:** true
- **Category:** design
- **Parent:** core/tab-list
- **Supports:** color (background, text), spacing (padding), typography (fontSize, textAlign), ~~html~~, ~~lock~~, ~~reusable~~, ~~visibility~~
- **Supports:** color (background, text), spacing (padding), typography (fontSize, textAlign), ~~html~~, ~~lock~~, ~~visibility~~

## Tab List

Expand All @@ -1007,7 +1007,7 @@ Display the tab buttons for a tabbed interface. ([Source](https://github.com/Wor
- **Category:** design
- **Parent:** core/tabs
- **Allowed Blocks:** core/tab
- **Supports:** color (background, text), dimensions (~~aspectRatio~~, ~~height~~, ~~minHeight~~, ~~width~~), layout (allowJustification, allowOrientation, allowVerticalAlignment, default, ~~allowSwitching~~), spacing (blockGap, margin, padding), typography (fontSize), ~~html~~, ~~lock~~, ~~reusable~~, ~~visibility~~
- **Supports:** color (background, text), layout (default, ~~allowOrientation~~, ~~allowVerticalAlignment~~, ~~allowWrap~~), spacing (blockGap, padding), typography (fontSize), ~~html~~, ~~lock~~, ~~visibility~~

## Tab Panel

Expand All @@ -1017,7 +1017,7 @@ Content for a tab in a tabbed interface. ([Source](https://github.com/WordPress/
- **Experimental:** true
- **Category:** design
- **Parent:** core/tab-panels
- **Supports:** anchor, color (background, text), layout, renaming, spacing (blockGap, padding, ~~margin~~), typography (fontSize), ~~html~~, ~~reusable~~, ~~visibility~~
- **Supports:** anchor, color (background, text), layout, spacing (blockGap, padding), typography (fontSize), ~~html~~, ~~visibility~~
- **Attributes:** label

## Tab Panels
Expand All @@ -1029,7 +1029,7 @@ Container for tab panel content in a tabbed interface. ([Source](https://github.
- **Category:** design
- **Parent:** core/tabs
- **Allowed Blocks:** core/tab-panel
- **Supports:** color (background, heading, link, text), dimensions (~~aspectRatio~~, ~~height~~, ~~minHeight~~, ~~width~~), layout (allowJustification, default, ~~allowOrientation~~, ~~allowSizingOnChildren~~, ~~allowSwitching~~, ~~allowVerticalAlignment~~), spacing (margin, padding, ~~blockGap~~), typography (fontSize), ~~anchor~~, ~~html~~, ~~lock~~, ~~reusable~~, ~~visibility~~
- **Supports:** color (background, heading, link, text), spacing (padding), typography (fontSize), ~~html~~, ~~lock~~, ~~visibility~~

## Table

Expand Down Expand Up @@ -1058,7 +1058,7 @@ Display content in a tabbed interface to help users navigate detailed content wi
- **Experimental:** true
- **Category:** design
- **Allowed Blocks:** core/tab-list, core/tab-panels
- **Supports:** align, anchor, color (background, text), interactivity, layout (allowJustification, allowOrientation, allowSizingOnChildren, allowVerticalAlignment, default, ~~allowSwitching~~), renaming, spacing (blockGap, margin, padding), typography (fontSize), ~~html~~
- **Supports:** align, anchor, color (background, text), interactivity, layout (~~allowEditing~~), spacing (blockGap, margin, padding), typography (fontSize), ~~html~~
- **Attributes:** activeTabIndex, editorActiveTabIndex

## Tag Cloud
Expand Down
2 changes: 0 additions & 2 deletions packages/block-library/src/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@
@use "./social-links/editor.scss" as *;
@use "./spacer/editor.scss" as *;
@use "./table/editor.scss" as *;
@use "./tab-list/editor.scss" as *;
@use "./tab/editor.scss" as *;
@use "./template-part/editor.scss" as *;
@use "./term-template/editor.scss" as *;
@use "./text-columns/editor.scss" as *;
Expand Down
1 change: 0 additions & 1 deletion packages/block-library/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
@use "./tag-cloud/style.scss" as *;
@use "./tab/style.scss" as *;
@use "./tab-panel/style.scss" as *;
@use "./tab-panels/style.scss" as *;
@use "./table/style.scss" as *;
@use "./table-of-contents/style.scss" as *;
@use "./tabs/style.scss" as *;
Expand Down
24 changes: 5 additions & 19 deletions packages/block-library/src/tab-list/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,8 @@
"attributes": {},
"supports": {
"html": false,
"reusable": false,
"visibility": false,
"lock": false,
"dimensions": {
"aspectRatio": false,
"height": false,
"minHeight": false,
"width": false
},
"color": {
"background": true,
"text": true,
Expand All @@ -42,26 +35,19 @@
},
"layout": {
"default": {
"type": "flex",
"flexWrap": "nowrap",
"orientation": "horizontal"
"type": "flex"
},
"allowSwitching": false,
"allowVerticalAlignment": true,
"allowJustification": true,
"allowOrientation": true
"allowVerticalAlignment": false,
"allowOrientation": false,
"allowWrap": false
},
"spacing": {
"padding": true,
"margin": true,
"blockGap": true,
"__experimentalDefaultControls": {
"padding": true,
"margin": true,
"blockGap": true
}
}
},
"editorScript": "file:./index.js",
"editorStyle": "file:./editor.css"
}
}
10 changes: 0 additions & 10 deletions packages/block-library/src/tab-list/editor.scss

This file was deleted.

8 changes: 2 additions & 6 deletions packages/block-library/src/tab-panel/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"supports": {
"anchor": true,
"html": false,
"reusable": false,
Comment thread
t-hamano marked this conversation as resolved.
Resolved
"color": {
"background": true,
"text": true,
Expand All @@ -34,8 +33,7 @@
"layout": true,
"spacing": {
"blockGap": true,
"padding": true,
"margin": false
"padding": true
},
"typography": {
"fontSize": true,
Expand All @@ -45,12 +43,10 @@
"__experimentalFontFamily": true
}
},
"renaming": true,
"visibility": false
},
"providesContext": {
"core/tab-label": "label"
},
"editorScript": "file:./index.js",
"style": "file:./style-index.css"
"style": "wp-block-tab-panel"
}
17 changes: 0 additions & 17 deletions packages/block-library/src/tab-panel/style.scss
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
.wp-block-tab-panel {
max-width: 100%;
flex-basis: 100%;
flex-grow: 1;
box-sizing: border-box;
Comment on lines -2 to -5

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the layout of the Tab panels block has been changed from Flex to Flow, styles related to the flex layout are no longer necessary.


& > *:first-child {
margin-top: 0;
}
& > *:last-child {
margin-bottom: 0;
}
Comment on lines -7 to -12

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the tab panel uses a flow layout, these styles are not needed.


&[hidden],
&:empty {
display: none !important;
}
}

.wp-block-tab-panel.wp-block.has-background,
.wp-block-tab-panel:not(.wp-block).has-background {
padding: var(--wp--preset--spacing--30);
}
Comment on lines -20 to -23

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this block supports padding, the default padding feels redundant. Most blocks should no longer have this style.

29 changes: 2 additions & 27 deletions packages/block-library/src/tab-panels/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,9 @@
"allowedBlocks": [ "core/tab-panel" ],
"attributes": {},
"supports": {
"anchor": false,
"html": false,
"reusable": false,
"visibility": false,
"lock": false,
"dimensions": {
"aspectRatio": false,
"height": false,
"minHeight": false,
"width": false
},
"color": {
"background": true,
"text": true,
Expand All @@ -33,34 +25,17 @@
}
},
"spacing": {
"blockGap": false,
"padding": true,
"margin": true
"padding": true
},
"typography": {
"fontSize": true,
"__experimentalFontFamily": true
},
"layout": {
"default": {
"type": "flex",
"flexWrap": "nowrap",
"justifyContent": "stretch",
"orientation": "vertical"
},
"allowSwitching": false,
"allowVerticalAlignment": false,
"allowOrientation": false,
"allowJustification": true,
"allowSizingOnChildren": false
},
"__experimentalBorder": {
"radius": true,
"color": true,
"width": true,
"style": true
}
},
"editorScript": "file:./index.js",
"style": "file:./style-index.css"
}
}
4 changes: 0 additions & 4 deletions packages/block-library/src/tab-panels/style.scss

This file was deleted.

5 changes: 1 addition & 4 deletions packages/block-library/src/tab/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
],
"supports": {
"html": false,
"reusable": false,
"visibility": false,
"lock": false,
"color": {
Expand Down Expand Up @@ -50,7 +49,5 @@
"style": true
}
},
"editorScript": "file:./index.js",
"editorStyle": "file:./editor.css",
"style": "file:./style-index.css"
"style": "wp-block-tab"
}
14 changes: 0 additions & 14 deletions packages/block-library/src/tab/editor.scss

This file was deleted.

5 changes: 0 additions & 5 deletions packages/block-library/src/tab/style.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
.wp-block-tab {
box-sizing: border-box;
color: inherit;
display: block;
width: max-content;
text-decoration: none;
cursor: pointer;
flex-basis: inherit !important;
flex-grow: inherit !important;
position: relative;

// Button reset
Expand Down
20 changes: 3 additions & 17 deletions packages/block-library/src/tabs/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,7 @@
}
},
"layout": {
"default": {
"type": "flex",
"flexWrap": "nowrap",
"justifyContent": "stretch",
"verticalAlignment": "stretch",
"orientation": "vertical"
},
"allowSwitching": false,
"allowVerticalAlignment": true,
"allowJustification": true,
"allowOrientation": true,
"allowSizingOnChildren": true
"allowEditing": false
},
"html": false,
"interactivity": true,
Expand All @@ -53,16 +42,13 @@
"typography": {
"fontSize": true,
"__experimentalFontFamily": true
},
"renaming": true
}
},
"providesContext": {
"core/tabs-activeTabIndex": "activeTabIndex",
"core/tabs-editorActiveTabIndex": "editorActiveTabIndex"
},
"usesContext": [ "core/tabs-list", "core/tabs-id" ],
"editorScript": "file:./index.js",
"editorStyle": "file:./index.css",
"style": "file:./style-index.css",
"style": "wp-block-tabs",
"viewScriptModule": "@wordpress/block-library/tabs/view"
}
6 changes: 1 addition & 5 deletions packages/block-library/src/tabs/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,7 @@ function Edit( { clientId, attributes, setAttributes } ) {
return (
<BlockContextProvider value={ contextValue }>
<div { ...innerBlockProps }>
<Controls
clientId={ clientId }
attributes={ attributes }
setAttributes={ setAttributes }
/>
<Controls clientId={ clientId } />
{ innerBlockProps.children }
</div>
</BlockContextProvider>
Expand Down
13 changes: 0 additions & 13 deletions packages/block-library/src/tabs/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,30 +96,17 @@ function block_core_tabs_render_block_callback( array $attributes, string $conte
return '';
}

$is_vertical = false;

$tag_processor = new WP_HTML_Tag_Processor( $content );

$tag_processor->next_tag( array( 'class_name' => 'wp-block-tabs' ) );
$tag_processor->set_attribute( 'data-wp-interactive', 'core/tabs/private' );

// Inspect inside the tab-list to see if its vertical or not.
$tag_processor->set_bookmark( 'core/tabs_wrapper' );
while ( $tag_processor->next_tag( array( 'class_name' => 'wp-block-tabs-list' ) ) ) {
if ( $tag_processor->has_class( 'is-vertical' ) ) {
$is_vertical = true;
break;
}
}
$tag_processor->seek( 'core/tabs_wrapper' );

$tag_processor->set_attribute(
'data-wp-context',
wp_json_encode(
array(
'tabsId' => $tabs_id,
'activeTabIndex' => $active_tab_index,
'isVertical' => $is_vertical,
)
)
);
Expand Down
12 changes: 2 additions & 10 deletions packages/block-library/src/tabs/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,24 +102,16 @@ const { actions: privateActions, state: privateState } = store(
* @param {KeyboardEvent} event The keydown event.
*/
handleTabKeyDown: withSyncEvent( ( event ) => {
const context = getContext();
const { isVertical } = context;
const { tabIndex } = privateState;

if ( tabIndex === null ) {
return;
}

if ( event.key === 'ArrowRight' && ! isVertical ) {
event.preventDefault();
privateActions.moveFocus( tabIndex + 1 );
} else if ( event.key === 'ArrowLeft' && ! isVertical ) {
event.preventDefault();
privateActions.moveFocus( tabIndex - 1 );
} else if ( event.key === 'ArrowDown' && isVertical ) {
if ( event.key === 'ArrowRight' ) {
event.preventDefault();
privateActions.moveFocus( tabIndex + 1 );
} else if ( event.key === 'ArrowUp' && isVertical ) {
} else if ( event.key === 'ArrowLeft' ) {
event.preventDefault();
privateActions.moveFocus( tabIndex - 1 );
}
Expand Down
Loading