Skip to content

Commit

Permalink
feat(BlockVideoOembed): add multiple size options
Browse files Browse the repository at this point in the history
* feat(BlockVideoOembed): add size options

* feat(BlockVideoOembed): add smaller play button on small size

* feat(BlockVideoOembed): update readme

* refactor(BlockVideoOembed): translatable labels, remove width from wrapper, add png to mime types
  • Loading branch information
koukouchris authored Jul 1, 2020
1 parent 4e84112 commit a26a933
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 8 deletions.
8 changes: 6 additions & 2 deletions Components/BlockVideoOembed/Partials/_figure.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
src="{{ image.src|resizeDynamic(1280, 720) }}"
srcset="{{ placeholderImage(1280, 720) }}"
data-srcset="
{{ image.src|resizeDynamic(2048, 1152) }} 2048w,
{{ image.src|resizeDynamic(1920, 1080) }} 1920w,
{{ image.src|resizeDynamic(1280, 720) }} 1280w,
{{ image.src|resizeDynamic(750, 422) }} 750w"
{{ image.src|resizeDynamic(1440, 810) }} 1440w,
{{ image.src|resizeDynamic(1320, 743) }} 1320w,
{{ image.src|resizeDynamic(800, 450) }} 800w,
{{ image.src|resizeDynamic(600, 338) }} 600w,
{{ image.src|resizeDynamic(375, 211) }} 375w"
data-sizes="auto"
alt="{{ image.alt|e }}">
{% if image.caption %}
Expand Down
1 change: 1 addition & 0 deletions Components/BlockVideoOembed/Partials/_video.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@import 'videoLoader';

.video {
margin: 0 auto;
position: relative;

&-player {
Expand Down
25 changes: 24 additions & 1 deletion Components/BlockVideoOembed/Partials/_videoPlayButton.scss
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ $play-button-triangle-size: (

.video-playButton {
@include play-button($color-gray, $background-opacity, $border-width, $color-white, $play-button-circle-diameter, $color-white, $play-button-triangle-size);

cursor: pointer;
display: block;
height: 100%;
Expand All @@ -84,3 +83,27 @@ $play-button-triangle-size: (
width: 100%;
z-index: 2;
}

&.flyntComponent--sizeSmall {
$play-button-small-circle-diameter: (
'desktop': 60px,
'mobile': 40px
);

$play-button-small-triangle-size: (
'desktop': 20px,
'mobile': 10px
);

.video-playButton {
@include play-button(
$color-gray,
$background-opacity,
$border-width,
$color-white,
$play-button-small-circle-diameter,
$color-white,
$play-button-small-triangle-size
);
}
}
2 changes: 1 addition & 1 deletion Components/BlockVideoOembed/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Block Video oEmbed

Instead of embedding a video player directly, this component shows a poster image with an overlaying play button at first only. When clicked, the iframe based embed player is loaded autoplays the video, if the browser supports autoplay.
Instead of embedding a video player directly, this component shows a poster image with an overlaying play button at first only. When clicked, the iframe based embed player is loaded autoplays the video, if the browser supports autoplay. Multiple size options available.
24 changes: 24 additions & 0 deletions Components/BlockVideoOembed/_style.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
[is='flynt-block-video-oembed'] {
@import 'Partials/video';

&.flyntComponent--sizeSmall {
.video {
max-width: 375px;
}
}

&.flyntComponent--sizeMedium {
.video {
max-width: $content-max-width;
}
}

&.flyntComponent--sizeLarge {
.video {
max-width: 800px;
}
}

&.flyntComponent--sizeFull {
.figure-caption {
margin-left: 0.625rem;
}
}
}
20 changes: 18 additions & 2 deletions Components/BlockVideoOembed/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function getACFLayout()
'type' => 'image',
'preview_size' => 'medium',
'mime_types' => 'jpg,jpeg,png',
'instructions' => __('Recommended Size: Min-Width 1200px; Min-Height: 675px; Image-Format: JPG, PNG. Aspect Ratio 16/9.', 'flynt'),
'instructions' => __('Recommended Size: Min-Width 1920px; Min-Height: 1080px; Image-Format: JPG, PNG. Aspect Ratio 16/9.', 'flynt'),
'required' => 1
],
[
Expand All @@ -57,7 +57,23 @@ function getACFLayout()
'type' => 'group',
'layout' => 'row',
'sub_fields' => [
FieldVariables\getTheme()
FieldVariables\getTheme(),
[
'label' => __('Size', 'flynt'),
'name' => 'size',
'type' => 'radio',
'other_choice' => 0,
'save_other_choice' => 0,
'layout' => 'horizontal',
'choices' => [
'sizeSmall' => __('Small', 'flynt'),
'sizeMedium' => __('Medium', 'flynt'),
'sizeLarge' => __('Large (Default)', 'flynt'),
'sizeHuge' => __('Huge', 'flynt'),
'sizeFull' => __('Full', 'flynt'),
],
'default_value' => 'sizeLarge',
],
]
]
]
Expand Down
4 changes: 2 additions & 2 deletions Components/BlockVideoOembed/index.twig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="flyntComponent componentSpacing {{ options.theme }}" is="flynt-block-video-oembed">
<div class="container centerMaxWidthContainer">
<div class="flyntComponent flyntComponent--{{ options.size }} componentSpacing {{ options.theme }}" is="flynt-block-video-oembed">
<div class="container{% if options.size != 'sizeFull' %} centerMaxWidthContainer{% endif %}">
{% include 'Partials/_video.twig' ignore missing with {video: video, image: posterImage} only %}
</div>
</div>

0 comments on commit a26a933

Please # to comment.