-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
248 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// See https://doc.ibexa.co/en/3.3/extending/import_assets_from_bundle/#configuration-from-main-project-files | ||
const path = require('path'); | ||
|
||
module.exports = (eZConfig, eZConfigManager) => { | ||
// Edit | ||
eZConfigManager.add({ | ||
eZConfig, | ||
entryName: 'ezplatform-admin-ui-content-edit-parts-js', | ||
newItems: [ | ||
path.resolve(__dirname, '../public/js/elbformat-icon-edit.js') | ||
] | ||
}); | ||
eZConfigManager.add({ | ||
eZConfig, | ||
entryName: 'ezplatform-admin-ui-content-edit-parts-css', | ||
newItems: [ | ||
path.resolve(__dirname, '../public/css/elbformat-icon-edit.css') | ||
] | ||
}); | ||
// Preview | ||
eZConfigManager.add({ | ||
eZConfig, | ||
entryName: 'ezplatform-admin-ui-layout-css', | ||
newItems: [ | ||
path.resolve(__dirname, '../public/css/elbformat-icon-preview.css') | ||
] | ||
}); | ||
|
||
}; |
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,84 @@ | ||
/* Inspired by https://codepen.io/giannisrig/pen/ywBWOV */ | ||
.elbformat-icon-select { | ||
display: none; | ||
} | ||
.icon-dropdown-wrapper { | ||
width: 100%; | ||
max-width: 34.375rem; | ||
height: calc(1.5em + 0.75rem + 2px); | ||
position: relative; | ||
border:1px solid #878b90; | ||
} | ||
.icon-dropdown-wrapper .icon-dropdown-trigger { | ||
width: 100%; | ||
height: 100%; | ||
background-color: #fff; | ||
border: 0; | ||
padding: 2px 10px; | ||
transition: 0.2s ease-in; | ||
cursor:pointer; | ||
text-align: left; | ||
} | ||
.icon-dropdown-wrapper .icon-dropdown-trigger::before { | ||
content: '˅'; | ||
position: absolute; | ||
top: 7px; | ||
right: 10px; | ||
} | ||
.icon-dropdown-wrapper.open .icon-dropdown-trigger::before { | ||
top: 5px; | ||
right: 10px; | ||
transform: rotate(180deg); | ||
} | ||
.icon-dropdown-wrapper .icon-dropdown-trigger .icon-container { | ||
width: 50px; | ||
height: 30px; | ||
padding-right: 10px; | ||
display: inline-block; | ||
} | ||
|
||
.icon-dropdown-wrapper .icon-dropdown-list { | ||
width: 100%; | ||
display:none; | ||
z-index: 1; | ||
position: absolute; | ||
background-color: #fff; | ||
left: 0; | ||
top: 37px; | ||
box-shadow: 0 4px 5px 0 rgba(0, 0, 0, 0.14), 0 1px 10px 0 rgba(0, 0, 0, 0.12), 0 2px 4px -1px rgba(0, 0, 0, 0.3); | ||
max-height: 300px; | ||
overflow: scroll; | ||
} | ||
.icon-dropdown-wrapper.open .icon-dropdown-list { | ||
display:block; | ||
} | ||
|
||
.icon-dropdown-wrapper .icon-dropdown-trigger button, | ||
.icon-dropdown-wrapper .icon-dropdown-list button { | ||
width: 100%; | ||
height: 54px; | ||
line-height: 54px; | ||
border: 0; | ||
padding: 2px 10px; | ||
cursor: pointer; | ||
transition:0.2s ease-in; | ||
text-align: left; | ||
overflow: hidden; | ||
} | ||
.icon-dropdown-wrapper .icon-dropdown-list button:hover { | ||
background-color:#e5e5e5; | ||
} | ||
.icon-dropdown-wrapper .icon-dropdown-list button:not(:last-child){ | ||
border-bottom: 1px solid #e5e5e5; | ||
} | ||
.icon-dropdown-wrapper .icon-dropdown-list .icon-container { | ||
width: 50px; | ||
height: 50px; | ||
padding-right: 10px; | ||
display: inline-block; | ||
} | ||
.icon-dropdown-wrapper .icon-dropdown-trigger .icon-container img, | ||
.icon-dropdown-wrapper .icon-dropdown-list .icon-container img { | ||
max-width: 90%; | ||
max-height: 90%; | ||
} |
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,12 @@ | ||
.ez-content-preview .elbformat-icon { | ||
text-align: left; | ||
} | ||
.ez-content-preview .elbformat-icon .icon-container { | ||
height: 18px; | ||
width: 30px; | ||
display: inline-block; | ||
} | ||
.ez-content-preview .elbformat-icon .icon-container img { | ||
max-height: 90%; | ||
max-width: 90%; | ||
} |
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,60 @@ | ||
// Inspired by https://codepen.io/giannisrig/pen/ywBWOV | ||
window.addEventListener('load', function() { | ||
document.querySelectorAll('.elbformat-icon-select').forEach((iconDropdown) => { | ||
// Hidden field to carry the form data | ||
let hiddenField = document.createElement('input'); | ||
hiddenField.setAttribute('type','hidden'); | ||
hiddenField.setAttribute('name', iconDropdown.getAttribute('name')); | ||
let value = iconDropdown.value || ''; | ||
hiddenField.setAttribute('value', value); | ||
iconDropdown.after(hiddenField); | ||
|
||
// Wrapper for new widget | ||
let wrapper = document.createElement('div'); | ||
wrapper.classList.add('icon-dropdown-wrapper'); | ||
iconDropdown.after(wrapper); | ||
|
||
let button = document.createElement('button'); | ||
button.classList.add('icon-dropdown-trigger'); | ||
wrapper.appendChild(button); | ||
let iconList = document.createElement('div'); | ||
iconList.classList.add('icon-dropdown-list'); | ||
wrapper.appendChild(iconList); | ||
|
||
// Extract icons | ||
let items = JSON.parse(iconDropdown.getAttribute('data-choices')); | ||
for (const [key, tmpl] of Object.entries(items)) { | ||
let container = document.createElement('button'); | ||
container.setAttribute('value', key) | ||
let iconContainer = document.createElement('div'); | ||
iconContainer.classList.add('icon-container'); | ||
iconContainer.innerHTML = tmpl; | ||
container.appendChild(iconContainer); | ||
container.innerHTML+=key | ||
iconList.appendChild(container); | ||
if (value===key) { | ||
button.innerHTML = container.innerHTML; | ||
} | ||
// Click on entry | ||
container.addEventListener('click',(e) => { | ||
button.innerHTML = container.innerHTML; | ||
hiddenField.value = key; | ||
wrapper.classList.remove('open'); | ||
e.preventDefault(); | ||
return false; | ||
}); | ||
}; | ||
|
||
// Open/Close | ||
button.addEventListener('click',(e) => { | ||
if (wrapper.classList.contains('open')) { | ||
wrapper.classList.remove('open'); | ||
} else { | ||
wrapper.classList.add('open'); | ||
} | ||
e.preventDefault(); | ||
return false; | ||
}); | ||
}); | ||
|
||
}); |
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
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
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
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,6 +1,11 @@ | ||
{% block icon_field %} | ||
{{ include('@ElbformatIconFieldtype/icon.html.twig', { | ||
icon: field.value.icon, | ||
iconset: fieldSettings.iconset | ||
}, with_context=false) }} | ||
<div class="elbformat-icon"> | ||
<div class="icon-container"> | ||
{{ include('@ElbformatIconFieldtype/icon.html.twig', { | ||
icon: field.value.icon, | ||
iconset: fieldSettings.iconset | ||
}, with_context=false) }} | ||
</div> | ||
{{ field.value.icon }} | ||
</div> | ||
{% endblock %} |