@ilo-org/twig 0.12.0 → 0.12.2

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.
@@ -1,9 +1,9 @@
1
1
 
2
- > @ilo-org/twig@0.12.0 build:lib /home/runner/work/designsystem/designsystem/packages/twig
2
+ > @ilo-org/twig@0.12.2 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.12.0 output /home/runner/work/designsystem/designsystem/packages/twig
7
+ > @ilo-org/twig@0.12.2 output /home/runner/work/designsystem/designsystem/packages/twig
8
8
  > node outputtwigs.js
9
9
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # @ilo-org/twig
2
2
 
3
+ ## 0.12.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 9b1d93031: Fix various styling issues with the Profile.
8
+ - 7dedac6dd: Fix Callout styles
9
+ - 1c65834a5: Change hero card date position
10
+ - 8d912f712: Make the accordion function properly inside a modal window. This also smoothens animations and simplifies the accordion styles.
11
+ - bd6fcbb9d: In Navigation, fix bug where clicking inside the Search Box would then close it immediately. This also fixes a similar issue in the context menu.
12
+ - 50ed7febf: Align source to the bottom of Stat Cards
13
+ - 44e42762f: fixed input border-radius on iOS Safari
14
+ - Updated dependencies [9b1d93031]
15
+ - Updated dependencies [1f7525b0d]
16
+ - Updated dependencies [632a16fcf]
17
+ - Updated dependencies [b8e8265ce]
18
+ - Updated dependencies [7dedac6dd]
19
+ - Updated dependencies [8d912f712]
20
+ - Updated dependencies [50ed7febf]
21
+ - Updated dependencies [44e42762f]
22
+ - @ilo-org/styles@0.11.2
23
+ - @ilo-org/fonts@0.1.2
24
+
25
+ ## 0.12.1
26
+
27
+ ### Patch Changes
28
+
29
+ - Updated dependencies [78f48eff5]
30
+ - Updated dependencies [03b3c26e4]
31
+ - @ilo-org/fonts@0.1.1
32
+ - @ilo-org/styles@0.11.1
33
+
3
34
  ## 0.12.0
4
35
 
5
36
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ilo-org/twig",
3
- "version": "0.12.0",
3
+ "version": "0.12.2",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Twig components for the ILO's Design System",
6
6
  "main": "",
@@ -23,9 +23,9 @@
23
23
  "dependencies": {
24
24
  "video.js": "^7.21.2",
25
25
  "@ilo-org/brand-assets": "0.2.0",
26
- "@ilo-org/fonts": "0.1.0",
26
+ "@ilo-org/fonts": "0.1.2",
27
27
  "@ilo-org/icons": "0.2.1",
28
- "@ilo-org/styles": "0.11.0",
28
+ "@ilo-org/styles": "0.11.2",
29
29
  "@ilo-org/themes": "0.6.1",
30
30
  "@ilo-org/utils": "0.0.11"
31
31
  },
@@ -3,14 +3,14 @@
3
3
  #}
4
4
  {% set uid = "now"|date('Uv') %}
5
5
  <li class="{{prefix}}--accordion--item" id=" {{ id }}{{ uid }}">
6
- <div class="ilo--h3">
7
- <button class="{{prefix}}--accordion--button {{prefix}}--accordion--button--{{ size|default('small') }}" aria-expanded="{{ defaultExpanded }}" aria-controls="panel-{{ id }}{{ uid }}" id="button-{{ id }}{{ uid }}">
8
- {{label}}
9
- </button>
10
- </div>
11
- <div class="{{prefix}}--accordion--panel{% if defaultExpanded == 'true'%} {{prefix}}--accordion--panel--open{% endif %} {% if scroll %} {{prefix}}--accordion--panel__scroll {% endif %}" id="panel-{{ id }}{{ uid }}" aria-labelledby="button-{{ id }}{{ uid }}" role="region">
12
- <div class="{{prefix}}--accordion--innerpanel">
13
- {{content|raw}}
14
- </div>
15
- </div>
6
+ <div class="ilo--h3">
7
+ <button class="{{prefix}}--accordion--button {{prefix}}--accordion--button--{{ size|default('small') }}" aria-expanded="{{ defaultExpanded }}" aria-controls="panel-{{ id }}{{ uid }}" id="button-{{ id }}{{ uid }}">
8
+ {{label}}
9
+ </button>
10
+ </div>
11
+ <div class="{{prefix}}--accordion--panel {% if defaultExpanded %} {{prefix}}--accordion--panel--open{% endif %} {% if scroll %} {{prefix}}--accordion--panel__scroll {% endif %}" id="panel-{{ id }}{{ uid }}" aria-labelledby="button-{{ id }}{{ uid }}" role="region">
12
+ <div class="{{prefix}}--accordion--innerpanel">
13
+ {{content|raw}}
14
+ </div>
15
+ </div>
16
16
  </li>
@@ -33,10 +33,7 @@ export default class Accordion {
33
33
  * @chainable
34
34
  */
35
35
  init() {
36
- this.cacheDomReferences()
37
- .setupHandlers()
38
- .enable()
39
- .evaluateAccordionHeights();
36
+ this.cacheDomReferences().setupHandlers().enable();
40
37
 
41
38
  return this;
42
39
  }
@@ -55,8 +52,7 @@ export default class Accordion {
55
52
  this.accordionItems = this.element.querySelectorAll(
56
53
  ".ilo--accordion--item"
57
54
  );
58
- this.multipleExpanded =
59
- this.element.getAttribute("data-multipleexpanded") === "true";
55
+ this.multipleExpanded = this.element.hasAttribute("data-multipleexpanded");
60
56
  this.accordionPanels = this.element.querySelectorAll(
61
57
  ".ilo--accordion--panel"
62
58
  );
@@ -110,22 +106,6 @@ export default class Accordion {
110
106
  return this;
111
107
  }
112
108
 
113
- /**
114
- * Evaluate accordion panel heights
115
- *
116
- * @chainable
117
- */
118
- evaluateAccordionHeights() {
119
- this.accordionPanels.forEach((item) => {
120
- item.style.setProperty(
121
- "--height",
122
- item.querySelector(".ilo--accordion--innerpanel").scrollHeight + "px"
123
- );
124
- });
125
-
126
- return this;
127
- }
128
-
129
109
  /**
130
110
  * Update accordion items based off of new statuses
131
111
  *
@@ -163,11 +143,11 @@ export default class Accordion {
163
143
  * @chainable
164
144
  */
165
145
  collapseSection(element) {
146
+ element.classList.remove("ilo--accordion--panel--open");
166
147
  element.parentElement
167
148
  .querySelector(".ilo--accordion--button")
168
149
  .setAttribute(ARIA.EXPANDED, "false");
169
150
  element.setAttribute(ARIA.HIDDEN, "false");
170
- element.classList.remove("ilo--accordion--panel--open");
171
151
  }
172
152
 
173
153
  /**
@@ -1,9 +1,8 @@
1
- {#
2
- ACCORDION COMPONENT
3
- #}
4
- <ul class="{{prefix}}--accordion" data-loadcomponent="Accordion" data-multipleexpanded="{{ allowMultipleExpanded|default(false) }}">
5
- {% for item in items %}
6
- {% include "@components/accordion/accordion-item.twig" with {
1
+ {# accordion.twig #}
2
+
3
+ <ul class="{{prefix}}--accordion" data-loadcomponent="Accordion" {% if allowMultipleExpanded %} data-multipleexpanded {% endif %}>
4
+ {% for item in items %}
5
+ {% include "@components/accordion/accordion-item.twig" with {
7
6
  label: item.label,
8
7
  content: item.content,
9
8
  defaultExpanded: item.defaultExpanded,
@@ -13,5 +12,5 @@
13
12
  prefix: prefix,
14
13
  scroll: item.scroll
15
14
  } only %}
16
- {% endfor %}
15
+ {% endfor %}
17
16
  </ul>
@@ -1,24 +1,30 @@
1
1
  {#
2
2
  CALLOUT COMPONENT
3
3
  #}
4
- <div class="{{prefix}}--callout {{prefix}}--callout--{{alert}} {% if isCollapsible == "true" and isOpen == "true" %} {{prefix}}--callout--open {% endif %} {% if isCollapsible == "true" %} {{prefix}}--callout--collapse {% endif %}" data-loadcomponent="Callout" >
5
- <div class="{{prefix}}--callout--sidebar">
6
- <span class="{{prefix}}--callout--icon icon icon--{{alert}}"></span>
7
- </div>
8
- <div class="{{prefix}}--callout--content">
9
- <div class="{{prefix}}--callout--header">
10
- <h5 class="{{prefix}}--callout--title">{{ title }}</h5>
11
- {% if isCollapsible == "true" %}
12
- <button class="{{prefix}}--callout--toggle" type="button" data-open="{{ toggleOpenLabel }}" data-closed="{{ toggleClosedLabel }}">
13
- <span class="{{prefix}}--callout--button-text">{% if isOpen %}{{ toggleOpenLabel }}{% else %}{{ toggleClosedLabel }}{% endif %}</span>
14
- <span class="{{prefix}}--callout--toggle--icon" role="presentation"></span>
15
- </button>
16
- {% endif %}
17
- </div>
18
- {{ content }}
19
- {% if button %}
20
- <div class="{{prefix}}--callout--footer">
21
- {% include '@components/button/button.twig' with {
4
+ <div class="{{prefix}}--callout {{prefix}}--callout--{{alert}} {% if isCollapsible == "true" and isOpen == "true" %} {{prefix}}--callout--open {% endif %} {% if isCollapsible == "true" %} {{prefix}}--callout--collapse {% endif %}" data-loadcomponent="Callout">
5
+ <div class="{{prefix}}--callout--sidebar">
6
+ <span class="{{prefix}}--callout--icon icon icon--{{alert}}"></span>
7
+ </div>
8
+ <div class="{{prefix}}--callout--content">
9
+ <div class="{{prefix}}--callout--header">
10
+ <h5 class="{{prefix}}--callout--title">{{ title }}</h5>
11
+ {% if isCollapsible == "true" %}
12
+ <button class="{{prefix}}--callout--toggle" type="button" data-open="{{ toggleOpenLabel }}" data-closed="{{ toggleClosedLabel }}">
13
+ <span class="{{prefix}}--callout--button-text">
14
+ {% if isOpen %}
15
+ {{ toggleOpenLabel }}
16
+ {% else %}
17
+ {{ toggleClosedLabel }}
18
+ {% endif %}
19
+ </span>
20
+ <span class="{{prefix}}--callout--toggle--icon" role="presentation"></span>
21
+ </button>
22
+ {% endif %}
23
+ </div>
24
+ {{ content }}
25
+ {% if button %}
26
+ <div class="{{prefix}}--callout--footer">
27
+ {% include '@components/button/button.twig' with {
22
28
  label: button.label,
23
29
  url: button.url,
24
30
  target: button.target,
@@ -29,7 +35,7 @@
29
35
  size: "small",
30
36
  type: "secondary",
31
37
  } %}
32
- </div>
33
- {% endif %}
34
- </div>
38
+ </div>
39
+ {% endif %}
40
+ </div>
35
41
  </div>
@@ -20,7 +20,7 @@ callout:
20
20
  label: Content
21
21
  description: The callout's content
22
22
  preview:
23
- faker: lorem.word
23
+ faker: lorem.paragraph(3)
24
24
  title:
25
25
  type: string
26
26
  label: Notification Title
@@ -2,21 +2,23 @@
2
2
  STAT CARD COMPONENT
3
3
  #}
4
4
  <div class="{{prefix}}--card {{prefix}}--card__type__stat {{prefix}}--card__color__{{color}} {{prefix}}--card__size__{{size}}">
5
- <div class="{{prefix}}--card--wrap">
6
- <div class="{{prefix}}--card--content">
7
- {% if title %}
8
- <h5 class="{{prefix}}--card--title">{{title}}</h5>
9
- {% endif %}
10
- {% if intro %}
11
- <p class="{{prefix}}--card--intro">{{intro}}</p>
12
- {% endif %}
13
- {% if source %}
14
- {% include "@components/link/link.twig" with {
15
- url: source.url,
16
- label: source.label,
17
- prefix: prefix
18
- } only %}
19
- {% endif %}
20
- </div>
21
- </div>
5
+ <div class="{{prefix}}--card--wrap">
6
+ <div class="{{prefix}}--card--content">
7
+ {% if title %}
8
+ <h5 class="{{prefix}}--card--title">{{title}}</h5>
9
+ {% endif %}
10
+ {% if intro %}
11
+ <p class="{{prefix}}--card--intro">{{intro}}</p>
12
+ {% endif %}
13
+ {% if source %}
14
+ <div class="{{prefix}}--card--source">
15
+ {% include "@components/link/link.twig" with {
16
+ url: source.url,
17
+ label: source.label,
18
+ prefix: prefix
19
+ } only %}
20
+ </div>
21
+ {% endif %}
22
+ </div>
23
+ </div>
22
24
  </div>
@@ -14,12 +14,12 @@
14
14
  <h1 class="{{ prefix }}--hero-card--title">{{ title }}</h2>
15
15
  {% endif %}
16
16
  {% endif %}
17
- {% if datecopy %}
18
- <p class="{{ prefix }}--hero-card--datecopy">{{ datecopy }}</p>
19
- {% endif %}
20
17
  {% if intro %}
21
18
  <p class="{{ prefix }}--hero-card--intro">{{ intro }}</p>
22
19
  {% endif %}
20
+ {% if datecopy %}
21
+ <p class="{{ prefix }}--hero-card--datecopy">{{ datecopy }}</p>
22
+ {% endif %}
23
23
  {% if socialmedia %}
24
24
  {% include "@components/socialmedia/socialmedia.twig" with {
25
25
  theme: theme,
@@ -4,17 +4,17 @@
4
4
  The modal calls another Twig into it, and therefore passes `modaldata` into it. `modaldata` should contain the fields for the component in question, just as if the component were being used anywhere else.
5
5
  #}
6
6
 
7
- {% if component != 'modal' %}
8
- <div class="{{prefix}}--modal" data-loadcomponent="Modal" data-prefix="{{prefix}}">
9
- {% include '@components/button/button.twig' with openbutton %}
10
- <div class="{{prefix}}--modal--wrapper" aria-modal="true" role="alertdialog">
11
- <div class="{{prefix}}--modal--background" role="presentation"></div>
12
- <div class="{{prefix}}--modal--contents">
13
- {% block modal_content %}
14
- {% include '@components/' ~ component ~ '/' ~ component ~ '.twig' with modaldata %}
15
- {% endblock %}
16
- {% include '@components/button/button.twig' with closebutton %}
17
- </div>
18
- </div>
19
- </div>
20
- {% endif %}
7
+ {% if component != 'modal' %}
8
+ <div class="{{prefix}}--modal" data-loadcomponent="Modal" data-prefix="{{prefix}}">
9
+ {% include '@components/button/button.twig' with openbutton %}
10
+ <div class="{{prefix}}--modal--wrapper" aria-modal="true" role="alertdialog">
11
+ <div class="{{prefix}}--modal--background" role="presentation"></div>
12
+ <div class="{{prefix}}--modal--contents">
13
+ {% block modal_content %}
14
+ {% include '@components/' ~ component ~ '/' ~ component ~ '.twig' with modaldata %}
15
+ {% endblock %}
16
+ {% include '@components/button/button.twig' with closebutton %}
17
+ </div>
18
+ </div>
19
+ </div>
20
+ {% endif %}
@@ -52,6 +52,7 @@ export default class Navigation {
52
52
  * The button for toggling Subnav state
53
53
  * @type {Object}
54
54
  */
55
+ this.subNav = this.element.querySelector(`.${this.prefix}--subnav`);
55
56
  this.subnavButton = this.element.querySelector(
56
57
  `.${this.prefix}--nav--trigger`
57
58
  );
@@ -65,6 +66,7 @@ export default class Navigation {
65
66
  this.searchButton = this.element.querySelector(
66
67
  `.${this.prefix}--search--button`
67
68
  );
69
+ this.searchBox = this.element.querySelector(`.${this.prefix}--search-box`);
68
70
  this.contextButton = this.element.querySelector(
69
71
  `.${this.prefix}--language-switcher--button`
70
72
  );
@@ -99,7 +101,6 @@ export default class Navigation {
99
101
  this.contextLinkClick = this.handleContextLinkClick.bind(this);
100
102
  this.onResize = this.handleResize.bind(this);
101
103
  this.keyPress = this.handleKeyPress.bind(this);
102
- this.bodyClick = this.removeClass.bind(this);
103
104
  this.contextButtonClick = this.handleContextButtonClick.bind(this);
104
105
  this.contextButtonClickOff = this.handleContextButtonClickOff.bind(this);
105
106
  this.contextButtonClickOn = this.handleContextButtonClickOn.bind(this);
@@ -212,6 +213,24 @@ export default class Navigation {
212
213
  });
213
214
  }
214
215
 
216
+ // Click events in the searchBox should not bubble up to the body
217
+ this.searchBox.addEventListener(
218
+ EVENTS.CLICK,
219
+ (ev) => {
220
+ ev.stopPropagation();
221
+ },
222
+ false
223
+ );
224
+
225
+ // Click events in the subNav should not bubble up to the body
226
+ this.subNav.addEventListener(
227
+ EVENTS.CLICK,
228
+ (ev) => {
229
+ ev.stopPropagation();
230
+ },
231
+ false
232
+ );
233
+
215
234
  window.addEventListener(EVENTS.RESIZE, (e) => {
216
235
  if (window.innerWidth >= 1024) {
217
236
  this.onResize(e);
@@ -221,22 +240,6 @@ export default class Navigation {
221
240
  return this;
222
241
  }
223
242
 
224
- /**
225
- * Onclick interaction with the body element
226
- *
227
- * @param {String} classText - Class name to remove from the element on body click
228
- * @return {Object} Navigation A reference to the instance of the class
229
- * @chainable
230
- */
231
- removeClass(e, classText) {
232
- e.stopImmediatePropagation();
233
- e.stopPropagation();
234
-
235
- this.element.classList.remove(classText);
236
-
237
- return this;
238
- }
239
-
240
243
  /**
241
244
  * Onclick interaction with the context links
242
245
  *
@@ -295,11 +298,7 @@ export default class Navigation {
295
298
  (ev) => this.keyPress(ev, this.contextButtonClickOff),
296
299
  false
297
300
  );
298
- this.body.addEventListener(
299
- EVENTS.CLICK,
300
- (ev) => this.handleContextButtonClickOff(ev),
301
- false
302
- );
301
+ window.addEventListener(EVENTS.CLICK, this.contextButtonClickOff);
303
302
 
304
303
  return this;
305
304
  }
@@ -318,12 +317,7 @@ export default class Navigation {
318
317
  (ev) => this.keyPress(ev, this.contextButtonClickOff),
319
318
  false
320
319
  );
321
- this.body.removeEventListener(
322
- EVENTS.CLICK,
323
- (ev) =>
324
- this.handleContextButtonClickoff(ev, `${this.prefix}--context--open`),
325
- false
326
- );
320
+ window.removeEventListener(EVENTS.CLICK, this.contextButtonClickOff);
327
321
 
328
322
  return this;
329
323
  }
@@ -361,11 +355,7 @@ export default class Navigation {
361
355
  );
362
356
 
363
357
  if (window.innerWidth >= 1024) {
364
- this.body.addEventListener(
365
- EVENTS.CLICK,
366
- (ev) => this.handleSearchButtonClickOff(ev),
367
- false
368
- );
358
+ window.addEventListener(EVENTS.CLICK, this.searchButtonClickOff, false);
369
359
  }
370
360
 
371
361
  return this;
@@ -386,11 +376,7 @@ export default class Navigation {
386
376
  false
387
377
  );
388
378
 
389
- this.body.removeEventListener(
390
- EVENTS.CLICK,
391
- (ev) => this.handleSearchButtonClickOff(ev),
392
- false
393
- );
379
+ window.removeEventListener(EVENTS.CLICK, this.searchButtonClickOff, false);
394
380
 
395
381
  return this;
396
382
  }
@@ -444,11 +430,7 @@ export default class Navigation {
444
430
  );
445
431
 
446
432
  if (window.innerWidth >= 1024) {
447
- this.body.addEventListener(
448
- EVENTS.CLICK,
449
- (ev) => this.handleSubnavClickOff(ev),
450
- false
451
- );
433
+ window.addEventListener(EVENTS.CLICK, this.subnavClickOff);
452
434
  }
453
435
  return this;
454
436
  }
@@ -468,11 +450,7 @@ export default class Navigation {
468
450
  false
469
451
  );
470
452
 
471
- this.body.removeEventListener(
472
- EVENTS.CLICK,
473
- (ev) => this.handleSubnavClickOff(ev),
474
- false
475
- );
453
+ window.removeEventListener(EVENTS.CLICK, this.subnavClickOff);
476
454
 
477
455
  return this;
478
456
  }
@@ -1,18 +1,26 @@
1
- {#
2
- PROFILE COMPONENT
3
- #}
4
- <figure class="storybook {{prefix}}--profile">
5
- <img class="{{prefix}}--profile--avatar" src="{{avatar}}" alt="Avatar for {{name}}">
6
- <figcaption class="{{prefix}}--profile--contents--{{theme}}">
7
- <span class="{{prefix}}--profile--name id">{{name}}</span>
8
- {% if role %}
9
- <span class="{{prefix}}--profile--role id">{{role}}</span>
10
- {% endif %}
11
- {% if description %}
12
- <p class="{{prefix}}--profile--description info">{{description}}</p>
13
- {% endif %}
14
- {% if link and link.url and link.label %}
15
- <a class="{{prefix}}--profile--link info" href="{{link.url}}"><span>{{link.label}}</span></a>
16
- {% endif %}
17
- </figcaption>
1
+ {# profile.twig #}
2
+
3
+ {% set defaultAlt = "Photo of " ~ name %}
4
+ <figure class="{{prefix}}--profile {{prefix}}--profile__theme__{{theme|default("light")}} {{prefix}}--profile__size__{{size|default("large")}}">
5
+ {% if avatar %}
6
+ <img class="{{prefix}}--profile--avatar" src="{{avatar}}" alt="{{alt|default(defaultAlt)}}">
7
+ {% endif %}
8
+ <figcaption>
9
+ <div class="{{prefix}}--profile--figcaption--content">
10
+ <div class="{{prefix}}--profile--name">{{name}}</div>
11
+ {% if role %}
12
+ <div class="{{prefix}}--profile--role">{{role}}</div>
13
+ {% endif %}
14
+ </div>
15
+ </figcaption>
16
+ {% if description %}
17
+ <p class="{{prefix}}--profile--description">{{description}}</p>
18
+ {% endif %}
19
+ {% if link and link.url and link.label %}
20
+ <div class="{{prefix}}--profile--link">
21
+ <a href={{link.url}} target="__blank" rel="noopener noreferrer">
22
+ <span class="{{prefix}}--profile--link--label">{{link.label}}</span>
23
+ </a>
24
+ </div>
25
+ {% endif %}
18
26
  </figure>
@@ -14,7 +14,7 @@ profile:
14
14
  type: string
15
15
  label: Description
16
16
  description: An optional plain-text description (e.g. a short bio)
17
- preview: "Gilbert F. Houngbo was elected as the ILO’s 11th Director-General by the organization’s Governing Body in March 2022."
17
+ preview: "Gilbert F. Houngbo was elected as the ILO’s 11th Director-General by the organization’s Governing Body in March 2022. "
18
18
  link:
19
19
  type: object
20
20
  label: Link