Skip to content

Commit

Permalink
Comment out whole file for now.
Browse files Browse the repository at this point in the history
  • Loading branch information
mauteri committed Jan 5, 2025
1 parent db7a1be commit e62745a
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 88 deletions.
2 changes: 1 addition & 1 deletion build/variations/add-to-calendar/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('wp-blocks', 'wp-i18n'), 'version' => '37389dc4747e8e7e0953');
<?php return array('dependencies' => array(), 'version' => '31d6cfe0d16ae931b73c');
1 change: 0 additions & 1 deletion build/variations/add-to-calendar/index.js
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
(()=>{"use strict";const e=window.wp.blocks,t=window.wp.i18n,r={category:"gatherpress",isActive:["metadata.bindings.url.args.service"],example:{}},o={tagName:"a"},a=[{service:"google",text:(0,t.__)("Google","gatherpress"),title:(0,t.__)("Add event to your Google calendar.","gatherpress")},{service:"ical",text:(0,t.__)("iCal","gatherpress"),title:(0,t.__)("Download event as iCal file.","gatherpress")},{service:"outlook",text:(0,t.__)("Outlook","gatherpress"),title:(0,t.__)("Download event as Outlook file.","gatherpress")},{service:"yahoo",text:(0,t.__)("Yahoo","gatherpress"),title:(0,t.__)("Add event to your Yahoo calendar.","gatherpress")}];function s(e){const{service:t,title:r,text:a}=e;return{...o,title:r,text:a,rel:"google"===t||"yahoo"===t?"noopener norefferrer":null,linkTarget:"google"===t||"yahoo"===t?"_blank":null,placeholder:a,metadata:{bindings:{url:{source:"gatherpress/add-to-calendar",args:{service:t}}},name:a}}}a.forEach((t=>{const o=s(t);(0,e.registerBlockVariation)("core/button",{...r,name:`gatherpress-add-to-calendar-details-${t.service}`,title:t.text,description:t.title,attributes:o})})),a.map((e=>["core/button",s(e)]))})();
172 changes: 86 additions & 86 deletions src/variations/add-to-calendar/index.js
Original file line number Diff line number Diff line change
@@ -1,98 +1,98 @@
/**
* WordPress dependencies
*/
import { registerBlockVariation } from '@wordpress/blocks';
import { __ } from '@wordpress/i18n';
import { calendar } from '@wordpress/icons';
// import { registerBlockVariation } from '@wordpress/blocks';
// import { __ } from '@wordpress/i18n';
// import { calendar } from '@wordpress/icons';

const NAME = 'gatherpress-add-to-calendar-details';
const VARIATION_ATTRIBUTES = {
category: 'gatherpress',
isActive: ['metadata.bindings.url.args.service'],
example: {},
};
const BUTTON_ATTRIBUTES = {
tagName: 'a', // By setting this to 'button', instead of 'a', we can completely prevent the LinkControl getting rendered into the Toolbar.
};
const SERVICES = [
{
service: 'google',
text: __('Google', 'gatherpress'),
title: __('Add event to your Google calendar.', 'gatherpress'),
},
{
service: 'ical',
text: __('iCal', 'gatherpress'),
title: __('Download event as iCal file.', 'gatherpress'),
},
{
service: 'outlook',
text: __('Outlook', 'gatherpress'),
title: __('Download event as Outlook file.', 'gatherpress'),
},
{
service: 'yahoo',
text: __('Yahoo', 'gatherpress'),
title: __('Add event to your Yahoo calendar.', 'gatherpress'),
},
];
// const NAME = 'gatherpress-add-to-calendar-details';
// const VARIATION_ATTRIBUTES = {
// category: 'gatherpress',
// isActive: ['metadata.bindings.url.args.service'],
// example: {},
// };
// const BUTTON_ATTRIBUTES = {
// tagName: 'a', // By setting this to 'button', instead of 'a', we can completely prevent the LinkControl getting rendered into the Toolbar.
// };
// const SERVICES = [
// {
// service: 'google',
// text: __('Google', 'gatherpress'),
// title: __('Add event to your Google calendar.', 'gatherpress'),
// },
// {
// service: 'ical',
// text: __('iCal', 'gatherpress'),
// title: __('Download event as iCal file.', 'gatherpress'),
// },
// {
// service: 'outlook',
// text: __('Outlook', 'gatherpress'),
// title: __('Download event as Outlook file.', 'gatherpress'),
// },
// {
// service: 'yahoo',
// text: __('Yahoo', 'gatherpress'),
// title: __('Add event to your Yahoo calendar.', 'gatherpress'),
// },
// ];

// Helper to generate button attributes based on service.
function createButtonAttributes(serviceData) {
const { service, title, text } = serviceData;
return {
...BUTTON_ATTRIBUTES,
title,
text,
rel:
service === 'google' || service === 'yahoo'
? 'noopener norefferrer'
: null,
linkTarget:
service === 'google' || service === 'yahoo' ? '_blank' : null,
placeholder: text,
metadata: {
bindings: {
url: {
source: 'gatherpress/add-to-calendar',
args: { service },
},
},
name: text,
},
};
}
// // Helper to generate button attributes based on service.
// function createButtonAttributes(serviceData) {
// const { service, title, text } = serviceData;
// return {
// ...BUTTON_ATTRIBUTES,
// title,
// text,
// rel:
// service === 'google' || service === 'yahoo'
// ? 'noopener norefferrer'
// : null,
// linkTarget:
// service === 'google' || service === 'yahoo' ? '_blank' : null,
// placeholder: text,
// metadata: {
// bindings: {
// url: {
// source: 'gatherpress/add-to-calendar',
// args: { service },
// },
// },
// name: text,
// },
// };
// }

/**
* Registers multiple block variations of the 'core/button' block, one per each calendar service.
*
* @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-variations/
*/
SERVICES.forEach((serviceData) => {
const attributes = createButtonAttributes(serviceData);
// /**
// * Registers multiple block variations of the 'core/button' block, one per each calendar service.
// *
// * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-variations/
// */
// SERVICES.forEach((serviceData) => {
// const attributes = createButtonAttributes(serviceData);

registerBlockVariation('core/button', {
...VARIATION_ATTRIBUTES,
name: `${NAME}-${serviceData.service}`,
title: serviceData.text,
description: serviceData.title,
attributes,
});
});
// registerBlockVariation('core/button', {
// ...VARIATION_ATTRIBUTES,
// name: `${NAME}-${serviceData.service}`,
// title: serviceData.text,
// description: serviceData.title,
// attributes,
// });
// });

// Generate innerBlocks array dynamically based on the services.
const INNER_BLOCKS = SERVICES.map((serviceData) => [
'core/button',
createButtonAttributes(serviceData),
]);
// // Generate innerBlocks array dynamically based on the services.
// const INNER_BLOCKS = SERVICES.map((serviceData) => [
// 'core/button',
// createButtonAttributes(serviceData),
// ]);

/**
* A Trap block, that looks like a single button, hohoho.
*
* This block-variation is only useful, because a user can pick the block directly from the inserter or the left sidebar.
*
* @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-variations/
*/
// /**
// * A Trap block, that looks like a single button, hohoho.
// *
// * This block-variation is only useful, because a user can pick the block directly from the inserter or the left sidebar.
// *
// * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-variations/
// */
// registerBlockVariation('core/buttons', {
// title: __('Add to calendar (BUTTONS)', 'gatherpress'),
// description: __(
Expand Down

0 comments on commit e62745a

Please sign in to comment.