-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Internal: Header/Footer templates-api [TMZ-276] (#151)
- Loading branch information
1 parent
cc88cd2
commit 9f1652a
Showing
18 changed files
with
416 additions
and
19 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
@import "./breakpoints"; | ||
@import "./values"; | ||
@import "./global-colors"; | ||
@import "./mixins"; |
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,30 @@ | ||
@mixin ellipsis { | ||
white-space: nowrap; | ||
text-overflow: ellipsis; | ||
overflow: hidden; | ||
} | ||
|
||
@mixin absolute-center { | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
} | ||
|
||
@mixin start($value) { | ||
body.rtl & { | ||
right: $value; | ||
} | ||
body:not(.rtl) & { | ||
left: $value; | ||
} | ||
} | ||
|
||
@mixin end($value) { | ||
body.rtl & { | ||
left: $value; | ||
} | ||
body:not(.rtl) & { | ||
right: $value; | ||
} | ||
} |
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
42 changes: 42 additions & 0 deletions
42
modules/template-parts/assets/js/editor/hooks/ui/add-library-tab.js
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,42 @@ | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
export class EhpAddLibraryTab extends $e.modules.hookUI.Before { | ||
getCommand() { | ||
return 'library/open'; | ||
} | ||
|
||
getId() { | ||
return 'ehp-add-library-tab'; | ||
} | ||
|
||
getConditions() { | ||
return [ 'ehp-header', 'ehp-footer' ].includes( elementor?.config?.document?.type ); | ||
} | ||
|
||
getTitle() { | ||
switch ( elementor?.config?.document?.type ) { | ||
case 'ehp-header': | ||
return __( 'Hello+ Header', 'hello-plus' ); | ||
case 'ehp-footer': | ||
return __( 'Hello+ Footer', 'hello-plus' ); | ||
default: | ||
return __( 'Hello Plus', 'elementor' ); | ||
} | ||
} | ||
|
||
apply() { | ||
$e.components.get( 'library' ).addTab( 'templates/ehp-elements', { | ||
title: this.getTitle(), | ||
filter: { | ||
source: 'remote-ehp', | ||
type: 'block', | ||
subtype: elementor?.config?.document?.type, | ||
}, | ||
}, 2 ); | ||
|
||
$e.components.get( 'library' ).removeTab( 'templates/blocks' ); | ||
$e.components.get( 'library' ).removeTab( 'templates/pages' ); | ||
} | ||
} | ||
|
||
export default EhpAddLibraryTab; |
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 |
---|---|---|
@@ -1,2 +1,5 @@ | ||
export { SelectEhpElementOnOpen } from './attach-preview'; | ||
export { SelectAfterContainer } from './select'; | ||
export { EhpAddLibraryTab } from './add-library-tab'; | ||
export { EhpRemoveLibraryTab } from './remove-library-tab'; | ||
export { EhpOpenLibraryAfterDelete } from './open-library-after-delete'; |
24 changes: 24 additions & 0 deletions
24
modules/template-parts/assets/js/editor/hooks/ui/open-library-after-delete.js
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,24 @@ | ||
export class EhpOpenLibraryAfterDelete extends $e.modules.hookUI.After { | ||
getCommand() { | ||
return 'document/elements/delete'; | ||
} | ||
|
||
getId() { | ||
return 'ehp-open-library-after-delete'; | ||
} | ||
|
||
getConditions( args ) { | ||
let type = args?.container?.document?.config?.type; | ||
if ( ! type ) { | ||
type = args?.containers[ 0 ]?.document?.config?.type; | ||
} | ||
|
||
return [ 'ehp-header', 'ehp-footer' ].includes( type ); | ||
} | ||
|
||
apply() { | ||
$e.run( 'library/open' ); | ||
} | ||
} | ||
|
||
export default EhpOpenLibraryAfterDelete; |
23 changes: 23 additions & 0 deletions
23
modules/template-parts/assets/js/editor/hooks/ui/remove-library-tab.js
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,23 @@ | ||
export class EhpRemoveLibraryTab extends $e.modules.hookUI.After { | ||
getCommand() { | ||
return 'editor/documents/unload'; | ||
} | ||
|
||
getId() { | ||
return 'ehp-remove-library-tab'; | ||
} | ||
|
||
getConditions( args ) { | ||
const document = elementor.documents.get( args.id ); | ||
return [ 'ehp-header', 'ehp-footer' ].includes( document.config.type ); | ||
} | ||
|
||
apply() { | ||
$e.components.get( 'library' ).removeTab( 'templates/ehp-elements' ); | ||
|
||
$e.components.get( 'library' ).addTab( 'templates/pages' ); | ||
$e.components.get( 'library' ).addTab( 'templates/blocks' ); | ||
} | ||
} | ||
|
||
export default EhpRemoveLibraryTab; |
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,3 @@ | ||
@import "../../../../assets/dev/scss/variables"; | ||
@import 'editor/_template-modal'; | ||
@import 'editor/_hello-plus-template-parts-preview'; |
File renamed without changes.
159 changes: 159 additions & 0 deletions
159
modules/template-parts/assets/scss/editor/_template-modal.scss
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,159 @@ | ||
$remote-templates-items-space: 30px; | ||
|
||
.elementor-template-library-template-remote-ehp { | ||
margin: calc( #{$remote-templates-items-space} / 2 ); | ||
padding: 8px; | ||
border: var(--e-a-border); | ||
border-radius: 3px; | ||
|
||
&:hover { | ||
background-color: var(--e-a-bg-hover); | ||
|
||
.elementor-template-library-template-name { | ||
display: none; | ||
} | ||
} | ||
|
||
&:not(:hover) { | ||
|
||
.elementor-template-library-template-preview { | ||
opacity: 0; | ||
} | ||
|
||
.elementor-template-library-favorite, | ||
.elementor-template-library-template-action { | ||
display: none; | ||
} | ||
} | ||
|
||
&.elementor-template-library-pro-template { | ||
|
||
.elementor-template-library-template-body:before { | ||
content: var( --elementor-template-library-subscription-plan-label ); | ||
background-color: var(--e-a-color-accent); | ||
color: var(--e-a-color-white); | ||
position: absolute; | ||
text-transform: uppercase; | ||
line-height: 1; | ||
top: 5px; | ||
@include end(5px); | ||
padding: 3px 5px; | ||
font-size: 8px; | ||
border-radius: 2px; | ||
} | ||
} | ||
|
||
// For blocks | ||
&:not(.elementor-template-library-template-page):not(.elementor-template-library-template-lp) { | ||
position: relative; | ||
width: calc(33.333% - #{$remote-templates-items-space}); | ||
overflow: hidden; | ||
|
||
img { | ||
display: block; | ||
width: 100%; | ||
} | ||
|
||
.elementor-template-library-template-footer { | ||
position: absolute; | ||
width: 100%; | ||
bottom: 0; | ||
@include start(0); | ||
padding: 10px; | ||
background-color: var(--e-a-bg-default); | ||
transition: transform .5s; | ||
} | ||
|
||
.elementor-template-library-template-name { | ||
display: none; | ||
} | ||
|
||
&:not(:hover) { | ||
|
||
.elementor-template-library-template-footer { | ||
transform: translateY(100%) | ||
} | ||
} | ||
} | ||
|
||
.elementor-template-library-template-body { | ||
position: relative; | ||
} | ||
|
||
@media (max-width: $editor-screen-lg-min) { | ||
|
||
.elementor-template-library-template-body { | ||
height: 300px; | ||
} | ||
} | ||
|
||
.elementor-template-library-template-screenshot { | ||
height: 100%; | ||
background-size: cover; | ||
background-position-x: 50%; | ||
box-shadow: inset 0px -2px 15px -6px rgba(0, 0, 0, 0.07); | ||
} | ||
|
||
.elementor-template-library-template-preview { | ||
position: absolute; | ||
inset: 0; | ||
background-color: rgba(0,0,0,.5); | ||
transition: opacity .5s; | ||
cursor: pointer; | ||
|
||
i { | ||
font-size: 20px; | ||
@include absolute-center; | ||
} | ||
} | ||
|
||
.elementor-template-library-template-footer { | ||
display: flex; | ||
justify-content: space-between; | ||
font-size: 11px; | ||
line-height: 1; | ||
height: 40px; | ||
align-items: center; | ||
} | ||
|
||
.elementor-template-library-template-name { | ||
text-align: start; | ||
flex-grow: 1; | ||
@include ellipsis; | ||
padding-inline-end: 5px; | ||
} | ||
|
||
.elementor-template-library-favorite { | ||
margin-inline-start: auto; | ||
} | ||
|
||
.elementor-template-library-template-favorite-input { | ||
display: none; | ||
|
||
&:checked { | ||
|
||
+ .elementor-template-library-template-favorite-label { | ||
|
||
i { | ||
|
||
&:before { | ||
content: '\e93f'; | ||
color: var(--e-a-color-primary-bold); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
.elementor-template-library-template-favorite-label { | ||
font-size: 15px; | ||
cursor: pointer; | ||
|
||
&:hover { | ||
|
||
i { | ||
color: var(--e-a-color-primary-bold); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.