-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Displays list of tabs and active tab content
- Loading branch information
1 parent
5ba5162
commit 49f8565
Showing
10 changed files
with
119 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,19 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { InnerBlocks, RichText, useBlockProps } from '@wordpress/block-editor'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { | ||
InnerBlocks, | ||
useBlockProps, | ||
useInnerBlocksProps, | ||
} from '@wordpress/block-editor'; | ||
|
||
export default function Edit( { context } ) { | ||
console.log( context ); | ||
const isActive = context[ 'tabs/activeTab' ]; | ||
return ( | ||
<div | ||
{ ...useBlockProps( { | ||
className: isActive ? 'is-active' : '', | ||
} ) } | ||
> | ||
<InnerBlocks | ||
defaultBlock={ [ | ||
'core/paragraph', | ||
{ placeholder: __( 'Enter tab content…' ) }, | ||
] } | ||
directInsert | ||
/> | ||
</div> | ||
); | ||
export default function Edit( { clientId, context } ) { | ||
const isActive = context[ 'tabs/activeTab' ] === clientId; | ||
const blockProps = useBlockProps( { | ||
className: isActive ? 'is-active' : '', | ||
} ); | ||
const innerBlocksProps = useInnerBlocksProps( blockProps, { | ||
renderAppender: InnerBlocks.ButtonBlockAppender, | ||
} ); | ||
return <div { ...innerBlocksProps } role="tabpanel"></div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.wp-block-tab { | ||
display: none; | ||
|
||
&.is-active { | ||
display: block; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,6 @@ | ||
.wp-block-tabs { | ||
.wp-block-tabs__tab-buttons { | ||
display: flex; | ||
border-bottom: 1px solid #ccc; | ||
} | ||
|
||
.wp-block-tabs__tab-button { | ||
background: none; | ||
border: none; | ||
padding: 10px 15px; | ||
cursor: pointer; | ||
|
||
&.is-active { | ||
border-bottom: 2px solid #007cba; | ||
} | ||
} | ||
|
||
.wp-block-tabs__content { | ||
padding: 15px 0; | ||
} | ||
} | ||
|
||
.wp-block-tab { | ||
display: none; | ||
|
||
&.is-active { | ||
display: block; | ||
} | ||
.wp-block-tabs__list { | ||
display: flex; | ||
gap: 10px; | ||
list-style: none; | ||
padding: 0; | ||
} |