Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions entry_types/scrolled/config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ de:
feature_name: iframe-Embed Inhaltselement
legacy_social_embed_content_elements:
feature_name: Legacy Twitter und TikTok Inhaltselemente
logo_list_content_element:
feature_name: Logo-Liste Inhaltselement
lottie_animation_content_element:
feature_name: Lottie-Animation-Inhaltselement
scrolled_entry_fragment_caching:
Expand Down Expand Up @@ -777,6 +779,41 @@ de:
name: Video
tabs:
general: Video
logoList:
attributes:
marquee:
label: Endlos scrollen
inline_help: |-
Logos bewegen sich in einer Endlosschleife über den
Bildschirm. Die Animation pausiert bei Mausberührung
und solange ein Logo den Tastaturfokus hat. Bei
bevorzugter Bewegungsreduzierung wird stattdessen
eine statische Liste angezeigt.
staggered:
label: Versetzt
inline_help: Jedes zweite Logo vertikal versetzt anzeigen.
description: Reihe von Partner- oder Kunden-Logos
items:
add: Hinzufügen
label: Logos
name: Logo-Liste
tabs:
general: Logo-Liste
edit_item:
back: Zurück
confirm_destroy: Soll das Logo wirklich gelöscht werden?
destroy: Logo löschen
attributes:
alt:
label: Alt-Text
inline_help: |-
Ersetzt den Alt-Text der Bilddatei für dieses Logo.
Bei verlinkten Logos sollte er das Linkziel
beschreiben, z.B. "Website von ACME".
image:
label: Bild
tabs:
item: Logo
lottieAnimation:
attributes:
id:
Expand Down
36 changes: 36 additions & 0 deletions entry_types/scrolled/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ en:
feature_name: iframe embed content element
legacy_social_embed_content_elements:
feature_name: Legacy Twitter and TikTok content elements
logo_list_content_element:
feature_name: Logo list content element
lottie_animation_content_element:
feature_name: Lottie animation content element
scrolled_entry_fragment_caching:
Expand Down Expand Up @@ -762,6 +764,40 @@ en:
name: Video
tabs:
general: Video
logoList:
attributes:
marquee:
label: Scroll continuously
inline_help: |-
Logos move across the screen in an endless loop. The
animation pauses on hover and while a logo has
keyboard focus. Visitors who prefer reduced motion see
a static list instead.
staggered:
label: Staggered
inline_help: Offset every other logo vertically.
description: Row of partner or client logos
items:
add: Add
label: Logos
name: Logo List
tabs:
general: Logo List
edit_item:
back: Back
confirm_destroy: Are you sure you want to delete this logo?
destroy: Delete logo
attributes:
alt:
label: Alt-Text
inline_help: |-
Replaces the alt text of the image file for this
logo. For linked logos, describe the link target,
e.g. "ACME website".
image:
label: Image
tabs:
item: Logo
lottieAnimation:
attributes:
id:
Expand Down
7 changes: 7 additions & 0 deletions entry_types/scrolled/lib/pageflow_scrolled/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ def configure(config)
)
end

c.features.register('logo_list_content_element') do |feature_config|
feature_config.additional_frontend_packs.register(
'pageflow-scrolled/contentElements/logoList-frontend',
content_element_type_names: ['logoList']
)
end

c.features.register('datawrapper_chart_embed_opt_in')
c.features.enable_by_default('datawrapper_chart_embed_opt_in')
c.features.register('iframe_embed_content_element')
Expand Down
6 changes: 6 additions & 0 deletions entry_types/scrolled/package/config/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ module.exports = {
'pageflow-scrolled/contentElements/lottieAnimation-frontend.css'
]
},
'pageflow-scrolled/contentElements/logoList-frontend': {
import: [
'pageflow-scrolled/contentElements/logoList-frontend',
'pageflow-scrolled/contentElements/logoList-frontend.css'
]
},
'pageflow-scrolled/widgets/defaultNavigation': {
import: [
'pageflow-scrolled/widgets/defaultNavigation',
Expand Down
1 change: 1 addition & 0 deletions entry_types/scrolled/package/contentElements-server.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'pageflow-scrolled/contentElements-frontend';
import 'pageflow-scrolled/contentElements/hotspots-frontend';
import 'pageflow-scrolled/contentElements/inlineBeforeAfter-frontend';
import 'pageflow-scrolled/contentElements/logoList-frontend';
import 'pageflow-scrolled/contentElements/lottieAnimation-frontend';
import 'pageflow-scrolled/contentElements/socialEmbed-frontend';
import 'pageflow-scrolled/contentElements/tikTokEmbed-frontend';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import React from 'react';

import {LogoList} from 'contentElements/logoList/LogoList';
import styles from 'contentElements/logoList/LogoList.module.css';

import {renderInContentElement} from 'pageflow-scrolled/testHelpers';
import userEvent from '@testing-library/user-event';
import '@testing-library/jest-dom/extend-expect'

describe('LogoList editor selection', () => {
const seed = {
imageFileUrlTemplates: {medium: ':id_partition/medium/image.webp'},
imageFiles: [{id: 1, permaId: 100}, {id: 2, permaId: 101}]
};

const items = [{id: 1, image: 100}, {id: 2, image: 101}];

function renderLogoList(inlineEditing) {
return renderInContentElement(
<LogoList configuration={{items}} contentElementId={1} />,
{seed, inlineEditing: {isSelected: true, ...inlineEditing}}
);
}

it('sets selected item id in transient state', async () => {
const setTransientState = jest.fn();
const user = userEvent.setup();
const {getAllByRole} = renderLogoList({transientState: setTransientState});

await user.click(getAllByRole('listitem')[1]);

expect(setTransientState).toHaveBeenCalledWith({selectedItemId: 2});
});

it('resets selected item id in transient state when clicking outside logos', async () => {
const setTransientState = jest.fn();
const user = userEvent.setup();
const {getByRole} = renderLogoList({transientState: setTransientState});

await user.click(getByRole('list'));

expect(setTransientState).toHaveBeenCalledWith({selectedItemId: null});
});

it('supports setting selected item via command', () => {
const {getAllByRole, triggerEditorCommand} = renderLogoList();

triggerEditorCommand({type: 'SET_SELECTED_ITEM', index: 1});

expect(getAllByRole('listitem')[0]).not.toHaveClass(styles.selected);
expect(getAllByRole('listitem')[1]).toHaveClass(styles.selected);
});

it('supports resetting selected item via command', () => {
const {container, triggerEditorCommand} = renderLogoList();

triggerEditorCommand({type: 'SET_SELECTED_ITEM', index: 1});
triggerEditorCommand({type: 'SET_SELECTED_ITEM', index: -1});

expect(container.querySelector(`.${styles.selected}`)).toBeNull();
});

it('supports highlighting item via command', () => {
const {getAllByRole, triggerEditorCommand} = renderLogoList();

triggerEditorCommand({type: 'HIGHLIGHT_ITEM', index: 1});

expect(getAllByRole('listitem')[0]).not.toHaveClass(styles.highlighted);
expect(getAllByRole('listitem')[1]).toHaveClass(styles.highlighted);
});

it('supports resetting item highlight via command', () => {
const {container, triggerEditorCommand} = renderLogoList();

triggerEditorCommand({type: 'HIGHLIGHT_ITEM', index: 1});
triggerEditorCommand({type: 'RESET_ITEM_HIGHLIGHT'});

expect(container.querySelector(`.${styles.highlighted}`)).toBeNull();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import React from 'react';
import '@testing-library/jest-dom/extend-expect'

import {LogoList} from 'contentElements/logoList/LogoList';

import {renderInContentElement} from 'pageflow-scrolled/testHelpers';

describe('LogoList images', () => {
const imageFileUrlTemplates = {
medium: ':id_partition/medium/image.webp',
original: ':id_partition/original/:basename.:extension'
};

function renderLogoList({configuration, imageFiles}) {
const result = renderInContentElement(
<LogoList configuration={configuration} contentElementId={1} />,
{seed: {imageFileUrlTemplates, imageFiles}}
);

result.simulateScrollPosition('near viewport');

return result;
}

it('renders medium variant of item images', () => {
const {getAllByRole} = renderLogoList({
configuration: {items: [{id: 1, image: 100}, {id: 2, image: 101}]},
imageFiles: [{id: 1, permaId: 100}, {id: 2, permaId: 101}]
});

expect(getAllByRole('img').map(img => img.getAttribute('src'))).toEqual([
'000/000/001/medium/image.webp',
'000/000/002/medium/image.webp'
]);
});

it('uses original url of svg images', () => {
const {getByRole} = renderLogoList({
configuration: {items: [{id: 1, image: 100}]},
imageFiles: [{id: 1, permaId: 100, basename: 'logo', extension: 'svg'}]
});

expect(getByRole('img')).toHaveAttribute('src', '000/000/001/original/logo.svg');
});

it('renders alt text of image file', () => {
const {getByRole} = renderLogoList({
configuration: {items: [{id: 1, image: 100}]},
imageFiles: [{id: 1, permaId: 100, configuration: {alt: 'ACME Inc.'}}]
});

expect(getByRole('img', {name: 'ACME Inc.'})).toBeInTheDocument();
});

it('prefers alt text of item', () => {
const {getByRole} = renderLogoList({
configuration: {items: [{id: 1, image: 100, alt: 'ACME website'}]},
imageFiles: [{id: 1, permaId: 100, configuration: {alt: 'ACME Inc.'}}]
});

expect(getByRole('img', {name: 'ACME website'})).toBeInTheDocument();
});

it('passes image dimensions to preserve aspect ratio', () => {
const {getByRole} = renderLogoList({
configuration: {items: [{id: 1, image: 100}]},
imageFiles: [{id: 1, permaId: 100, width: 400, height: 100}]
});

expect(getByRole('img')).toHaveAttribute('width', '400');
expect(getByRole('img')).toHaveAttribute('height', '100');
});

it('skips items with missing image files', () => {
const {getAllByRole} = renderLogoList({
configuration: {items: [{id: 1, image: 100}, {id: 2, image: 999}]},
imageFiles: [{id: 1, permaId: 100}]
});

expect(getAllByRole('listitem')).toHaveLength(1);
});

it('does not load images before content element is near viewport', () => {
const {queryByRole} = renderInContentElement(
<LogoList configuration={{items: [{id: 1, image: 100}]}} contentElementId={1} />,
{seed: {imageFileUrlTemplates, imageFiles: [{id: 1, permaId: 100}]}}
);

expect(queryByRole('img')).toBeNull();
});
});
Loading
Loading