adapt block too, add to changelog
This commit is contained in:
parent
ce7a108e97
commit
4f1281deb3
|
@ -1,5 +1,6 @@
|
||||||
### [Unreleased]
|
### [Unreleased]
|
||||||
#### Added
|
#### Added
|
||||||
|
- Display event picture if available
|
||||||
#### Changed
|
#### Changed
|
||||||
#### Deprecated
|
#### Deprecated
|
||||||
#### Removed
|
#### Removed
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import Formatter from './formatter.js'
|
import Formatter from './formatter.js'
|
||||||
import { createAnchorElement } from './html-creator.js'
|
import { createAnchorElement, createImageElement } from './html-creator.js'
|
||||||
|
|
||||||
export function clearEventsList(container) {
|
export function clearEventsList(container) {
|
||||||
const list = container.querySelector('ul')
|
const list = container.querySelector('ul')
|
||||||
|
@ -18,9 +18,19 @@ export function displayEvents({ events, document, container, maxEventsCount }) {
|
||||||
const list = container.querySelector('ul')
|
const list = container.querySelector('ul')
|
||||||
for (let i = 0; i < eventsCount; i++) {
|
for (let i = 0; i < eventsCount; i++) {
|
||||||
const li = document.createElement('li')
|
const li = document.createElement('li')
|
||||||
// TODO add style
|
li.style.lineHeight = '150%'
|
||||||
|
li.style.marginTop = '20px'
|
||||||
|
|
||||||
// TODO add image
|
if (events[i].picture) {
|
||||||
|
const img = createImageElement({
|
||||||
|
document,
|
||||||
|
alt: events[i].picture.alt ? events[i].picture.alt : '',
|
||||||
|
src: events[i].picture.base64 ? events[i].picture.base64 : '',
|
||||||
|
})
|
||||||
|
img.style.display = 'block'
|
||||||
|
img.style.maxWidth = '100%'
|
||||||
|
li.appendChild(img)
|
||||||
|
}
|
||||||
|
|
||||||
const a = createAnchorElement({
|
const a = createAnchorElement({
|
||||||
document,
|
document,
|
||||||
|
|
|
@ -5,3 +5,10 @@ export function createAnchorElement({ document, text, url }) {
|
||||||
a.innerHTML = text
|
a.innerHTML = text
|
||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function createImageElement({ document, alt, src }) {
|
||||||
|
const img = document.createElement('img')
|
||||||
|
img.setAttribute('alt', alt)
|
||||||
|
img.setAttribute('src', src)
|
||||||
|
return img
|
||||||
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ if (!defined('ABSPATH')) {
|
||||||
<?php foreach ($events as $event) { ?>
|
<?php foreach ($events as $event) { ?>
|
||||||
<li style="line-height: 150%; margin-top: 20px;">
|
<li style="line-height: 150%; margin-top: 20px;">
|
||||||
<?php if (isset($event['picture'])) { ?>
|
<?php if (isset($event['picture'])) { ?>
|
||||||
<img alt="<?php echo esc_attr($event['picture']['alt']); ?>" src="<?php echo esc_attr($event['picture']['base64']); ?>" style="display: block;">
|
<img alt="<?php echo esc_attr($event['picture']['alt']); ?>" src="<?php echo esc_attr($event['picture']['base64']); ?>" style="display: block; max-width: 100%;">
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<a href="<?php echo esc_attr($event['url']); ?>"><?php echo esc_html_e($event['title']); ?></a>
|
<a href="<?php echo esc_attr($event['url']); ?>"><?php echo esc_html_e($event['title']); ?></a>
|
||||||
<br>
|
<br>
|
||||||
|
|
Loading…
Reference in New Issue