-
Notifications
You must be signed in to change notification settings - Fork 383
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 sub-task] Grid layers layout #1347
Changes from 7 commits
de8a1c5
954c14e
87cca23
9d79e01
6ec83eb
83d2c34
2774a1a
c7951bd
4fa18d3
bfdefb9
cd4d801
b9b410c
e5c84d0
912439d
6ff0bf6
b486847
b7afb23
dc87187
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,56 @@ | ||
div[data-type="amp/amp-story-page"] { | ||
border: 1px solid #ffdddd; | ||
} | ||
|
||
.editor-block-list__layout { | ||
background-color: #ffdddd; | ||
div[data-type="amp/amp-story-page"], | ||
div[data-type="amp/amp-story-page"] .editor-inner-blocks .editor-block-list__layout { | ||
min-height: 450px; | ||
} | ||
.editor-block-list__layout .editor-block-list__layout { | ||
background-color: white; | ||
div[data-type="amp/amp-story-page"] .editor-inner-blocks .editor-block-list__layout .editor-block-list__layout { | ||
background-color: initial; | ||
min-height: initial; | ||
} | ||
div[data-type="amp/amp-story-page"] { | ||
background-color: #ddffdd; | ||
|
||
.editor-block-list__layout div[data-type="amp/amp-story-grid-layer"] { | ||
position: absolute; | ||
height: 100%; | ||
width: 100%; | ||
} | ||
|
||
.editor-block-list__layout div[data-type="amp/amp-story-cta-layer"] { | ||
position: absolute; | ||
height: 20%; | ||
width: 100%; | ||
bottom: 0; | ||
} | ||
|
||
.editor-block-list__layout div[data-type="amp/amp-story-grid-layer"], | ||
.editor-block-list__layout div[data-type="amp/amp-story-cta-layer"] { | ||
border: 1px solid #ddffdd; | ||
} | ||
div[data-type="amp/amp-story-grid-layer"] { | ||
background-color: #ddddff; | ||
|
||
.editor-block-list__layout div[data-type="amp/amp-story-grid-layer"].is-selected ~ div[data-type="amp/amp-story-grid-layer"], | ||
.editor-block-list__layout div[data-type="amp/amp-story-grid-layer"].is-selected-parent ~ div[data-type="amp/amp-story-grid-layer"]{ | ||
display: none; | ||
} | ||
|
||
.editor-selectors { | ||
position: absolute; | ||
right: -150px; | ||
bottom: 0px; | ||
width: 100px; | ||
z-index: 80; | ||
} | ||
|
||
.editor-selectors .component-editor__selector { | ||
margin-bottom: 2px; | ||
} | ||
|
||
.editor-selectors .component-editor__selector a { | ||
color: #656565; | ||
font-size: 13px; | ||
} | ||
|
||
.editor-selectors .is-selected.component-editor__selector a { | ||
text-decoration: underline; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import forEachRight from 'lodash'; // eslint-disable-line no-unused-vars | ||
|
||
const { Component } = wp.element; | ||
const { getBlockType } = wp.blocks; | ||
const { | ||
dispatch, | ||
select | ||
} = wp.data; | ||
const { | ||
getBlock, | ||
isBlockSelected, | ||
hasSelectedInnerBlock, | ||
getSelectedBlock | ||
} = select( 'core/editor' ); | ||
const { | ||
selectBlock | ||
} = dispatch( 'core/editor' ); | ||
|
||
class BlockSelector extends Component { | ||
render() { | ||
if ( ! this.props.rootClientId ) { | ||
return null; | ||
} | ||
|
||
const rootBlock = getBlock( this.props.rootClientId ); | ||
|
||
if ( ! rootBlock.innerBlocks.length ) { | ||
return null; | ||
} | ||
|
||
let links = []; | ||
|
||
_.forEachRight( rootBlock.innerBlocks, function( block, index ) { | ||
let className = 'component-editor__selector'; | ||
if ( isBlockSelected( block.clientId ) || hasSelectedInnerBlock( block.clientId ) ) { | ||
className += ' is-selected'; | ||
} | ||
let blockType = getBlockType( block.name ); | ||
links.push( | ||
<li className={ className } key={ 'selector-' + index }> | ||
<a onClick={ ( e ) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's have this be a |
||
e.stopPropagation(); | ||
if ( getSelectedBlock.clientId !== block.clientId ) { | ||
// @todo This selects the first inner child instead for some reason. | ||
selectBlock( block.clientId ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @westonruter For some reason There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know why. Is this why I am unable to insert a grid layer upon selecting the page? |
||
} | ||
}}>{ blockType.title }</a> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can just be “Layer” perhaps. In the end, I don't think that we'll be displaying the label and that we'd just have an icon instead, with perhaps a tooltip. |
||
</li> | ||
); | ||
} ); | ||
|
||
let className = 'component-editor__selector'; | ||
if ( isBlockSelected( this.props.rootClientId ) ) { | ||
className += ' is-selected'; | ||
} | ||
|
||
links.push( | ||
<li className={ className } key='page-selector'> | ||
<a onClick={ () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per above, this should be |
||
selectBlock( this.props.rootClientId ); | ||
}}>Page</a> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. “Page” here needs to be translatable. |
||
</li> | ||
); | ||
|
||
return ( | ||
<ul className="editor-selectors"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably be an |
||
{ links } | ||
</ul> | ||
); | ||
} | ||
} | ||
|
||
export default BlockSelector; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On desktop an AMP story has the following style rule:
Would that ensure that the page is displayed with the right aspect ratio and dimensions?