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

Fix: enable utilities on video component #835

Merged
merged 7 commits into from
Aug 16, 2018
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
"accountId": "1900410236",
"playerId": "r1CAdLzTW",
"showMeta": true,
"showMetaTitle": false
"showMetaTitle": false,
"attributes": {
"class": "u-bolt-margin-bottom-small"
}
} only %}
<figcaption>
{% include "@bolt/text.twig" with {
Expand Down
30 changes: 23 additions & 7 deletions packages/components/bolt-video/src/video.twig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% if enable_json_schema_validation %}
{{ validate_data_schema(bolt.data.components['@bolt-components-video'].schema, _self) | raw }}
{{ validate_data_schema(bolt.data.components["@bolt-components-video"].schema, _self) | raw }}
{% endif %}

{% set videoUuid = videoUuid | default("js-bolt-video-uuid--" ~ random()) %}
Expand All @@ -12,23 +12,39 @@
{% set collapsed = collapsed | default(true) %}
{% set ratio = ratio ?? true %}

{#@todo @salem Is this used anywhere?#}
{% set classes = [
baseClass,
collapsed is not null and collapsed == false ? "is-expanded" : "is-collapsed"
] %}


{% set videoTag %}
{% include "@bolt/_video-tag.twig" %}
{% set utilClasses = [] %}
{% set videoClasses = [] %}

{% for class in attributes["class"] %}
{% if class starts with "u-" %}
{% set utilClasses = utilClasses|merge([class]) %}
{% else %}
{% set videoClasses = videoClasses|merge([class]) %}
{% endif %}
{% endfor %}

{% set innerVideo %}
{% include "@bolt/_video-tag.twig" with {
attributes: {
class: videoClasses
}
} %}
{% endset %}

{% if ratio == true %}
{% include "@bolt/ratio.twig" with {
aspectRatioHeight: aspectRatioHeight ?? 9,
aspectRatioWidth: aspectRatioWidth ?? 16,
children: videoTag
children: innerVideo,
attributes: {
class: utilClasses
}
} only %}
{% else %}
{{ videoTag }}
{% include "@bolt/_video-tag.twig" %}
{% endif %}