Skip to content

Commit

Permalink
Enhance tab group functionality and interactivity; update attributes,…
Browse files Browse the repository at this point in the history
… styles, and unique identification for multiple instances
  • Loading branch information
ipatate committed Nov 6, 2024
1 parent c816d1a commit 8a8a290
Show file tree
Hide file tree
Showing 23 changed files with 110 additions and 35 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CodeGPT.apiKey": "Ollama"
}
16 changes: 14 additions & 2 deletions build/tab-group/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,21 @@
},
"supports": {
"html": false,
"align": true,
"anchor": true,
"alignWide": true,
"interactivity": true
"interactivity": true,
"color": {
"text": true,
"link": true,
"background": true
},
"dimensions": {
"minHeight": true
},
"spacing": {
"margin": true,
"padding": true
}
},
"textdomain": "marvelous-tab",
"editorScript": "file:./index.js",
Expand Down
2 changes: 1 addition & 1 deletion build/tab-group/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-data'), 'version' => '722c5e2d4855328e12e4');
<?php return array('dependencies' => array('react', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-data'), 'version' => 'fafa1d3c4d7b05d2cde6');
2 changes: 1 addition & 1 deletion build/tab-group/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/tab-group/index.js.map

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions build/tab-group/render.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
<?php
// generate uniq id if multiple block in content
$block_id = uniqid();
?>
<div <?php echo get_block_wrapper_attributes([
'class' => 'marvelous-tab-group',
]); ?>
data-wp-interactive="goodmotion/marvelous-tab"
<?php echo wp_interactivity_data_wp_context(['current' => 'section-0']); ?>>
<?php echo wp_interactivity_data_wp_context(['current' => 'section-0' . '_' . $block_id]); ?>>
<div class="tab-control" role="tablist">
<?php foreach ($block->inner_blocks as $key => $inner_block): ?>
<button
id="tab-<?php echo $key; ?>"
id="tab-<?php echo $key . '_' . $block_id; ?>"
role="tab"
data-target="section-<?php echo $key; ?>"
aria-controls="section-<?php echo $key . '_' . $block_id; ?>"
data-wp-on--click="actions.showTab"
data-wp-class--tab-is-active="state.tabIsShow"
data-wp-bind--aria-selected="state.tabIsShow">
Expand All @@ -18,10 +22,10 @@
</div>
<div class="tab-content">
<?php foreach ($block->inner_blocks as $key => $inner_block): ?>
<div id="section-<?php echo $key; ?>"
<div id="section-<?php echo $key . '_' . $block_id; ?>"
role="tabpanel"
data-wp-bind--hidden="!state.isShow"
data-wp-bind--aria-labelledby="tab-<?php echo $key; ?>"
data-wp-bind--aria-labelledby="tab-<?php echo $key . '_' . $block_id; ?>"
data-wp-bind--aria-hidden="!state.isShow">
<?php echo $inner_block->render(); ?>
</div>
Expand Down
2 changes: 1 addition & 1 deletion build/tab-group/style-index-rtl.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/tab-group/style-index.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/tab-group/style-index.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/tab-group/view.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('@wordpress/interactivity'), 'version' => '12ecc2d9c88638177b7b', 'type' => 'module');
<?php return array('dependencies' => array('@wordpress/interactivity'), 'version' => 'fd1c03050ab067bf2f9a', 'type' => 'module');
2 changes: 1 addition & 1 deletion build/tab-group/view.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/tab-group/view.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion build/tab-item/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,20 @@
"supports": {
"html": false,
"align": true,
"alignWide": true
"alignWide": true,
"color": {
"text": true,
"link": true,
"background": true,
"heading": true
},
"dimensions": {
"minHeight": true
},
"spacing": {
"margin": true,
"padding": true
}
},
"textdomain": "marvelous-tab",
"editorScript": "file:./index.js"
Expand Down
2 changes: 1 addition & 1 deletion build/tab-item/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-i18n'), 'version' => '7cf693b80d7120cfebf8');
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-i18n'), 'version' => 'a3d1b7ce1f5cfec53e6e');
Loading

0 comments on commit 8a8a290

Please sign in to comment.