spectatr-player-sdk
Version:
A custom video player built with Stencil with Shaka Player integration
29 lines (28 loc) • 1.59 kB
JavaScript
import { h } from "@stencil/core";
import { findNearbyPoll } from "../utils/quiz-handler";
export const PollNotification = ({ showPoll, polls, currentTime, onClick, quizPosition }) => {
const nearbyPoll = findNearbyPoll(polls, currentTime);
if (!nearbyPoll || showPoll)
return null;
const bgColor = getComputedStyle(document.documentElement).getPropertyValue('--vp-video-text').trim();
const position = nearbyPoll.position || nearbyPoll.position === 'top-center'
? !!quizPosition && quizPosition === 'top-left'
? 'right'
: 'left'
: (nearbyPoll.position ?? '').replace('top-', '');
function triggerPoll() {
const updatedPolls = polls.map(poll => {
if (poll.id === nearbyPoll.id) {
return { ...poll, autoTrigger: false, triggered: true };
}
return poll;
});
onClick(nearbyPoll, updatedPolls);
}
if (nearbyPoll.autoTrigger && !nearbyPoll?.triggered) {
triggerPoll();
return null;
}
return (h("div", { class: "poll-notification-container", style: { [position]: '16px' }, onClick: triggerPoll }, h("div", { class: "poll-info-icon" }, h("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: bgColor }, h("path", { d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z" }))), !nearbyPoll?.triggered && (h("div", { class: "poll-alert-strip", style: { [position]: '40px' } }, "Poll available! Click to participate."))));
};
//# sourceMappingURL=PollNotification.js.map