@ilo-org/twig 0.14.6 → 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.
Files changed (27) hide show
  1. package/.turbo/turbo-build:lib.log +2 -2
  2. package/CHANGELOG.md +49 -0
  3. package/apps/storybook/theme.js +3 -3
  4. package/package.json +6 -5
  5. package/src/patterns/components/breadcrumb/breadcrumb.twig +1 -1
  6. package/src/patterns/components/breadcrumb/breadcrumb.wingsuit.yml +1 -1
  7. package/src/patterns/components/button/button.twig +11 -8
  8. package/src/patterns/components/button/button.wingsuit.yml +6 -4
  9. package/src/patterns/components/hero/hero.twig +1 -1
  10. package/src/patterns/components/icon/icon.behavior.js +16 -0
  11. package/src/patterns/components/icon/icon.js +128 -0
  12. package/src/patterns/components/icon/icon.stories.jsx +10 -0
  13. package/src/patterns/components/icon/icon.twig +1 -1
  14. package/src/patterns/components/icon/icon.wingsuit.yml +29 -0
  15. package/src/patterns/components/icon/index.js +4 -4
  16. package/src/patterns/components/list/list.twig +22 -23
  17. package/src/patterns/components/pagination/pagination.wingsuit.yml +1 -1
  18. package/src/patterns/components/search/index.js +1 -0
  19. package/src/patterns/components/search/search.behavior.js +15 -0
  20. package/src/patterns/components/search/search.js +103 -0
  21. package/src/patterns/components/search/search.twig +13 -4
  22. package/src/patterns/components/tableofcontents/tableofcontents.twig +45 -21
  23. package/src/patterns/components/tableofcontents/tableofcontents.wingsuit.yml +4 -12
  24. package/src/patterns/components/video/video.js +7 -57
  25. package/src/patterns/components/video/video.twig +2 -1
  26. package/src/patterns/components/video/video.wingsuit.yml +37 -0
  27. package/src/patterns/components/video/videoplayer.twig +0 -1
@@ -1,9 +1,9 @@
1
1
 
2
- > @ilo-org/twig@0.14.6 build:lib /home/runner/work/designsystem/designsystem/packages/twig
2
+ > @ilo-org/twig@0.16.0 build:lib /home/runner/work/designsystem/designsystem/packages/twig
3
3
  > node importprefix.js && node importsvgs.js && pnpm output
4
4
 
5
5
  theme prefix added
6
6
 
7
- > @ilo-org/twig@0.14.6 output /home/runner/work/designsystem/designsystem/packages/twig
7
+ > @ilo-org/twig@0.16.0 output /home/runner/work/designsystem/designsystem/packages/twig
8
8
  > node outputtwigs.js
9
9
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,54 @@
1
1
  # @ilo-org/twig
2
2
 
3
+ ## 0.16.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 138890e7a: implemented new icon component
8
+
9
+ ### Patch Changes
10
+
11
+ - ac23bf484: Add clear button to search input field
12
+ - fd26dbafc: Enable Button to use newly refactored Icon component
13
+ - db2ecaf48: Correct the way the Table of Contents passes properties to the Open and Close buttons.
14
+ - Updated dependencies [ac23bf484]
15
+ - Updated dependencies [1b9c54f99]
16
+ - Updated dependencies [138890e7a]
17
+ - @ilo-org/styles@0.14.0
18
+
19
+ ## 0.15.0
20
+
21
+ ### Minor Changes
22
+
23
+ - 4153f99b5: Removed black bars from youtube ebedded video
24
+ - 1ed3123ae: Re-implemented video.js styles
25
+
26
+ ### Patch Changes
27
+
28
+ - 9bf73c7bd: Fix lists containing other elements than li items to improve accessibility
29
+ - a3c872512: separated labels for breadcrumbs
30
+ - 056754038: Revise and refactor color names with the same values and remove duplicates and replace where it was used
31
+ - e1000fbbd: added legacy classname for react video component
32
+ - Updated dependencies [4153f99b5]
33
+ - Updated dependencies [c8de2b695]
34
+ - Updated dependencies [7472dd625]
35
+ - Updated dependencies [b3298a267]
36
+ - Updated dependencies [bf4432d7c]
37
+ - Updated dependencies [1ed3123ae]
38
+ - Updated dependencies [f76a35fdc]
39
+ - Updated dependencies [a3c872512]
40
+ - Updated dependencies [056754038]
41
+ - Updated dependencies [4bbac5457]
42
+ - Updated dependencies [e1000fbbd]
43
+ - Updated dependencies [ac58b53d2]
44
+ - Updated dependencies [51b20d4aa]
45
+ - Updated dependencies [5a1e32f8e]
46
+ - Updated dependencies [52eeae214]
47
+ - Updated dependencies [709675b79]
48
+ - @ilo-org/styles@0.13.3
49
+ - @ilo-org/brand-assets@0.4.0
50
+ - @ilo-org/themes@0.7.1
51
+
3
52
  ## 0.14.6
4
53
 
5
54
  ### Patch Changes
@@ -17,7 +17,7 @@ export default create({
17
17
  colorSecondary: brand["ilo-blue"].value,
18
18
 
19
19
  // UI
20
- appBg: brand["ilo-lighter-blue"].value,
20
+ appBg: brand["ilo-light-blue"].value,
21
21
  appContentBg: brand["ilo-white"].value,
22
22
  appBorderColor: brand["ilo-grey-ui"].value,
23
23
  appBorderRadius: 0,
@@ -37,9 +37,9 @@ export default create({
37
37
 
38
38
  buttonBg: brand["ilo-white"].value,
39
39
  buttonBorder: brand["ilo-grey-ui"].value,
40
- booleanBg: brand["ilo-lighter-blue"].value,
40
+ booleanBg: brand["ilo-light-blue"].value,
41
41
  booleanSelectedBg: brand["ilo-white"].value,
42
- inputBg: brand["ilo-lighter-blue"].value,
42
+ inputBg: brand["ilo-light-blue"].value,
43
43
  inputBorder: brand["ilo-grey-ui"].value,
44
44
  inputTextColor: brand["ilo-dark-blue"].value,
45
45
  inputBorderRadius: 3,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ilo-org/twig",
3
- "version": "0.14.6",
3
+ "version": "0.16.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Twig components for the ILO's Design System",
6
6
  "main": "",
@@ -21,13 +21,14 @@
21
21
  "components"
22
22
  ],
23
23
  "dependencies": {
24
- "@popperjs/core": "^2.11.8",
25
24
  "video.js": "^7.21.2",
26
- "@ilo-org/brand-assets": "0.3.1",
25
+ "videojs-youtube": "^3.0.1",
26
+ "@popperjs/core": "^2.11.8",
27
+ "@ilo-org/brand-assets": "0.4.0",
27
28
  "@ilo-org/fonts": "0.1.2",
28
29
  "@ilo-org/icons": "0.2.1",
29
- "@ilo-org/styles": "0.13.2",
30
- "@ilo-org/themes": "0.7.0",
30
+ "@ilo-org/styles": "0.14.0",
31
+ "@ilo-org/themes": "0.7.1",
31
32
  "@ilo-org/utils": "0.0.11"
32
33
  },
33
34
  "devDependencies": {
@@ -24,7 +24,7 @@
24
24
  {% if not loop.first and not loop.last %}
25
25
  <li class="{{prefix}}--breadcrumb--item">
26
26
  <a href="{{link.url}}" class="{{prefix}}--breadcrumb--link">
27
- <span class="{{prefix}}--breadcrumb--link--label">{{link.label}}</span>
27
+ <span class="{{prefix}}--breadcrumb--link--label--dropdown">{{link.label}}</span>
28
28
  </a>
29
29
  </li>
30
30
  {% endif %}
@@ -22,7 +22,7 @@ breadcrumb:
22
22
  url: "/linkone"
23
23
  - label: "Link Two"
24
24
  url: "/linktwo"
25
- - label: "Link Three"
25
+ - label: "Link Three a long link that will wrap to the next line"
26
26
  url: "/linkthree"
27
27
  - label: "Link Four"
28
28
  url: "/linkfour"
@@ -3,18 +3,21 @@
3
3
  #}
4
4
  {% if url %}
5
5
  <a class="{{prefix}}--button ilo--button--{{size}} {{prefix}}--button--{{type}}{% if icon %} icon icon__position--{{iconPosition}}{% endif %}{% if icononly %} icon--only{% endif %}{% if className %} {{className}}{% endif %}" href="{{url}}" {% if target is defined and target != 'false' %} target="{{target}}" rel="noopener noreferrer" {% endif %} {% if disabled is defined and disabled == 'true' %} disabled {% endif %}>
6
-
7
6
  <span class="link__label">{{label}}</span>
8
- {% if icon %}
9
- {% include '@components/icon/icon.twig' with {icon: icon} %}
10
- {% endif %}
7
+ {% block button_icon %}
8
+ {% if icon %}
9
+ {% include '@components/icon/icon.twig' with {
10
+ prefix: prefix,
11
+ name: icon.name,
12
+ size: icon.size,
13
+ color: icon.color
14
+ } only %}
15
+ {% endif %}
16
+ {% endblock %}
11
17
  </a>
12
18
  {% else %}
13
19
  <button class="{{prefix}}--button ilo--button--{{size}} {{prefix}}--button--{{type}}{% if icon %} icon icon__position--{{iconPosition}}{% endif %}{% if icononly %} icon--only{% endif %}{% if className %} {{className}}{% endif %}" {% if kind %} type="{{kind}}" {% endif %} {% if opensmodal %} aria-haspopup="dialog" {% endif %} {% if disabled is defined and disabled == 'true' %} disabled {% endif %} {% if name %} name="{{name}}" {% endif %}>
14
-
15
20
  <span class="button__label">{{label}}</span>
16
- {% if icon %}
17
- {% include '@components/icon/icon.twig' with {icon: icon} %}
18
- {% endif %}
21
+ {{ block("button_icon") }}
19
22
  </button>
20
23
  {% endif %}
@@ -23,16 +23,18 @@ button:
23
23
  preview: ""
24
24
  required: false
25
25
  target:
26
- type: string
26
+ type: object
27
27
  label: target
28
28
  description: Should the button open in a new tab? If so, include the name of the tab. Only evaluated if the url field is populated.
29
29
  preview: "true"
30
30
  required: false
31
31
  icon:
32
- type: string
32
+ type: object
33
33
  label: Icon
34
- description: optional icon to include in button
35
- preview: false
34
+ description: Optional icon to include in button. See the `Icon` component for a full list of arguments
35
+ preview:
36
+ name: "add"
37
+ size: 24
36
38
  required: false
37
39
  className:
38
40
  type: string
@@ -55,7 +55,7 @@
55
55
  {% include '@components/tooltip/tooltip.twig' with {
56
56
  prefix: prefix,
57
57
  label: caption.label,
58
- icon: true,
58
+ icon: "true",
59
59
  theme: "dark",
60
60
  icontheme: "dark"
61
61
  } only %}
@@ -0,0 +1,16 @@
1
+ import Icon from "./icon";
2
+
3
+ Drupal.behaviors.icon = {
4
+ attach() {
5
+ Array.prototype.forEach.call(
6
+ document.querySelectorAll(`[data-loadcomponent="Icon"]`),
7
+ (element) => {
8
+ if (!element.dataset.jsProcessed) {
9
+ // eslint-disable-next-line no-console
10
+ new Icon(element);
11
+ element.dataset.jsProcessed = true;
12
+ }
13
+ }
14
+ );
15
+ },
16
+ };
@@ -0,0 +1,128 @@
1
+ import * as Icons from "@ilo-org/icons";
2
+
3
+ const SIZING = [16, 20, 24, 32];
4
+ const DEFAULT_SIZE = 24;
5
+ const SVG_NS = "http://www.w3.org/2000/svg";
6
+ const PATH_NS = "http://www.w3.org/2000/path";
7
+
8
+ /**
9
+ * The Icon module which handles rendering icons
10
+ *
11
+ * @class Icon
12
+ */
13
+ export default class Icon {
14
+ /**
15
+ * Icon constructor which assigns the element passed into the constructor
16
+ *
17
+ * @param {SVGElement} element - REQUIRED - the module's container
18
+ */
19
+ constructor(element) {
20
+ /**
21
+ * Reference to the DOM element that is the root of the component
22
+ * @property {SVGElement}
23
+ */
24
+ this.element = element;
25
+
26
+ /** Initialize the icon logic*/
27
+ this.init();
28
+ }
29
+
30
+ /**
31
+ * Initializes the icon logic
32
+ */
33
+ init() {
34
+ const isValid = this.validate();
35
+ if (!isValid) {
36
+ return;
37
+ }
38
+
39
+ const svg = this.build();
40
+
41
+ this.prepare(svg);
42
+ this.element.outerHTML = svg.outerHTML;
43
+
44
+ return this;
45
+ }
46
+
47
+ /**
48
+ * Validate icon prop
49
+ *
50
+ * @returns {boolean}
51
+ */
52
+ validate() {
53
+ let { name, size } = this.element.dataset;
54
+ if (!SIZING.includes(+size)) {
55
+ console.warn(
56
+ `Icon size ${size} is not supported. Defaulting to ${DEFAULT_SIZE}px`
57
+ );
58
+ size = DEFAULT_SIZE;
59
+ }
60
+
61
+ if (!name) {
62
+ console.warn("Icon name is required");
63
+ return false;
64
+ }
65
+
66
+ const reference = this.getIconConfig(name, size);
67
+ if (!reference) {
68
+ console.warn(`Icon "${name}" not found`);
69
+ return false;
70
+ }
71
+
72
+ return true;
73
+ }
74
+
75
+ /**
76
+ * Build a new SVG element
77
+ *
78
+ * @returns {SVGElement}
79
+ */
80
+ build() {
81
+ const { name, size, color } = this.element.dataset;
82
+ const config = this.getIconConfig(name, size);
83
+ const element = document.createElementNS(SVG_NS, "svg");
84
+
85
+ for (const [key, value] of Object.entries(config.attrs)) {
86
+ element.setAttribute(key, value);
87
+ }
88
+
89
+ if (color) {
90
+ element.setAttribute("fill", color);
91
+ }
92
+
93
+ for (const item of config.content) {
94
+ const child = document.createElementNS(PATH_NS, item.elem);
95
+ for (let [key, value] of Object.entries(item.attrs)) {
96
+ if (key === "fill" && color) {
97
+ value = color;
98
+ }
99
+ child.setAttribute(key, value);
100
+ }
101
+ element.appendChild(child);
102
+ }
103
+
104
+ return element;
105
+ }
106
+
107
+ /**
108
+ * Get the icon config
109
+ *
110
+ * @param {string} name
111
+ * @param {string} size
112
+ */
113
+ getIconConfig(name, size) {
114
+ const nameUpper = name.charAt(0).toUpperCase() + name.slice(1);
115
+
116
+ return Icons[`${nameUpper}${size}`];
117
+ }
118
+
119
+ /**
120
+ * Attach final attributes
121
+ *
122
+ * @param {SVGElement} icon - REQUIRED - the svg icon instance
123
+ */
124
+ prepare(icon) {
125
+ icon.setAttribute("class", this.element.getAttribute("class"));
126
+ icon.setAttribute("data-js-processed", true);
127
+ }
128
+ }
@@ -0,0 +1,10 @@
1
+ import "./index";
2
+
3
+ export default {};
4
+
5
+ const patternDefinition = require("./icon.wingsuit.yml");
6
+
7
+ /* eslint-disable-next-line */
8
+ export const wingsuit = {
9
+ patternDefinition,
10
+ };
@@ -1,4 +1,4 @@
1
1
  {#
2
2
  ICON COMPONENT
3
3
  #}
4
- <img class="{{prefix}}--icon" src="{{'/images/'~icon~'.svg'}}" alt="{{icon}}" role="presentation">
4
+ <svg class="{{prefix}}--icon" data-name="{{name}}" data-size="{{size}}" data-color="{{color}}" data-loadcomponent="Icon"></svg>
@@ -0,0 +1,29 @@
1
+ icon:
2
+ namespace: Components/User Interface
3
+ use: "@components/icon/icon.twig"
4
+ label: Icon
5
+ description: A component for displaying an svg icon.
6
+ settings:
7
+ name:
8
+ type: string
9
+ label: Name
10
+ description: The name of the icon to display. <strong style="font-weight:bold">The name should match SVG file</strong>, see available icons in the <a target="_blank" href="https://github.com/international-labour-organization/designsystem/tree/develop/packages/icons/src/svg">@ilo-org/icons</a> package
11
+ preview: "arrowright"
12
+ required: true
13
+ size:
14
+ type: select
15
+ label: Size
16
+ description: The size of the icon in pixels
17
+ options:
18
+ 16: 16
19
+ 20: 20
20
+ 24: 24
21
+ 32: 32
22
+ preview: "24"
23
+ required: false
24
+ color:
25
+ type: string
26
+ label: Fill
27
+ description: The fill color of the icon in hex
28
+ preview: "#000000"
29
+ required: false
@@ -1,6 +1,6 @@
1
1
  /**
2
- * media
2
+ * Icon
3
3
  */
4
- // Module template
5
- import "./image.twig";
6
- import "./image.wingsuit.yml";
4
+ import "./icon.twig";
5
+ import "./icon.wingsuit.yml";
6
+ import "./icon.behavior";
@@ -1,30 +1,29 @@
1
1
  {#
2
2
  LIST COMPONENT
3
3
  #}
4
- {% if ordered == "ordered" %}
5
- <ol class="ilo--list ilo--list--{{ ordered|default('ordered') }}" data-loadcomponent="List">
4
+ <div class="ilo--list ilo--list--{% if ordered == 'ordered' %}ordered{% endif %}{{alignment|default('') }}">
6
5
  {% if title %}
7
6
  <h5 class="ilo--list__title">{{ title }}</h5>
8
7
  {% endif %}
9
- {% for item in items %}
10
- {% include "@components/list/list-item.twig" with {
11
- label: item.label,
12
- content: item.content,
13
- id: item.id,
14
- } only %}
15
- {% endfor %}
16
- </ol>
17
- {% else %}
18
- <ul class="ilo--list ilo--list--{{ ordered|default('unordered') }} ilo--list--{{ alignment|default('') }}" data-loadcomponent="List">
19
- {% if title %}
20
- <h5 class="ilo--list__title">{{ title }}</h5>
8
+ {% if ordered == "ordered" %}
9
+ <ol data-loadcomponent="List">
10
+ {% for item in items %}
11
+ {% include "@components/list/list-item.twig" with {
12
+ label: item.label,
13
+ content: item.content,
14
+ id: item.id,
15
+ } only %}
16
+ {% endfor %}
17
+ </ol>
18
+ {% else %}
19
+ <ul class="ilo--list--{{ alignment|default('') }}" data-loadcomponent="List">
20
+ {% for item in items %}
21
+ {% include "@components/list/list-item.twig" with {
22
+ label: item.label,
23
+ content: item.content,
24
+ id: item.id,
25
+ } only %}
26
+ {% endfor %}
27
+ </ul>
21
28
  {% endif %}
22
- {% for item in items %}
23
- {% include "@components/list/list-item.twig" with {
24
- label: item.label,
25
- content: item.content,
26
- id: item.id,
27
- } only %}
28
- {% endfor %}
29
- </ul>
30
- {% endif %}
29
+ </div>
@@ -2,7 +2,7 @@ pagination:
2
2
  namespace: Components/Navigation
3
3
  use: "@components/pagination/pagination.twig"
4
4
  label: Pagination
5
- description: The Pagination component presents a dismissible alert.
5
+ description: The Pagination component breaks content into pages for easier navigation with intuitive controls like 'Previous' and 'Next' buttons.
6
6
  fields:
7
7
  currentPage:
8
8
  type: numeric
@@ -4,3 +4,4 @@
4
4
  // Module template
5
5
  import "./search.twig";
6
6
  import "./search.wingsuit.yml";
7
+ import "./search.behavior";
@@ -0,0 +1,15 @@
1
+ import Search from "./search";
2
+
3
+ Drupal.behaviors.search = {
4
+ attach() {
5
+ Array.prototype.forEach.call(
6
+ document.querySelectorAll(`[data-loadcomponent="Search"]`),
7
+ (element) => {
8
+ if (!element.dataset.jsProcessed) {
9
+ new Search(element);
10
+ element.dataset.jsProcessed = true;
11
+ }
12
+ }
13
+ );
14
+ },
15
+ };
@@ -0,0 +1,103 @@
1
+ import { EVENTS, ARIA } from "@ilo-org/utils";
2
+
3
+ /**
4
+ * The Search module which handles the clear button.
5
+ *
6
+ * @class Search
7
+ */
8
+ export default class Search {
9
+ /**
10
+ * Search constructor which assigns the element passed into the constructor
11
+ * to the `this.element` property for later reference
12
+ *
13
+ * @param {HTMLElement} element - REQUIRED - the module's container
14
+ */
15
+ constructor(element) {
16
+ /**
17
+ * Reference to the DOM element that is the root of the component
18
+ * @property {Object}
19
+ */
20
+ this.element = element;
21
+ this.multipleExpanded = false;
22
+
23
+ // Initialize the view
24
+ this.init();
25
+ }
26
+
27
+ /**
28
+ * Initializes the view by calling the functions to
29
+ * create DOM references, setup event handlers and
30
+ * then create the event listeners
31
+ *
32
+ * @return {Object} Search A reference to the instance of the class
33
+ * @chainable
34
+ */
35
+ init() {
36
+ this.cacheDomReferences().setupHandlers().enable();
37
+
38
+ return this;
39
+ }
40
+
41
+ /**
42
+ * Find all necessary DOM elements used in the view and cache them
43
+ *
44
+ * @return {Object} Search A reference to the instance of the class
45
+ * @chainable
46
+ */
47
+ cacheDomReferences() {
48
+ /**
49
+ * The field that a user interacts with on a form
50
+ * @type {Object}
51
+ */
52
+ this.searchButton = this.element.querySelector(
53
+ ".ilo--searchfield--clear-button"
54
+ );
55
+ this.searchInputField = this.element.querySelector(".ilo--input");
56
+ return this;
57
+ }
58
+
59
+ /**
60
+ * Bind event handlers with the proper context of `this`.
61
+ *
62
+ * @return {Object} Search A reference to the current instance of the class
63
+ * @chainable
64
+ */
65
+ setupHandlers() {
66
+ this.onClick = this.onClick.bind(this);
67
+ this.KeyPressHandler = this.onKeyPress.bind(this);
68
+ return this;
69
+ }
70
+
71
+ /**
72
+ * Creates event listeners to enable interaction with view
73
+ *
74
+ * @return {Object} Search A reference to the instance of the class
75
+ * @chainable
76
+ */
77
+ enable() {
78
+ this.searchButton.addEventListener(EVENTS.CLICK, this.onClick.bind(this));
79
+ this.searchInputField.addEventListener(
80
+ "keyup",
81
+ this.onKeyPress.bind(this, this.searchButton)
82
+ );
83
+
84
+ return this;
85
+ }
86
+
87
+ /**
88
+ * Onclick interaction with the clear button
89
+ */
90
+ onClick(e) {
91
+ this.searchInputField.value = "";
92
+ this.searchButton.classList.remove("show");
93
+ }
94
+
95
+ onKeyPress(searchButton, e) {
96
+ const inputValue = e.target.value.trim();
97
+ if (inputValue !== "") {
98
+ this.searchButton.classList.add("show");
99
+ } else {
100
+ this.searchButton.classList.remove("show");
101
+ }
102
+ }
103
+ }
@@ -6,17 +6,26 @@
6
6
  {% set searchClass = [baseClass, class] %}
7
7
  {% set inputClass = prefix ~ "--input" %}
8
8
  {% set buttonClass = baseClass ~ "--button" %}
9
+ {% set fieldSetClass = prefix ~ "--fieldset" %}
10
+ {% set clearButtonClass = baseClass ~ "--clear-button" %}
9
11
 
10
12
  {% if error %}
11
13
  {% set inputClass = inputClass|merge([baseClass ~ "__error"]) %}
12
14
  {% endif %}
13
15
 
14
-
15
16
  {% block formfield %}
16
-
17
- <div class="{{ searchClass|join(" ") }}" {% if style %} style={{ style }} {% endif %}>
17
+ <div data-loadcomponent="Search" class="{{ searchClass|join(" ") }}" {% if style %} style={{ style }} {% endif %}>
18
+ <div class="{{fieldSetClass}}">
18
19
  <input name="{{name}}" type="{{type}}" class="{{ inputClass }}{% if error %} error{% endif %}" {% if placeholder %} placeholder="{{placeholder}}" {% endif %} {% if disabled %} disabled {% endif %} {% if required %} required {% endif %} id="{% if id %}{{id}}{% else %}{{name}}{% endif %}"/>
20
+ <span class="{{clearButtonClass}}" >
21
+ {% include "@components/icon/icon.twig" with {
22
+ "name": "Close",
23
+ "size": "24",
24
+ "color": "#230050"
25
+ } %}
26
+ </span>
27
+ </div>
19
28
  <input class="{{ buttonClass }}" type="submit"/>
20
- </div>
21
29
 
30
+ </div>
22
31
  {% endblock %}
@@ -1,23 +1,47 @@
1
- {#
2
- TABLE OF CONTENTS COMPONENT
3
- #}
1
+ {# tableofcontents.twig #}
2
+
3
+ {% set openbutton_size = openbutton.size|default("medium") %}
4
+ {% set openbutton_type = openbutton.type|default("secondary") %}
5
+ {% set openbutton_label = openbutton.label|default("Open") %}
6
+ {% set openbutton_label = openbutton.label|default("Open") %}
7
+ {% set closebutton_label = closebutton.label|default("Close") %}
8
+
4
9
  {% if items %}
5
- <div class="{{prefix}}--table-of-contents--wrapper" data-loadcomponent="TableOfContents" data-prefix="{{prefix}}">
6
- <div class="{{prefix}}--table-of-contents--trigger">
7
- {% include '@components/button/button.twig' with openbutton %}
8
- </div>
9
- <div class="{{prefix}}--table-of-contents--modal">
10
- <h3 class="{{prefix}}--table-of-contents--headline">{{headline}}</h3>
11
- {% include '@components/button/button.twig' with closebutton %}
12
- </div>
13
- <nav class="{{prefix}}--table-of-contents">
14
- <ul class="{{prefix}}--table-of-contents--list">
15
- {% for item in items %}
16
- <li class="{{prefix}}--table-of-contents--list--item">
17
- <a class="{{prefix}}--table-of-contents--link" href="{{item.href}}">{{item.label}}</a>
18
- </li>
19
- {% endfor %}
20
- </ul>
21
- </nav>
22
- </div>
10
+ <div class="{{prefix}}--table-of-contents--wrapper" data-loadcomponent="TableOfContents" data-prefix="{{prefix}}">
11
+ <div class="{{prefix}}--table-of-contents--trigger">
12
+ {% include '@components/button/button.twig' with {
13
+ prefix: prefix,
14
+ size: openbutton_size,
15
+ type: openbutton_type,
16
+ label: openbutton_label,
17
+ opensmodal: true,
18
+ className: "toc--modal--open"
19
+ } only %}
20
+ </div>
21
+ <div class="{{prefix}}--table-of-contents--modal">
22
+ <h3 class="{{prefix}}--table-of-contents--headline">{{headline}}</h3>
23
+ {% include '@components/button/button.twig' with {
24
+ prefix: prefix,
25
+ size: "large",
26
+ type: "tertiary",
27
+ label: closebutton_label,
28
+ icon: {
29
+ name: "close",
30
+ size: 24,
31
+ },
32
+ iconPos: "center",
33
+ icononly: true,
34
+ className: "toc--modal--close"
35
+ } only %}
36
+ </div>
37
+ <nav class="{{prefix}}--table-of-contents">
38
+ <ul class="{{prefix}}--table-of-contents--list">
39
+ {% for item in items %}
40
+ <li class="{{prefix}}--table-of-contents--list--item">
41
+ <a class="{{prefix}}--table-of-contents--link" href="{{item.href}}">{{item.label}}</a>
42
+ </li>
43
+ {% endfor %}
44
+ </ul>
45
+ </nav>
46
+ </div>
23
47
  {% endif %}
@@ -7,26 +7,18 @@ tableofcontents:
7
7
  openbutton:
8
8
  type: object
9
9
  label: Open Button
10
- description: The label and settings for the button that will show the table of contents at small breakpoints
10
+ description: Settings for the button that will show the table of contents at small breakpoints. Only the `size`, `type` and `label` properties will be passed to the underlying button.
11
11
  preview:
12
12
  size: "medium"
13
13
  type: "secondary"
14
- label: "Open Button"
15
- className: "toc--modal--open"
16
- opensmodal: true
14
+ label: "Open"
17
15
  required: true
18
16
  closebutton:
19
17
  type: object
20
18
  label: Close Button
21
- description: Label and settings for the "close" button
19
+ description: Settings for the button that closes the table of contents at small breakpoints. Only the `label` property will be passed to the underlying button.
22
20
  preview:
23
- size: "large"
24
- type: "tertiary"
25
- label: "Close Button"
26
- icon: close
27
- iconPos: center
28
- icononly: true
29
- className: "toc--modal--close"
21
+ label: "Close"
30
22
  headline:
31
23
  type: string
32
24
  label: Headline
@@ -1,4 +1,4 @@
1
- import { EVENTS } from "@ilo-org/utils";
1
+ import "videojs-youtube";
2
2
  import videojs from "video.js";
3
3
 
4
4
  /**
@@ -37,11 +37,7 @@ export default class Video {
37
37
  * @chainable
38
38
  */
39
39
  init() {
40
- this.cacheDomReferences()
41
- .start()
42
- .cacheVideoReferences()
43
- .setupHandlers()
44
- .enable();
40
+ this.cacheDomReferences().start().setupHandlers().enable();
45
41
 
46
42
  return this;
47
43
  }
@@ -64,28 +60,6 @@ export default class Video {
64
60
  return this;
65
61
  }
66
62
 
67
- /**
68
- * Find all necessary DOM elements inside videojs
69
- *
70
- * @return {Object} Video A reference to the instance of the class
71
- * @chainable
72
- */
73
- cacheVideoReferences() {
74
- /**
75
- * The button for video play control
76
- * @type {?Element}
77
- */
78
- this.PlayButton = this.element.querySelector(".vjs-play-control");
79
-
80
- /**
81
- * The duration display
82
- * @type {?Element}
83
- */
84
- this.Duration = this.element.querySelector(".vjs-duration");
85
-
86
- return this;
87
- }
88
-
89
63
  /**
90
64
  * Bind event handlers with the proper context of `this`.
91
65
  *
@@ -93,29 +67,19 @@ export default class Video {
93
67
  * @chainable
94
68
  */
95
69
  setupHandlers() {
96
- this.onDurationHover = this.onDurationHover.bind(this);
97
-
98
70
  return this;
99
71
  }
100
72
 
101
73
  /**
102
- * Creates event listeners to fix duration hover
103
- * https://github.com/international-labour-organization/designsystem/issues/521
74
+ * Creates event listeners to enable interaction with view
104
75
  *
105
76
  * @return {Object} Video A reference to the instance of the class
106
77
  * @chainable
107
78
  */
108
79
  enable() {
109
- if (!this.Duration) return this;
110
- this.Duration.addEventListener(EVENTS.MOUSEOVER, () =>
111
- this.onDurationHover(true)
112
- );
113
- this.Duration.addEventListener(EVENTS.MOUSEOUT, () => {
114
- this.onDurationHover(false);
115
- });
116
-
117
80
  return this;
118
81
  }
82
+
119
83
  /**
120
84
  * Starts up videojs
121
85
  *
@@ -146,25 +110,11 @@ export default class Video {
146
110
  sources: [
147
111
  { type: this.element.dataset.vjsType, src: this.element.dataset.src },
148
112
  ],
113
+ dataSetup: {
114
+ techOrder: ["youtube"],
115
+ },
149
116
  });
150
117
 
151
118
  return this;
152
119
  }
153
-
154
- /**
155
- * Controls duration hover
156
- *
157
- * @param {boolean} state - whether or not the duration is hovered
158
- * @return {Object} Video A reference to the instance of the class
159
- * @chainable
160
- */
161
- onDurationHover(state) {
162
- if (!this.PlayButton) return this;
163
- const className = `${this.controlsprefix}--play--hovered`;
164
-
165
- if (this.PlayButton.classList.contains("vjs-playing")) return this;
166
- this.PlayButton.classList.toggle(className, state);
167
-
168
- return this;
169
- }
170
120
  }
@@ -10,7 +10,8 @@
10
10
  prefix: prefix,
11
11
  src: video.src,
12
12
  tracks: video.tracks,
13
- url: url
13
+ url: url,
14
+ vjsType: vjsType
14
15
  } %}
15
16
  </div>
16
17
  <figcaption class="{{prefix}}--video--caption">{{caption}}</figcaption>
@@ -42,4 +42,41 @@ video:
42
42
  volume: "Volume"
43
43
  src: "/images/video-example.mp4"
44
44
  tracks: null
45
+
46
+ youtube_video:
47
+ namespace: Components/Media
48
+ use: "@components/video/video.twig"
49
+ label: Youtube Video
50
+ description: A component for displaying a video, source from YouTube.
51
+ fields:
52
+ alt:
53
+ type: string
54
+ label: Alt
55
+ description: alt text for the image
56
+ required: true
57
+ preview: "The ILO logo animates into view"
58
+ caption:
59
+ type: string
60
+ label: Caption
61
+ description: string
62
+ preview: "The ILO brings together governments, employers and workers to set labour standards and promote decent work."
63
+ video:
64
+ type: object
65
+ label: Video
66
+ description: video player settings
67
+ required: true
68
+ preview:
69
+ controls:
70
+ fullscreen: "Fullscreen"
71
+ play: "Play"
72
+ pause: "Pause"
73
+ volume: "Volume"
74
+ src: "https://www.youtube.com/watch?v=55xQTgUJqhQ&ab_channel=InternationalLabourOrganization"
75
+ tracks: null
76
+ vjsType:
77
+ type: string
78
+ label: Source Type
79
+ description: The source type of video, required for youtube embedded videos
80
+ required: false
81
+ preview: "video/youtube"
45
82
  visibility: storybook
@@ -6,4 +6,3 @@ VIDEO PLAYER SUB-COMPONENT
6
6
  <video class="{{prefix}}--video--element" poster="{{poster.src}}">
7
7
  </video>
8
8
  </div>
9
-