这是indexloc提供的服务,不要输入任何密码
Skip to content

Add deprecation rule for showcase block #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
222 changes: 147 additions & 75 deletions blocks/build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,94 +417,102 @@ var __ = wp.i18n.__;
var registerBlockType = wp.blocks.registerBlockType;


var attributes = {

showCaseTitle: {
type: 'array',
field: {
type: 'rich-text',
className: 'showcase-title',
placeholder: __('Showcase Title'),
tagName: 'h3',
inlineToolbar: false
},
selector: '.showcase-title',
source: 'children'
},

showCaseContent: {
type: 'array',
field: {
type: 'rich-text',
className: 'showcase-content',
placeholder: __('Showcase description'),
tagName: 'div',
multiline: 'p',
inlineToolbar: false
},
selector: '.showcase-content',
source: 'children'
},

showCaseImage: {
type: 'object',
field: {
type: 'image',
buttonText: __('Upload'),
inputUrl: false,
imagePlaceholder: true,
removeButtonText: __('Remove')
}
},

showCaseLink: {
type: 'string',
field: {
type: 'link',
placement: 'inspector',
label: __('Showcase link')
}
}

};

var edit = function edit(props, middleware) {
var showCaseLink = props.attributes.showCaseLink;


var className = props.className ? props.className : '';

return wp.element.createElement(
'div',
{ className: className + ' showcase-wrapper alignwide' },
wp.element.createElement(
'div',
{ className: 'image-container' },
middleware.fields.showCaseImage
),
wp.element.createElement(
'div',
{ className: 'info-container' },
middleware.inspectorControls,
middleware.fields.showCaseTitle,
middleware.fields.showCaseContent,
showCaseLink ? wp.element.createElement(
'a',
{ href: showCaseLink, title: __('Read More'), className: 'button secondary' },
__('Read More')
) : ''
)
);
};

registerBlockType('rtgb/showcase', {

title: __('Showcase'),
icon: 'portfolio',
category: 'layout',
description: __('Use for showcase'),

attributes: {

showCaseTitle: {
type: 'array',
field: {
type: 'rich-text',
className: 'showcase-title',
placeholder: __('Showcase Title'),
tagName: 'h3',
inlineToolbar: false
},
selector: '.showcase-title',
source: 'children'
},

showCaseContent: {
type: 'array',
field: {
type: 'rich-text',
className: 'showcase-content',
placeholder: __('Showcase description'),
tagName: 'div',
multiline: 'p',
inlineToolbar: false
},
selector: '.showcase-content',
source: 'children'
},

showCaseImage: {
type: 'object',
field: {
type: 'image',
buttonText: __('Upload'),
inputUrl: false,
imagePlaceholder: true,
removeButtonText: __('Remove')
}
},

showCaseLink: {
type: 'string',
field: {
type: 'link',
placement: 'inspector',
label: __('Showcase link')
}
}
},
attributes: attributes,

getEditWrapperProps: function getEditWrapperProps() {
return { 'data-align': 'wide' };
},
edit: function edit(props, middleware) {
var showCaseLink = props.attributes.showCaseLink;


var className = props.className ? props.className : '';
edit: edit,

return wp.element.createElement(
'div',
{ className: className + ' showcase-wrapper alignwide' },
wp.element.createElement(
'div',
{ className: 'image-container' },
middleware.fields.showCaseImage
),
wp.element.createElement(
'div',
{ className: 'info-container' },
middleware.inspectorControls,
middleware.fields.showCaseTitle,
middleware.fields.showCaseContent,
showCaseLink ? wp.element.createElement(
'a',
{ href: showCaseLink, title: __('Read More'), className: 'button secondary' },
__('Read More')
) : ''
)
);
},
save: function save(props) {
var _props$attributes = props.attributes,
showCaseImage = _props$attributes.showCaseImage,
Expand Down Expand Up @@ -566,7 +574,71 @@ registerBlockType('rtgb/showcase', {
) : ''
)
);
}
},


deprecated: [{
attributes: attributes,
edit: edit,
save: function save(props) {
var _props$attributes2 = props.attributes,
showCaseImage = _props$attributes2.showCaseImage,
showCaseTitle = _props$attributes2.showCaseTitle,
showCaseContent = _props$attributes2.showCaseContent,
showCaseLink = _props$attributes2.showCaseLink;


var className = props.className ? props.className : '';
var imageContent = '';

if (showCaseImage) {
var imageSrc = wp.element.createElement(
'figure',
null,
wp.element.createElement('img', { src: showCaseImage.url, alt: showCaseImage.title })
);

imageContent = wp.element.createElement(
'div',
{ className: 'image-container' },
imageSrc
);
}

return wp.element.createElement(
'div',
{ className: className + ' showcase-wrapper alignwide' },
imageContent,
wp.element.createElement(
'div',
{ className: 'info-container' },
showCaseLink ? wp.element.createElement(
'h3',
null,
wp.element.createElement(
'a',
{ href: showCaseLink, className: 'showcase-title' },
showCaseTitle
)
) : wp.element.createElement(
'h3',
{ className: 'showcase-title' },
showCaseTitle
),
wp.element.createElement(
'div',
{ className: 'showcase-content' },
showCaseContent
),
showCaseLink ? wp.element.createElement(
'a',
{ href: showCaseLink, title: __('Read More'), className: 'button secondary' },
__('Read More')
) : ''
)
);
}
}]
});

/***/ }),
Expand Down
Loading