Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add responsive video header and include with docs #788

Merged
merged 1 commit into from
Jan 24, 2017
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
4 changes: 4 additions & 0 deletions _includes/page__hero_video.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% capture video_id %}{{ page.header.video.id }}{% endcapture %}
{% capture video_provider %}{{ page.header.video.provider }}{% endcapture %}

{% include responsive_video id=video_id provider=video_provider %}
11 changes: 11 additions & 0 deletions _includes/responsive_video
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% capture video_id %}{{ include.id }}{% endcapture %}
{% capture video_provider %}{{ include.provider }}{% endcapture %}

<!-- Courtesy of embedresponsively.com //-->
<div class="responsive-video-container">
{% if video_provider == "vimeo" %}
<iframe src="http://player.vimeo.com/video/{{ video_id }}" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey should these be protocol relative? This breaks when served over HTTPS

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it should be protocol relative.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incoming pull

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just do https://, I just checked the embeds on Vimeo and that's what they default to. The YouTube one is that way as well.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

{% elsif video_provider == "youtube" %}
<iframe src="https://www.youtube.com/embed/{{ video_id }}" frameborder="0" allowfullscreen></iframe>
{% endif %}
</div>
4 changes: 3 additions & 1 deletion _layouts/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

{% if page.header.overlay_color or page.header.overlay_image or page.header.image %}
{% include page__hero.html %}
{% elsif page.header.video.id and page.header.video.provider %}
{% include page__hero_video.html %}
{% endif %}

{% if page.url != "/" and site.breadcrumbs %}
Expand Down Expand Up @@ -71,4 +73,4 @@ <h4 class="page__related-title">{{ site.data.ui-text[site.locale].related_label
</div>
</div>
{% endif %}
</div>
</div>
25 changes: 24 additions & 1 deletion _sass/_utilities.scss
Original file line number Diff line number Diff line change
Expand Up @@ -479,4 +479,27 @@ a.reversefootnote {
table, tr, td {
border: 0; /* remove table borders widget */
}
}
}

/*
Responsive Video Embed
========================================================================== */

.responsive-video-container {
position: relative;
padding-bottom: 56.25%;
height: 0;
overflow: hidden;
max-width: 100%;

iframe,
object,
embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
}

12 changes: 11 additions & 1 deletion docs/_docs/14-helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,16 @@ And then drop-in the feature row include in the body where you'd like it to appe
**More Feature Row Goodness:** A [few more examples]({{ "/splash-page/" | absolute_url }}) and [source code](https://github.com/{{ site.repository }}/blob/master/docs/_pages/splash-page.md) can be seen in the demo site.
{: .notice--info}

## Video

Embed a responsive video from YouTube or Vimeo.

```liquid
{% raw %}{% include responsive_video id="97649261" provider="vimeo" %}{% endraw %}
```

{% include responsive_video id="97649261" provider="vimeo" %}

## Table of Contents

To include an [auto-generated table of contents](http://kramdown.rubyforge.org/converter/html.html#toc) for posts and pages, add the following helper before any actual content in your post or page.
Expand Down Expand Up @@ -280,4 +290,4 @@ To add a navigation list to a post or page's main content instead of the sidebar

| Parameter | Required | Description |
| --------- | -------- | ----------- |
| items | **Required** | Name of the links array found in `_data/navigation.yml`. |
| items | **Required** | Name of the links array found in `_data/navigation.yml`. |
4 changes: 4 additions & 0 deletions docs/_includes/page__hero_video.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% capture video_id %}{{ page.header.video.id }}{% endcapture %}
{% capture video_provider %}{{ page.header.video.provider }}{% endcapture %}

{% include responsive_video id=video_id provider=video_provider %}
11 changes: 11 additions & 0 deletions docs/_includes/responsive_video
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% capture video_id %}{{ include.id }}{% endcapture %}
{% capture video_provider %}{{ include.provider }}{% endcapture %}

<!-- Courtesy of embedresponsively.com //-->
<div class="responsive-video-container">
{% if video_provider == "vimeo" %}
<iframe src="http://player.vimeo.com/video/{{ video_id }}" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
{% elsif video_provider == "youtube" %}
<iframe src="https://www.youtube.com/embed/{{ video_id }}" frameborder="0" allowfullscreen></iframe>
{% endif %}
</div>
4 changes: 3 additions & 1 deletion docs/_layouts/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

{% if page.header.overlay_color or page.header.overlay_image or page.header.image %}
{% include page__hero.html %}
{% elsif page.header.video.id and page.header.video.provider %}
{% include page__hero_video.html %}
{% endif %}

{% if page.url != "/" and site.breadcrumbs %}
Expand Down Expand Up @@ -71,4 +73,4 @@ <h4 class="page__related-title">{{ site.data.ui-text[site.locale].related_label
</div>
</div>
{% endif %}
</div>
</div>
51 changes: 51 additions & 0 deletions docs/_posts/2017-01-23-layout-header-video.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
title: "Layout: Header Video"
header:
video:
id: XsxDH4HcOWA
provider: youtube
categories:
- Layout
- Uncategorized
tags:
- video
- layout
---

This post should display a **header with a reponsive video**, if the theme supports it.

## Settings

|---
| Parameter | Required | Description |
|-|-
| `id` | **Required** | ID of the video
| `provider` | **Required** | Hosting provider of the video, either 'youtube' or 'vimeo'
|---

## YouTube

Here is a YouTube example for the video at url `https://www.youtube.com/watch?v=XsxDH4HcOWA` (long version) or `https://youtu.be/XsxDH4HcOWA` (short version):

```yaml
header:
video:
id: XsxDH4HcOWA
provider: youtube
```

{% include responsive_video id="XsxDH4HcOWA" provider="youtube" %}

## Vimeo

Here is a Vimeo example for the video at url `https://vimeo.com/97649261`:

```yaml
header:
video:
id: 97649261
provider: vimeo
```

{% include responsive_video id="97649261" provider="vimeo" %}

25 changes: 24 additions & 1 deletion docs/_sass/_utilities.scss
Original file line number Diff line number Diff line change
Expand Up @@ -479,4 +479,27 @@ a.reversefootnote {
table, tr, td {
border: 0; /* remove table borders widget */
}
}
}

/*
Responsive Video Embed
========================================================================== */

.responsive-video-container {
position: relative;
padding-bottom: 56.25%;
height: 0;
overflow: hidden;
max-width: 100%;

iframe,
object,
embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
}