Skip to content

Commit

Permalink
3089: Added image contain to instagram feed
Browse files Browse the repository at this point in the history
  • Loading branch information
tuj committed Nov 28, 2024
1 parent dfb2397 commit e4a2cf1
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/image-text/image-text-admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"input": "checkbox",
"name": "imageContain",
"label": "Deaktivér billedbeskæring",
"helpText": "Billedet vil blive vist i fuld størrelse med tomme områder omkring"
"helpText": "Billedet vil blive vist ubeskåret med tomme områder omkring"
},
{
"key": "form-background-color",
Expand Down
7 changes: 7 additions & 0 deletions src/instagram-feed/instagram-feed-admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,12 @@
"label": "Maksimalt antal billeder/videoer fra feedet",
"helpText": "Her kan du skrive maksimalt antal billeder/videoer fra feedet.",
"formGroupClasses": "col-md-6"
},
{
"key": "form-image-contain",
"input": "checkbox",
"name": "imageContain",
"label": "Deaktivér billedbeskæring",
"helpText": "Billedet vil blive vist ubeskåret med tomme områder omkring"
}
]
12 changes: 9 additions & 3 deletions src/instagram-feed/instagram-feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function InstagramFeed({ slide, content, run, slideDone, executionId }) {
const animationDuration = 1500;

const { feedData = [] } = slide;
const { hashtagText, orientation, imageWidth = null } = content;
const { hashtagText, orientation, imageWidth = null, backgroundColor, mediaContain } = content;

// @TODO: should duration depend on number of instagram posts to show?
let { entryDuration: duration } = content;
Expand Down Expand Up @@ -92,6 +92,10 @@ function InstagramFeed({ slide, content, run, slideDone, executionId }) {
rootStyle["--percentage-narrow"] = `${100 - imageWidth}%`;
}

if (backgroundColor) {
rootStyle.backgroundColor = backgroundColor;
}

return (
<>
{currentPost && (
Expand All @@ -104,7 +108,7 @@ function InstagramFeed({ slide, content, run, slideDone, executionId }) {
<div className="media-section">
{!currentPost.videoUrl && (
<div
className="image"
className={`image${mediaContain ? " image-contain" : ""}`}
style={{
backgroundImage: `url("${currentPost.mediaUrl}")`,
...(show
Expand All @@ -115,7 +119,7 @@ function InstagramFeed({ slide, content, run, slideDone, executionId }) {
)}
{currentPost.videoUrl && (
<div className="video-container">
<video muted="muted" autoPlay loop src={currentPost.videoUrl}>
<video muted="muted" autoPlay loop src={currentPost.videoUrl} className={mediaContain ? 'video-contain' : ''}>
<track kind="captions" />
</video>
</div>
Expand Down Expand Up @@ -169,6 +173,8 @@ InstagramFeed.propTypes = {
entryDuration: PropTypes.number,
maxEntries: PropTypes.number,
imageWidth: PropTypes.number,
backgroundColor: PropTypes.string,
mediaContain: PropTypes.bool,
}).isRequired,
executionId: PropTypes.string.isRequired,
};
Expand Down
9 changes: 9 additions & 0 deletions src/instagram-feed/instagram-feed.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
background-position: center center;
}

.image.image-contain {
background-size: contain;
background-repeat: no-repeat;
}

.video-container {
width: auto;
height: 100%;
Expand All @@ -31,6 +36,10 @@
width: 100%;
height: 100%;
}

video.video-contain {
object-fit: contain;
}
}

.author-section {
Expand Down
4 changes: 3 additions & 1 deletion src/slides.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,14 +553,16 @@ const slides = [
{
id: "slide7-instagram",
type: "instagram-feed",
themeFile: "themes/dokk1.css",
darkModeEnabled: false,
content: {
duration: 5000,
hashtagText: "#myhashtag",
orientation: "landscape",
imageWidth: 40.0,
entryDuration: 10,
maxEntries: 5,
backgroundColor: "#fff",
mediaContain: true,
},
feedData: [
{
Expand Down
2 changes: 1 addition & 1 deletion src/slideshow/slideshow-admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"input": "checkbox",
"name": "imageContain",
"label": "Deaktivér billedbeskæring",
"helpText": "Billedet vil blive vist i fuld størrelse med tomme områder omkring"
"helpText": "Billedet vil blive vist ubeskåret med tomme områder omkring"
},
{
"key": "form-background-color",
Expand Down

0 comments on commit e4a2cf1

Please sign in to comment.