Skip to content
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

[AMP Stories] Add template Inserter #2029

Merged
merged 25 commits into from
Apr 1, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
bf424fc
Start adding template inserter.
miina Mar 25, 2019
7e0b682
Make template inserter (kind of) functional.
miina Mar 26, 2019
738d975
Improve style.
miina Mar 26, 2019
1932e3f
Improve API request.
miina Mar 26, 2019
9273dc0
Remove unused params.
miina Mar 26, 2019
f0b70f9
Rework getting reusable blocks.
miina Mar 27, 2019
1306f9c
Remove unused code.
miina Mar 27, 2019
8ae5c64
Style adjustments.
miina Mar 27, 2019
3c43aeb
Add icons for the template inserter and reordering.
miina Mar 28, 2019
7eb3a3e
Allow saving custom templates.
miina Mar 28, 2019
24bf37c
Update dashicon.
miina Mar 28, 2019
364a61f
Prevent endless loading.
miina Mar 28, 2019
3a53207
Merge remote-tracking branch 'origin/amp-stories-redux' into amp-stor…
miina Mar 28, 2019
788d22d
Style fix.
miina Mar 28, 2019
46834cf
Add todo notice.
miina Mar 29, 2019
4f3baf5
Use pre-existing pageIcon file
swissspidy Apr 1, 2019
9f4d919
Use pre-existing BlockPreview component
swissspidy Apr 1, 2019
de77363
Extract all SVGs into separate files
swissspidy Apr 1, 2019
379d51d
Fix reorder cancel button styling
swissspidy Apr 1, 2019
6859bfd
ESLint fix
swissspidy Apr 1, 2019
cdec4ae
Merge branch 'amp-stories-redux' into amp-story/1902-template_inserter
swissspidy Apr 1, 2019
abd0879
Remove unused import after merge
swissspidy Apr 1, 2019
d72d6ee
Add role to PluginBlockSettingsMenuItem
swissspidy Apr 1, 2019
53def88
Remove allowedBlockNames todo
swissspidy Apr 1, 2019
a5ee722
Rename allowedBlockNames to allowedBlocks as per upstream discussion
swissspidy Apr 1, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ import { Disabled } from '@wordpress/components';
import { BlockEdit } from '@wordpress/editor';

/**
* BlockPreview component that is used within the reordering UI.
* Block Preview Component: It renders a preview given a block name and attributes.
*
* @return {Object} Block preview.
* @param {Object} props Component props.
*
* @return {WPElement} Rendered element.
*/
const BlockPreview = ( { clientId, name, attributes, innerBlocks } ) => {
const BlockPreview = ( { clientId, name, attributes, innerBlocks = [] } ) => {
const block = createBlock( name, attributes, innerBlocks );
return (
<Disabled className="editor-block-preview__content editor-styles-wrapper" aria-hidden>
<Disabled className="block-editor-block-preview__content editor-styles-wrapper" aria-hidden>
<BlockEdit
name={ name }
focus={ false }
Expand Down
2 changes: 1 addition & 1 deletion assets/src/components/editor-carousel/reorderer-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { withDispatch, withSelect } from '@wordpress/data';
/**
* Internal dependencies
*/
import BlockPreview from './block-preview';
import { BlockPreview } from '../';

/**
* Parses drag & drop events to ensure the event contains valid transfer data.
Expand Down
1 change: 1 addition & 0 deletions assets/src/components/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export { default as AnimationControls } from './animation-controls';
export { default as AnimationOrderPicker } from './animation-order-picker';
export { default as BlockNavigation } from './block-navigation';
export { default as BlockPreview } from './block-preview';
export { default as EditorCarousel } from './editor-carousel';
export { default as StoryControls } from './story-controls';
export { default as Shortcuts } from './shortcuts';
Expand Down
48 changes: 0 additions & 48 deletions assets/src/components/template-inserter/block-preview.js

This file was deleted.

20 changes: 12 additions & 8 deletions assets/src/components/template-inserter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { Dropdown, IconButton } from '@wordpress/components';
import { Dropdown, IconButton, Button } from '@wordpress/components';
import { Component } from '@wordpress/element';
import { withSelect, withDispatch } from '@wordpress/data';
import { createBlock, cloneBlock } from '@wordpress/blocks';
Expand All @@ -11,7 +11,7 @@ import { compose } from '@wordpress/compose';
/**
* Internal dependencies
*/
import BlockPreview from './block-preview';
import { BlockPreview } from '../';
import pageIcon from '../../../images/add-page-inserter.svg';
import { ICONS } from './../../constants';

Expand Down Expand Up @@ -102,16 +102,20 @@ class TemplateInserter extends Component {
className="amp-stories__blank-page-inserter editor-block-preview__content block-editor-block-preview__content editor-styles-wrapper"
/>
</div>
{ storyTemplates && storyTemplates.map( ( item ) =>
<BlockPreview
{ storyTemplates && storyTemplates.map( ( item ) => (
<Button
swissspidy marked this conversation as resolved.
Show resolved Hide resolved
key={ `template-preview-${ item.id }` }
name="core/block"
attributes={ { ref: item.id } }
onClick={ () => {
onSelect( item );
} }
/>
) }
className="components-button block-editor-block-preview"
>
<BlockPreview
name="core/block"
attributes={ { ref: item.id } }
/>
</Button>
) ) }
</div>
</div>
</div>
Expand Down