Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 0 additions & 6 deletions assets/js/frontend/frontend.js
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
// import foo from './components/bar';
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is safe to delete this file. Remember to remove the entry point from package.json while doing so.

import Tabs from '@10up/component-tabs';

// eslint-disable-next-line no-new
new Tabs('.tabs', {
orientation: 'horizontal',
});
2 changes: 2 additions & 0 deletions includes/blocks/block-editor/tabs-item/block.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"name": "tenup/tabs-item",
"editorScript": "file:./register.js",
"viewScript": "file:../tabs/view.js",
"attributes":{
"header": {
"type": "string"
Expand Down
20 changes: 1 addition & 19 deletions includes/blocks/block-editor/tabs-item/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,12 @@ function register() {

if ( function_exists( 'register_block_type_from_metadata' ) ) {
register_block_type_from_metadata(
PUBLISHER_MEDIA_KIT_BLOCKS_PATH . '/tabs-item', // this is the directory where the block.json is found.
PUBLISHER_MEDIA_KIT_PATH . 'dist/blocks/block-editor/tabs-item', // this is the directory where the block.json is found.
[
'render_callback' => $n( 'render_tabs_item_block_callback' ),
]
);
}

// Enqueue assets.
add_action( 'enqueue_block_assets', $n( 'enqueue_block_assets' ) );
}

/**
* Enqueue block assets.
*/
function enqueue_block_assets() {
$asset_file = include PUBLISHER_MEDIA_KIT_PATH . 'dist/blocks/tabs-item-block.asset.php';

wp_enqueue_script(
'publisher-media-kit-tabs-item-block',
PUBLISHER_MEDIA_KIT_URL . '/dist/blocks/tabs-item-block.js',
$asset_file['dependencies'],
$asset_file['version'],
true
);
}

/**
Expand Down
4 changes: 4 additions & 0 deletions includes/blocks/block-editor/tabs/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"description": "Display sections of content with brief headings in a compact tab layout that shows one section at a time.",
"text-domain": "publisher-media-kit",
"category": "common",
"editorScript": "file:./register.js",
"editorStyle": "file:./editor.css",
"style": "file:./editor.css",
"viewScript": "file:./view.js",
"example": {
"innerBlocks": [
{
Expand Down
27 changes: 1 addition & 26 deletions includes/blocks/block-editor/tabs/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,12 @@ function register() {

if ( function_exists( 'register_block_type_from_metadata' ) ) {
register_block_type_from_metadata(
PUBLISHER_MEDIA_KIT_BLOCKS_PATH . '/tabs', // this is the directory where the block.json is found.
PUBLISHER_MEDIA_KIT_PATH . 'dist/blocks/block-editor/tabs', // this is the directory where the block.json is found.
[
'render_callback' => $n( 'render_tabs_block_callback' ),
]
);
}

// Enqueue assets.
add_action( 'enqueue_block_assets', $n( 'enqueue_block_assets' ) );
}

/**
* Enqueue block assets.
*/
function enqueue_block_assets() {
$asset_file = include PUBLISHER_MEDIA_KIT_PATH . 'dist/blocks/tabs-block.asset.php';

wp_enqueue_script(
'publisher-media-kit-tabs-block',
PUBLISHER_MEDIA_KIT_URL . '/dist/blocks/tabs-block.js',
$asset_file['dependencies'],
$asset_file['version'],
true
);

wp_enqueue_style(
'publisher-media-kit-tabs-block',
PUBLISHER_MEDIA_KIT_URL . '/dist/blocks/tabs-block.css',
[],
$asset_file['version']
);
}

/**
Expand Down
13 changes: 13 additions & 0 deletions includes/blocks/block-editor/tabs/view.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Tabs Block - Frontend View Script
*
* @package PublisherMediaKit\Blocks\Tabs
*/

import Tabs from '@10up/component-tabs';

// Initialize tabs on frontend
// eslint-disable-next-line no-new
new Tabs('.tabs', {
orientation: 'horizontal',
});
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
"shared-style": "./assets/css/shared/shared-style.css",
"style": "./assets/css/frontend/style.css",
"tabs-block": "./includes/blocks/block-editor/tabs/register.js",
"tabs-item-block": "./includes/blocks/block-editor/tabs-item/register.js"
"tabs-item-block": "./includes/blocks/block-editor/tabs-item/register.js",
"tabs-view": "./includes/blocks/block-editor/tabs/view.js"
}
}
}
6 changes: 3 additions & 3 deletions tests/cypress/integration/pmk-block-patterns.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ describe('Check if Media Kit Block Pattern is available for use', () => {
} else if ($body.find(':contains("Publisher Media Kit")').length > 0) {
cy.contains(/^Publisher Media Kit$/).click();
}

// Check if cover patter exist in the list
cy.get('[aria-label="Publisher Media Kit - Cover"]').should('exist');
});

// Wait for patterns to load, then verify cover pattern exists
cy.get('[aria-label="Publisher Media Kit - Cover"]', { timeout: 10000 }).should('exist');
});
});