Skip to content
Merged
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
19 changes: 15 additions & 4 deletions extensions/blocks/calendly/calendly.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ function set_availability() {
* @return string
*/
function load_assets( $attr, $content ) {
if ( is_admin() ) {
return;
}
$url = get_attribute( $attr, 'url' );
if ( empty( $url ) ) {
return;
Expand All @@ -93,7 +96,7 @@ function load_assets( $attr, $content ) {
'https://assets.calendly.com/assets/external/widget.js',
null,
JETPACK__VERSION,
false
true
);

$style = get_attribute( $attr, 'style' );
Expand All @@ -105,7 +108,7 @@ function load_assets( $attr, $content ) {
$submit_button_classes = get_attribute( $attr, 'submitButtonClasses' );
$submit_button_text_color = get_attribute( $attr, 'customTextButtonColor' );
$submit_button_background_color = get_attribute( $attr, 'customBackgroundButtonColor' );
$classes = \Jetpack_Gutenberg::block_classes( 'calendly', $attr );
$classes = \Jetpack_Gutenberg::block_classes( 'calendly', $attr, array( 'calendly-style-' . $style ) );
$block_id = wp_unique_id( 'calendly-block-' );

$url = add_query_arg(
Expand Down Expand Up @@ -150,10 +153,18 @@ function load_assets( $attr, $content ) {
);
} else { // Inline style.
$content = sprintf(
'<div class="calendly-inline-widget %1$s" data-url="%2$s" style="min-width:320px;height:630px;"></div>',
'<div class="%1$s" id="%2$s"></div>',
esc_attr( $classes ),
esc_url( $url )
esc_attr( $block_id )
);
$script = <<<JS_END
Calendly.initInlineWidget({
url: '%s',
parentElement: document.getElementById('%s'),
inlineStyles: false,
});
JS_END;
wp_add_inline_script( 'jetpack-calendly-external-js', sprintf( $script, esc_url( $url ), esc_js( $block_id ) ) );
}

return $content;
Expand Down
6 changes: 4 additions & 2 deletions extensions/blocks/calendly/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { getBlockDefaultClassName } from '@wordpress/blocks';
* Internal dependencies
*/
import './editor.scss';
import './view.scss';
import icon from './icon';
import attributeDetails from './attributes';
import { getValidatedAttributes } from '../../shared/get-validated-attributes';
Expand Down Expand Up @@ -147,7 +148,6 @@ export default function CalendlyEdit( props ) {
frameBorder="0"
data-origwidth="100%"
data-origheight="100%"
style={ { minWidth: '320px', height: '630px', width: '100%' } }
title="Calendly"
></iframe>
</>
Expand Down Expand Up @@ -257,8 +257,10 @@ export default function CalendlyEdit( props ) {
</InspectorControls>
);

const classes = `${ className } calendly-style-${ style }`;

return (
<div className={ className }>
<div className={ classes }>
{ inspectorControls }
{ blockControls }
{ url ? blockPreview( style ) : blockPlaceholder }
Expand Down
4 changes: 4 additions & 0 deletions extensions/blocks/calendly/view.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.admin-bar .calendly-overlay .calendly-popup-close {
top: 47px;
}

.wp-block-jetpack-calendly.calendly-style-inline {
height: 630px;
}