-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Save/output/preview templates with units and wrappers.
- Loading branch information
Showing
5 changed files
with
71 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as SavePage } from './savePage'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import StoryPropTypes from '../../../types'; | ||
import { getDefinitionForType } from '../../../elements'; | ||
import { getBox } from '../../../units/dimensions'; | ||
|
||
function SaveElement( { element } ) { | ||
const { id, type } = element; | ||
|
||
// eslint-disable-next-line @wordpress/no-unused-vars-before-return | ||
const { Save } = getDefinitionForType( type ); | ||
|
||
// eslint-disable-next-line @wordpress/no-unused-vars-before-return | ||
const { x, y, width, height, rotationAngle } = getBox( element, 100, 100 ); | ||
|
||
return ( | ||
<div | ||
id={ 'el-' + id } | ||
style={ { | ||
position: 'absolute', | ||
left: `${ x }%`, | ||
top: `${ y }%`, | ||
width: `${ width }%`, | ||
height: `${ height }%`, | ||
transform: rotationAngle ? `rotate(${ rotationAngle }deg)` : null, | ||
} }> | ||
<Save element={ element } /> | ||
</div> | ||
); | ||
} | ||
|
||
SaveElement.propTypes = { | ||
element: StoryPropTypes.element.isRequired, | ||
}; | ||
|
||
export default SaveElement; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import StoryPropTypes from '../../../types'; | ||
import SaveElement from './saveElement'; | ||
|
||
function SavePage( { page } ) { | ||
const { id } = page; | ||
return ( | ||
<amp-story-page id={ id }> | ||
<amp-story-grid-layer template="vertical"> | ||
{ page.elements.map( ( element ) => { | ||
const { id: elId } = element; | ||
return ( | ||
<SaveElement key={ 'el-' + elId } element={ element } /> | ||
); | ||
} ) } | ||
</amp-story-grid-layer> | ||
</amp-story-page> | ||
); | ||
} | ||
|
||
SavePage.propTypes = { | ||
page: StoryPropTypes.page.isRequired, | ||
}; | ||
|
||
export default SavePage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters