@openeuropa/bcl-featured-media 0.12.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/featured-media.html.twig +49 -5
- package/package.json +5 -2
- package/__snapshots__/featured-media.test.js.snap +0 -76
- package/data.js +0 -12
- package/dataImage.js +0 -6
- package/dataVideo.js +0 -24
- package/featured-media.story.js +0 -141
- package/featured-media.test.js +0 -26
package/featured-media.html.twig
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
{% spaceless %}
|
|
2
2
|
|
|
3
3
|
{# Parameters:
|
|
4
|
+
- with_text (boolean) (default: false)
|
|
5
|
+
- title: (string) (default: '')
|
|
6
|
+
- title_tag: (string) (default: 'h3')
|
|
4
7
|
- image: (string) (default: "")
|
|
5
8
|
- poster_image: (string) (default: "")
|
|
6
9
|
- content: (string) (default: "")
|
|
10
|
+
- wrapper_classes: (default: '')
|
|
7
11
|
- content_classes: (string) (default: "")
|
|
12
|
+
- read_more (object) (default: {})
|
|
13
|
+
- description (string) (default: '')
|
|
8
14
|
- ratio: (string) (default: "16x9")
|
|
9
15
|
- options ["1x1", "4x3", "16x9", "21x9"]
|
|
10
16
|
- sources: (array of sources) (default: []) format: [
|
|
@@ -26,15 +32,47 @@
|
|
|
26
32
|
- "embedded_media"
|
|
27
33
|
#}
|
|
28
34
|
|
|
35
|
+
{% set _title = title|default('') %}
|
|
36
|
+
{% set _title_tag = title_tag|default('h4') %}
|
|
37
|
+
{% set _with_text = with_text|default(false) %}
|
|
38
|
+
{% set _wrapper_classes = 'bcl-featured-item' %}
|
|
39
|
+
{% set _description = description|default('') %}
|
|
29
40
|
{% set _embedded_media = embedded_media|default('') %}
|
|
30
|
-
{% set _image = image|default(
|
|
31
|
-
{% set _poster_image = poster_image|default(
|
|
32
|
-
{% set _content = content|default(
|
|
33
|
-
{% set
|
|
34
|
-
{% set
|
|
41
|
+
{% set _image = image|default('') %}
|
|
42
|
+
{% set _poster_image = poster_image|default('') %}
|
|
43
|
+
{% set _content = content|default('') %}
|
|
44
|
+
{% set _alignment = alignment|default('right') %}
|
|
45
|
+
{% set _content_classes = content_classes|default('') %}
|
|
46
|
+
{% set _ratio = ratio|default('16x9') %}
|
|
35
47
|
{% set _sources = sources|default([]) %}
|
|
36
48
|
{% set _tracks = tracks|default([]) %}
|
|
49
|
+
{% set _col_classes = 'col-12 col-md-6' %}
|
|
50
|
+
{% set _read_more = read_more|default({}) %}
|
|
37
51
|
|
|
52
|
+
{% if wrapper_classes is defined and wrapper_classes is not empty %}
|
|
53
|
+
{% set _wrapper_classes = _wrapper_classes ~ ' ' ~ wrapper_classes %}
|
|
54
|
+
{% endif %}
|
|
55
|
+
|
|
56
|
+
{% if _with_text %}
|
|
57
|
+
<div class="{{ _wrapper_classes }}">
|
|
58
|
+
|
|
59
|
+
{% if _title is not empty %}
|
|
60
|
+
{% set _title_classes = 'fw-bold mb-4' %}
|
|
61
|
+
<{{ _title_tag }} class="{{ _title_classes }}">
|
|
62
|
+
{{- _title -}}
|
|
63
|
+
</{{ _title_tag }}>
|
|
64
|
+
{% endif %}
|
|
65
|
+
|
|
66
|
+
<div class="row">
|
|
67
|
+
<div class="{{ _col_classes }} order-{{ _alignment == "right" ? '1' : '2' }}">
|
|
68
|
+
{{- _description|default('') -}}
|
|
69
|
+
|
|
70
|
+
{% if _read_more is not empty %}
|
|
71
|
+
{% include '@oe-bcl/bcl-link/link.html.twig' with _read_more only %}
|
|
72
|
+
{% endif %}
|
|
73
|
+
</div>
|
|
74
|
+
<div class="{{ _col_classes }} order-{{ _alignment == "right" ? '2' : '1' }}">
|
|
75
|
+
{% endif %}
|
|
38
76
|
|
|
39
77
|
<figure
|
|
40
78
|
{{ attributes }}
|
|
@@ -79,4 +117,10 @@
|
|
|
79
117
|
{% endif %}
|
|
80
118
|
</figure>
|
|
81
119
|
|
|
120
|
+
{% if _with_text %}
|
|
121
|
+
</div>
|
|
122
|
+
</div>
|
|
123
|
+
</div>
|
|
124
|
+
{% endif %}
|
|
125
|
+
|
|
82
126
|
{% endspaceless %}
|
package/package.json
CHANGED
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
"name": "@openeuropa/bcl-featured-media",
|
|
3
3
|
"author": "European Commission",
|
|
4
4
|
"license": "EUPL-1.2",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.16.0",
|
|
6
6
|
"description": "OE - BCL featured media",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@openeuropa/bcl-link": "^0.16.0"
|
|
12
|
+
},
|
|
10
13
|
"repository": {
|
|
11
14
|
"type": "git",
|
|
12
15
|
"url": "git+https://github.com/openeuropa/bootstrap-component-library.git"
|
|
@@ -21,5 +24,5 @@
|
|
|
21
24
|
"design-system",
|
|
22
25
|
"twig"
|
|
23
26
|
],
|
|
24
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "39a52d25c36789a0c4712b0f6e55cbc5cbbedcb5"
|
|
25
28
|
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`OE - Featured media renders correctly with iframe 1`] = `
|
|
4
|
-
<jest>
|
|
5
|
-
<figure
|
|
6
|
-
src="https://www.youtube.com/embed/VFYlYeFAEH4"
|
|
7
|
-
>
|
|
8
|
-
<div
|
|
9
|
-
class="ratio ratio-16x9"
|
|
10
|
-
>
|
|
11
|
-
<iframe
|
|
12
|
-
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
|
|
13
|
-
allowfullscreen=""
|
|
14
|
-
frameborder="0"
|
|
15
|
-
height="197"
|
|
16
|
-
src="https://www.youtube.com/embed/fgi-GSCB6ho"
|
|
17
|
-
title="New digital strategy"
|
|
18
|
-
width="350"
|
|
19
|
-
/>
|
|
20
|
-
</div>
|
|
21
|
-
<figcaption
|
|
22
|
-
class="bg-light p-3"
|
|
23
|
-
>
|
|
24
|
-
Media description text goes here.
|
|
25
|
-
</figcaption>
|
|
26
|
-
</figure>
|
|
27
|
-
</jest>
|
|
28
|
-
`;
|
|
29
|
-
|
|
30
|
-
exports[`OE - Featured media renders correctly with image 1`] = `
|
|
31
|
-
<jest>
|
|
32
|
-
<figure>
|
|
33
|
-
<img
|
|
34
|
-
class="img-fluid"
|
|
35
|
-
src="https://picsum.photos/1000/400?random=1"
|
|
36
|
-
/>
|
|
37
|
-
<figcaption
|
|
38
|
-
class="bg-light p-3"
|
|
39
|
-
>
|
|
40
|
-
Media description text goes here.
|
|
41
|
-
</figcaption>
|
|
42
|
-
</figure>
|
|
43
|
-
</jest>
|
|
44
|
-
`;
|
|
45
|
-
|
|
46
|
-
exports[`OE - Featured media renders correctly with video 1`] = `
|
|
47
|
-
<jest>
|
|
48
|
-
<figure>
|
|
49
|
-
<video
|
|
50
|
-
class="w-100 d-block"
|
|
51
|
-
controls=""
|
|
52
|
-
poster="https://inno-ecl.s3.amazonaws.com/media/examples/example-image.jpg"
|
|
53
|
-
>
|
|
54
|
-
<source
|
|
55
|
-
src="https://inno-ecl.s3.amazonaws.com/media/videos/big_buck_bunny.mp4"
|
|
56
|
-
type="video/mp4"
|
|
57
|
-
/>
|
|
58
|
-
<source
|
|
59
|
-
src="https://inno-ecl.s3.amazonaws.com/media/videos/big_buck_bunny.webm"
|
|
60
|
-
type="video/webm"
|
|
61
|
-
/>
|
|
62
|
-
<track
|
|
63
|
-
kind="captions"
|
|
64
|
-
label="English"
|
|
65
|
-
src="example.vtt"
|
|
66
|
-
srclang=""
|
|
67
|
-
/>
|
|
68
|
-
</video>
|
|
69
|
-
<figcaption
|
|
70
|
-
class="bg-light p-3"
|
|
71
|
-
>
|
|
72
|
-
Media description text goes here.
|
|
73
|
-
</figcaption>
|
|
74
|
-
</figure>
|
|
75
|
-
</jest>
|
|
76
|
-
`;
|
package/data.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const drupalAttribute = require("drupal-attribute");
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
content: "Media description text goes here.",
|
|
5
|
-
content_classes: "bg-light p-3",
|
|
6
|
-
embedded_media:
|
|
7
|
-
'<iframe title="New digital strategy" width="350" height="197" src="https://www.youtube.com/embed/fgi-GSCB6ho" frameBorder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowFullScreen></iframe>',
|
|
8
|
-
attributes: new drupalAttribute().setAttribute(
|
|
9
|
-
"src",
|
|
10
|
-
"https://www.youtube.com/embed/VFYlYeFAEH4"
|
|
11
|
-
),
|
|
12
|
-
};
|
package/dataImage.js
DELETED
package/dataVideo.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
content: "Media description text goes here.",
|
|
3
|
-
content_classes: "bg-light p-3",
|
|
4
|
-
poster_image:
|
|
5
|
-
"https://inno-ecl.s3.amazonaws.com/media/examples/example-image.jpg",
|
|
6
|
-
tracks: [
|
|
7
|
-
{
|
|
8
|
-
kind: "captions",
|
|
9
|
-
label: "English",
|
|
10
|
-
src: "example.vtt",
|
|
11
|
-
srclang: "en",
|
|
12
|
-
},
|
|
13
|
-
],
|
|
14
|
-
sources: [
|
|
15
|
-
{
|
|
16
|
-
type: "video/mp4",
|
|
17
|
-
src: "https://inno-ecl.s3.amazonaws.com/media/videos/big_buck_bunny.mp4",
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
type: "video/webm",
|
|
21
|
-
src: "https://inno-ecl.s3.amazonaws.com/media/videos/big_buck_bunny.webm",
|
|
22
|
-
},
|
|
23
|
-
],
|
|
24
|
-
};
|
package/featured-media.story.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import demoData from "@openeuropa/bcl-featured-media/data";
|
|
2
|
-
import demoDataVideo from "@openeuropa/bcl-featured-media/dataVideo";
|
|
3
|
-
import demoDataImage from "@openeuropa/bcl-featured-media/dataImage";
|
|
4
|
-
import featuredMedia from "@openeuropa/bcl-featured-media/featured-media.html.twig";
|
|
5
|
-
|
|
6
|
-
const getArgs = (data, type) => {
|
|
7
|
-
const args = {
|
|
8
|
-
content: data.content || "",
|
|
9
|
-
content_classes: data.content_classes || "",
|
|
10
|
-
};
|
|
11
|
-
if (type === "iframe") {
|
|
12
|
-
args.ratio = data.ratio || "16x9";
|
|
13
|
-
}
|
|
14
|
-
if (type === "text") {
|
|
15
|
-
args.alignment = "left";
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return args;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const getArgTypes = (data, type) => {
|
|
22
|
-
const argTypes = {
|
|
23
|
-
content: {
|
|
24
|
-
description: "Content under featured media",
|
|
25
|
-
type: { name: "string" },
|
|
26
|
-
table: {
|
|
27
|
-
type: { summary: "string" },
|
|
28
|
-
defaultValue: { summary: "" },
|
|
29
|
-
category: "Content",
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
content_classes: {
|
|
33
|
-
name: "classes content",
|
|
34
|
-
description: "Classes for content under featured media",
|
|
35
|
-
type: { name: "string" },
|
|
36
|
-
table: {
|
|
37
|
-
type: { summary: "string" },
|
|
38
|
-
defaultValue: { summary: "" },
|
|
39
|
-
category: "Style",
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
if (type === "iframe") {
|
|
45
|
-
argTypes.ratio = {
|
|
46
|
-
type: { name: "select" },
|
|
47
|
-
description: "Ratio for iframe",
|
|
48
|
-
options: ["1x1", "4x3", "16x9", "21x9"],
|
|
49
|
-
table: {
|
|
50
|
-
type: { summary: "string" },
|
|
51
|
-
defaultValue: { summary: "16x9" },
|
|
52
|
-
category: "Style",
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (type === "text") {
|
|
58
|
-
argTypes.alignment = {
|
|
59
|
-
name: "alignment",
|
|
60
|
-
type: { name: "select" },
|
|
61
|
-
description: "Alignment inside text containter",
|
|
62
|
-
options: ["left", "right"],
|
|
63
|
-
table: {
|
|
64
|
-
type: { summary: "string" },
|
|
65
|
-
defaultValue: { summary: "" },
|
|
66
|
-
category: "Layout",
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return argTypes;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const adjustWidth = (story) => {
|
|
75
|
-
const demo = story();
|
|
76
|
-
return `
|
|
77
|
-
<div class="row">
|
|
78
|
-
<div class="col-12 col-md-4">
|
|
79
|
-
${demo}
|
|
80
|
-
</div>
|
|
81
|
-
</div>`;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const withText = (story, params) => {
|
|
85
|
-
const demo = story();
|
|
86
|
-
const alignment = params.args.alignment;
|
|
87
|
-
return `
|
|
88
|
-
<h3 class="mb-4">Lorem ipsum dolor sit amet.</h3>
|
|
89
|
-
<div class="row">
|
|
90
|
-
<div class="col-12 col-md-6 ${
|
|
91
|
-
alignment == "right" ? "order-md-1" : "order-md-2"
|
|
92
|
-
}">
|
|
93
|
-
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
94
|
-
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
|
|
95
|
-
<a href="#" class="mb-5 d-block">Read More</a>
|
|
96
|
-
</div>
|
|
97
|
-
<div class="col-12 col-md-6 ${
|
|
98
|
-
alignment == "right" ? "order-md-2" : "order-md-1"
|
|
99
|
-
}">
|
|
100
|
-
${demo}
|
|
101
|
-
</div>
|
|
102
|
-
</div>`;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export default {
|
|
106
|
-
title: "Paragraphs/Featured media",
|
|
107
|
-
parameters: {
|
|
108
|
-
design: [
|
|
109
|
-
{
|
|
110
|
-
name: "Mockup",
|
|
111
|
-
type: "figma",
|
|
112
|
-
url: "https://www.figma.com/file/7aJedLkk8hiDoD3RcxTnQi/BCL-Starter-kit?node-id=3973%3A35941",
|
|
113
|
-
},
|
|
114
|
-
],
|
|
115
|
-
},
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
const applyArgs = (data, args) => {
|
|
119
|
-
return Object.assign(data, args);
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
export const Iframe = (args) => featuredMedia(applyArgs(demoData, args));
|
|
123
|
-
Iframe.args = getArgs(demoData, "iframe");
|
|
124
|
-
Iframe.argTypes = getArgTypes(demoData, "iframe");
|
|
125
|
-
Iframe.decorators = [adjustWidth];
|
|
126
|
-
|
|
127
|
-
export const Video = (args) => featuredMedia(applyArgs(demoDataVideo, args));
|
|
128
|
-
Video.args = getArgs(demoData);
|
|
129
|
-
Video.argTypes = getArgTypes(demoData);
|
|
130
|
-
Video.decorators = [adjustWidth];
|
|
131
|
-
|
|
132
|
-
export const Image = (args) => featuredMedia(applyArgs(demoDataImage, args));
|
|
133
|
-
Image.args = getArgs(demoDataImage);
|
|
134
|
-
Image.argTypes = getArgTypes(demoDataImage);
|
|
135
|
-
Image.decorators = [adjustWidth];
|
|
136
|
-
|
|
137
|
-
export const insideTextContainer = (args) =>
|
|
138
|
-
featuredMedia(applyArgs(demoData, args));
|
|
139
|
-
insideTextContainer.args = getArgs(demoData, "text");
|
|
140
|
-
insideTextContainer.argTypes = getArgTypes(demoData, "text");
|
|
141
|
-
insideTextContainer.decorators = [withText];
|
package/featured-media.test.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { renderTwigFileAsNode } from "@openeuropa/bcl-test-utils";
|
|
2
|
-
|
|
3
|
-
import demoData from "@openeuropa/bcl-featured-media/data";
|
|
4
|
-
import demoDataVideo from "@openeuropa/bcl-featured-media/dataVideo";
|
|
5
|
-
import demoDataImage from "@openeuropa/bcl-featured-media/dataImage";
|
|
6
|
-
|
|
7
|
-
const template = "@oe-bcl/bcl-featured-media/featured-media.html.twig";
|
|
8
|
-
const render = (params) => renderTwigFileAsNode(template, params);
|
|
9
|
-
|
|
10
|
-
describe("OE - Featured media", () => {
|
|
11
|
-
test("renders correctly with iframe", () => {
|
|
12
|
-
expect.assertions(1);
|
|
13
|
-
|
|
14
|
-
return expect(render(demoData)).resolves.toMatchSnapshot();
|
|
15
|
-
});
|
|
16
|
-
test("renders correctly with video", () => {
|
|
17
|
-
expect.assertions(1);
|
|
18
|
-
|
|
19
|
-
return expect(render(demoDataVideo)).resolves.toMatchSnapshot();
|
|
20
|
-
});
|
|
21
|
-
test("renders correctly with image", () => {
|
|
22
|
-
expect.assertions(1);
|
|
23
|
-
|
|
24
|
-
return expect(render(demoDataImage)).resolves.toMatchSnapshot();
|
|
25
|
-
});
|
|
26
|
-
});
|