Skip to content

Commit dc9e7a9

Browse files
authored
Merge pull request #165 from os2display/feature/eventdatabasen-v2
New feed source: Eventdatabasen v2
2 parents e3defcf + c0ab8ba commit dc9e7a9

File tree

6 files changed

+58
-31
lines changed

6 files changed

+58
-31
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44

55
## Unreleased
66

7+
- [#165](https://github.com/os2display/display-templates/pull/165)
8+
- Fixed transitions for poster.
9+
- Fixed dates for poster spanning multiple days.
10+
711
## [2.2.0] - 2025-3-10
812

913
- [#160](https://github.com/os2display/display-templates/pull/160)

build/poster-config-develop.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"id": "01FWJZQ25A1868V63CWYYHQFKQ",
55
"description": "Mulighed for at vise plakat indhold.",
66
"resources": {
7-
"component": "https://raw.githubusercontent.com/os2display/display-templates/develop/build/poster.js?ts=1733136815096",
8-
"admin": "https://raw.githubusercontent.com/os2display/display-templates/develop/build/poster-admin.json?ts=1733136815096",
9-
"schema": "https://raw.githubusercontent.com/os2display/display-templates/develop/build/poster-schema.json?ts=1733136815096",
7+
"component": "https://raw.githubusercontent.com/os2display/display-templates/develop/build/poster.js?ts=1738154345932",
8+
"admin": "https://raw.githubusercontent.com/os2display/display-templates/develop/build/poster-admin.json?ts=1738154345932",
9+
"schema": "https://raw.githubusercontent.com/os2display/display-templates/develop/build/poster-schema.json?ts=1738154345932",
1010
"assets": [],
1111
"options": {},
1212
"content": {}

build/poster-config-main.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"id": "01FWJZQ25A1868V63CWYYHQFKQ",
55
"description": "Mulighed for at vise plakat indhold.",
66
"resources": {
7-
"component": "https://raw.githubusercontent.com/os2display/display-templates/main/build/poster.js?ts=1733136815096",
8-
"admin": "https://raw.githubusercontent.com/os2display/display-templates/main/build/poster-admin.json?ts=1733136815096",
9-
"schema": "https://raw.githubusercontent.com/os2display/display-templates/main/build/poster-schema.json?ts=1733136815096",
7+
"component": "https://raw.githubusercontent.com/os2display/display-templates/main/build/poster.js?ts=1738154345932",
8+
"admin": "https://raw.githubusercontent.com/os2display/display-templates/main/build/poster-admin.json?ts=1738154345932",
9+
"schema": "https://raw.githubusercontent.com/os2display/display-templates/main/build/poster-schema.json?ts=1738154345932",
1010
"assets": [],
1111
"options": {},
1212
"content": {}

build/poster.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/poster/poster.js

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import "./poster.scss";
2323
function Poster({ slide, content, run, slideDone, executionId }) {
2424
const [translations, setTranslations] = useState({});
2525
const [currentEvent, setCurrentEvent] = useState(null);
26+
const [currentIndex, setCurrentIndex] = useState(null);
2627
const [show, setShow] = useState(true);
2728
const timerRef = useRef(null);
2829
const animationTimerRef = useRef(null);
@@ -88,7 +89,7 @@ function Poster({ slide, content, run, slideDone, executionId }) {
8889

8990
const formatDateNoYear = (date) => {
9091
if (!date) return "";
91-
return capitalize(dayjs(date).locale(localeDa).format("DD MMMM"));
92+
return capitalize(dayjs(date).locale(localeDa).format("DD MMM"));
9293
};
9394

9495
const getUrlDomain = (urlString) => {
@@ -101,37 +102,55 @@ function Poster({ slide, content, run, slideDone, executionId }) {
101102
);
102103
};
103104

105+
useEffect(() => {
106+
if (currentEvent) {
107+
setShow(true);
108+
}
109+
}, [currentEvent]);
110+
104111
// Setup feed entry switch and animation, if there is more than one post.
105112
useEffect(() => {
106-
if (!currentEvent) return;
113+
if (currentIndex === null) {
114+
return;
115+
}
107116

108-
timerRef.current = setTimeout(() => {
109-
const currentIndex = feedData.indexOf(currentEvent);
110-
const nextIndex = (currentIndex + 1) % feedData.length;
117+
setCurrentEvent(feedData[currentIndex]);
118+
119+
const nextIndex = (currentIndex + 1) % feedData.length;
111120

121+
if (nextIndex > 0) {
122+
if (animationTimerRef?.current) {
123+
clearInterval(animationTimerRef.current);
124+
}
125+
126+
animationTimerRef.current = setTimeout(() => {
127+
setShow(false);
128+
}, entryDurationMilliseconds - animationDuration + 50);
129+
}
130+
131+
if (timerRef?.current) {
132+
clearInterval(timerRef.current);
133+
}
134+
135+
timerRef.current = setTimeout(() => {
112136
if (nextIndex === 0) {
113137
slideDone(slide);
114138
} else {
115-
setCurrentEvent(feedData[nextIndex]);
116-
setShow(true);
139+
setCurrentIndex(nextIndex);
117140
}
118141
}, entryDurationMilliseconds);
119-
120-
animationTimerRef.current = setTimeout(() => {
121-
setShow(false);
122-
}, entryDurationMilliseconds - animationDuration);
123-
}, [currentEvent]);
142+
}, [currentIndex]);
124143

125144
useEffect(() => {
126145
if (run) {
127146
if (feedData && currentEvent === null && feedData?.length > 0) {
128-
const [first] = feedData;
129-
setCurrentEvent(first);
147+
setCurrentIndex(0);
130148
} else {
131149
setTimeout(() => slideDone(slide), 1000);
132150
}
133151
} else {
134152
setCurrentEvent(null);
153+
setCurrentIndex(null);
135154
}
136155
}, [run]);
137156

@@ -142,10 +161,10 @@ function Poster({ slide, content, run, slideDone, executionId }) {
142161
setTranslations(da);
143162

144163
return function cleanup() {
145-
if (timerRef?.current !== null) {
164+
if (timerRef?.current) {
146165
clearInterval(timerRef.current);
147166
}
148-
if (animationTimerRef?.current !== null) {
167+
if (animationTimerRef?.current) {
149168
clearInterval(animationTimerRef.current);
150169
}
151170
};
@@ -159,12 +178,16 @@ function Poster({ slide, content, run, slideDone, executionId }) {
159178
<div className={`template-poster ${showLogo && "with-logo"}`}>
160179
<div
161180
className={`image-area ${mediaContain ? "media-contain" : ""}`}
162-
style={{
163-
backgroundImage: `url("${image}")`,
164-
...(show
165-
? { animation: `fade-in ${animationDuration}ms` }
166-
: { animation: `fade-out ${animationDuration}ms` }),
167-
}}
181+
style={
182+
image
183+
? {
184+
backgroundImage: `url("${image}")`,
185+
...(show
186+
? { animation: `fade-in ${animationDuration}ms` }
187+
: { animation: `fade-out ${animationDuration}ms` }),
188+
}
189+
: {}
190+
}
168191
/>
169192
<div className="header-area">
170193
<div className="center">

src/slides.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -939,8 +939,8 @@ const slides = [
939939
name: "Lorem ipsum",
940940
url: "www.example.dk",
941941
image: "/fixtures/images/mountain1.jpeg",
942-
startDate: "2021-06-21T14:00:00+00:00",
943-
endDate: "2021-06-21T15:00:00+00:00",
942+
startDate: "2021-08-21T14:00:00+00:00",
943+
endDate: "2021-09-21T15:00:00+00:00",
944944
ticketPriceRange: "75-150 kr.",
945945
eventStatusText: null,
946946
place: {

0 commit comments

Comments
 (0)