@ilo-org/twig 1.8.6 → 1.10.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 (95) hide show
  1. package/README.md +101 -0
  2. package/dist/components/card_detail/card_detail.twig +8 -1
  3. package/dist/components/dropdown/dropdown.twig +3 -3
  4. package/dist/components/icon/icon.behavior.js +835 -610
  5. package/dist/components/icon/icon.twig +1 -1
  6. package/dist/components/image/image.component.yml +7 -0
  7. package/dist/components/image/image.twig +18 -6
  8. package/dist/components/image/image.wingsuit.yml +7 -0
  9. package/dist/components/linklist/linklist.component.yml +11 -0
  10. package/dist/components/linklist/linklist.twig +3 -1
  11. package/dist/components/linklist/linklist.wingsuit.yml +11 -0
  12. package/dist/components/list/list.component.yml +11 -0
  13. package/dist/components/list/list.twig +2 -1
  14. package/dist/components/list/list.wingsuit.yml +11 -0
  15. package/dist/components/nav/desktop/navmenu.twig +2 -3
  16. package/dist/components/nav/desktop/navsearch.twig +24 -0
  17. package/dist/components/nav/mobile/mobiledrawer_main.twig +27 -8
  18. package/dist/components/nav/nav.behavior.js +1 -1
  19. package/dist/components/nav/nav.component.yml +63 -4
  20. package/dist/components/nav/nav.twig +3 -1
  21. package/dist/components/nav/nav.wingsuit.yml +63 -4
  22. package/dist/components/nav/nav_compact.twig +2 -1
  23. package/dist/components/nav/nav_complex.twig +2 -2
  24. package/dist/components/nav/nav_main.twig +135 -0
  25. package/dist/components/socialmedia/socialmedia.component.yml +20 -0
  26. package/dist/components/socialmedia/socialmedia.twig +3 -1
  27. package/dist/components/socialmedia/socialmedia.wingsuit.yml +20 -0
  28. package/dist/components/tableofcontents/tableofcontents.twig +12 -12
  29. package/dist/components/video/video.twig +1 -1
  30. package/dist/styles/components/accordion.css +1 -1
  31. package/dist/styles/components/blockquote.css +1 -1
  32. package/dist/styles/components/breadcrumb.css +1 -1
  33. package/dist/styles/components/button.css +1 -1
  34. package/dist/styles/components/callout.css +1 -1
  35. package/dist/styles/components/card.css +1 -1
  36. package/dist/styles/components/cardgroup.css +1 -1
  37. package/dist/styles/components/checkbox.css +1 -1
  38. package/dist/styles/components/container.css +1 -1
  39. package/dist/styles/components/contextmenu.css +1 -1
  40. package/dist/styles/components/datacard.css +1 -1
  41. package/dist/styles/components/datepicker.css +1 -1
  42. package/dist/styles/components/detailcard.css +1 -1
  43. package/dist/styles/components/dropdown.css +1 -1
  44. package/dist/styles/components/empty.css +1 -1
  45. package/dist/styles/components/factlistcard.css +1 -1
  46. package/dist/styles/components/featurecard.css +1 -1
  47. package/dist/styles/components/fieldset.css +1 -1
  48. package/dist/styles/components/file-upload.css +1 -1
  49. package/dist/styles/components/footer.css +1 -1
  50. package/dist/styles/components/form.css +1 -1
  51. package/dist/styles/components/formcontrol.css +1 -1
  52. package/dist/styles/components/hero.css +1 -1
  53. package/dist/styles/components/herocard.css +1 -1
  54. package/dist/styles/components/image.css +1 -1
  55. package/dist/styles/components/input.css +1 -1
  56. package/dist/styles/components/languagetoggle.css +1 -1
  57. package/dist/styles/components/link.css +1 -1
  58. package/dist/styles/components/linklist.css +1 -1
  59. package/dist/styles/components/list.css +1 -1
  60. package/dist/styles/components/loading.css +1 -1
  61. package/dist/styles/components/logogrid.css +1 -1
  62. package/dist/styles/components/modal.css +1 -1
  63. package/dist/styles/components/multilinkcard.css +1 -1
  64. package/dist/styles/components/navigation.css +1 -1
  65. package/dist/styles/components/notification.css +1 -1
  66. package/dist/styles/components/pagination.css +1 -1
  67. package/dist/styles/components/profile.css +1 -1
  68. package/dist/styles/components/promocard.css +1 -1
  69. package/dist/styles/components/radio.css +1 -1
  70. package/dist/styles/components/readmore.css +1 -1
  71. package/dist/styles/components/richtext.css +1 -1
  72. package/dist/styles/components/scorecard.css +1 -1
  73. package/dist/styles/components/searchfield.css +1 -1
  74. package/dist/styles/components/socialmedia.css +1 -1
  75. package/dist/styles/components/statcard.css +1 -1
  76. package/dist/styles/components/status.css +1 -1
  77. package/dist/styles/components/table.css +1 -1
  78. package/dist/styles/components/tableofcontents.css +1 -1
  79. package/dist/styles/components/tabs.css +1 -1
  80. package/dist/styles/components/tag.css +1 -1
  81. package/dist/styles/components/textarea.css +1 -1
  82. package/dist/styles/components/textcard.css +1 -1
  83. package/dist/styles/components/textinput.css +1 -1
  84. package/dist/styles/components/toggle.css +1 -1
  85. package/dist/styles/components/tooltip.css +1 -1
  86. package/dist/styles/components/video.css +1 -1
  87. package/dist/styles/global.css +1 -1
  88. package/dist/styles/global.css.map +1 -1
  89. package/dist/styles/index.css +4 -2
  90. package/dist/styles/index.css.map +1 -1
  91. package/dist/styles/monorepo.css +4 -2
  92. package/dist/styles/monorepo.css.map +1 -1
  93. package/package.json +16 -17
  94. package/dist/styles/components/credit.css +0 -1
  95. package/dist/styles/components/heading.css +0 -1
@@ -1 +1 @@
1
- <svg class="ilo--icon" data-name="{{name}}" data-size="{{size}}" data-color="{{color}}" data-loadcomponent="Icon" aria-hidden="true"></svg>
1
+ <svg class="ilo--icon{% if class %} {{class}}{% endif %}" data-name="{{name}}" data-size="{{size}}" data-color="{{color}}" data-loadcomponent="Icon" aria-hidden="true"></svg>
@@ -51,4 +51,11 @@ image:
51
51
  description: Is this image in a hero? If true, and credit exists, will display credit in a title attribute
52
52
  preview: false
53
53
  required: false
54
+ theme:
55
+ type: select
56
+ label: Theme
57
+ description: The theme to be used for the Image component.
58
+ options:
59
+ light: light
60
+ dark: dark
54
61
  visibility: storybook
@@ -1,9 +1,10 @@
1
1
  {#
2
2
  IMAGE COMPONENT
3
3
  #}
4
- <figure class="ilo--image" data-prefix="ilo">
4
+ {% set theme = theme|default("light") %}
5
+ <figure class="ilo--image ilo--image__theme__{{theme}}" data-prefix="ilo">
5
6
  <div class="image ilo--image--wrapper">
6
- <picture class="ilo--image--img" {% if credit and ishero and ishero != 'false' %}title="{{credit}}"{% endif %}>
7
+ <picture {% if credit and ishero and ishero != 'false' %}title="{{credit}}"{% endif %}>
7
8
  {% for img in url|reverse %}
8
9
  {% if loop.last == false %}
9
10
  {% if img.breakpoint matches '/^\\d+$/' %}
@@ -17,13 +18,24 @@
17
18
  </picture>
18
19
  {% if not ishero or ishero =='false' %}
19
20
  {% if credit %}
20
- <span class="ilo--credit">
21
- <span class="ilo--credit--label">{{credit}}</span>
22
- </span>
21
+ <div class="ilo--image--credit">
22
+ <div class="ilo--image--tooltip">
23
+ {% include '@components/tooltip/tooltip.twig' with {
24
+ prefix: prefix,
25
+ label: credit,
26
+ icon: true,
27
+ theme: theme,
28
+ icontheme: theme == 'dark' ? 'light' : 'dark'
29
+ } only %}
30
+ </div>
31
+ <div class="ilo--image--label">
32
+ {{credit}}
33
+ </div>
34
+ </div>
23
35
  {% endif %}
24
36
  {% endif %}
25
37
  </div>
26
38
  {% if caption %}
27
- <figcaption class="ilo--image--caption">{{caption}}</figcaption>
39
+ <figcaption>{{caption}}</figcaption>
28
40
  {% endif %}
29
41
  </figure>
@@ -51,4 +51,11 @@ image:
51
51
  description: Is this image in a hero? If true, and credit exists, will display credit in a title attribute
52
52
  preview: false
53
53
  required: false
54
+ theme:
55
+ type: select
56
+ label: Theme
57
+ description: The theme to be used for the Image component.
58
+ options:
59
+ light: light
60
+ dark: dark
54
61
  visibility: storybook
@@ -52,4 +52,15 @@ linklist:
52
52
  light: Light
53
53
  dark: Dark
54
54
  preview: "light"
55
+ titleLevel:
56
+ type: select
57
+ label: Headline Title Level
58
+ description: Select the title level for the headline.
59
+ required: false
60
+ options:
61
+ h2: h2
62
+ h3: h3
63
+ h4: h4
64
+ h5: h5
65
+ preview: "h3"
55
66
  visibility: storybook
@@ -1,9 +1,11 @@
1
1
  {#
2
2
  LINK LIST COMPONENT
3
3
  #}
4
+ {% set titleLevel = titleLevel|default('h3') %}
5
+
4
6
  <div class="ilo--link-list ilo--link-list--{{theme}}" data-loadcomponent="LinkList" data-prefix="ilo">
5
7
  {% if headline %}
6
- <h3 class="ilo--link-list--headline">{{headline}}</h3>
8
+ <{{titleLevel}} class="ilo--link-list--headline">{{headline}}</{{titleLevel}}>
7
9
  {% endif %}
8
10
  <ul class="ilo--link-list--linkgroups">
9
11
  {% for group in linkgroup %}
@@ -52,4 +52,15 @@ linklist:
52
52
  light: Light
53
53
  dark: Dark
54
54
  preview: "light"
55
+ titleLevel:
56
+ type: select
57
+ label: Headline Title Level
58
+ description: Select the title level for the headline.
59
+ required: false
60
+ options:
61
+ h2: h2
62
+ h3: h3
63
+ h4: h4
64
+ h5: h5
65
+ preview: "h3"
55
66
  visibility: storybook
@@ -64,4 +64,15 @@ list:
64
64
  options:
65
65
  light: light
66
66
  dark: dark
67
+ titleLevel:
68
+ type: select
69
+ label: Headline Title Level
70
+ description: Select the title level for the headline.
71
+ required: false
72
+ options:
73
+ h2: h2
74
+ h3: h3
75
+ h4: h4
76
+ h5: h5
77
+ preview: "h2"
67
78
  visibility: storybook
@@ -8,10 +8,11 @@
8
8
  {% set theme = "light" %}
9
9
  {% endif %}
10
10
 
11
+ {% set titleLevel = titleLevel|default('h2') %}
11
12
 
12
13
  <div class="ilo--list {% if ordered == 'unstyled' %} ilo--list__unstyled {% endif %} {% if alignment == 'horizontal' %} ilo--list__horizontal {% endif %} ilo--list__theme__{{theme}}">
13
14
  {% if title %}
14
- <h2 class="ilo--list--title">{{ title }}</h2>
15
+ <{{ titleLevel }} class="ilo--list--title">{{ title }}</{{ titleLevel }}>
15
16
  {% endif %}
16
17
  {% if ordered == "ordered" %}
17
18
  <ol>
@@ -64,4 +64,15 @@ list:
64
64
  options:
65
65
  light: light
66
66
  dark: dark
67
+ titleLevel:
68
+ type: select
69
+ label: Headline Title Level
70
+ description: Select the title level for the headline.
71
+ required: false
72
+ options:
73
+ h2: h2
74
+ h3: h3
75
+ h4: h4
76
+ h5: h5
77
+ preview: "h2"
67
78
  visibility: storybook
@@ -2,8 +2,7 @@
2
2
 
3
3
  {% set prefix = prefix|default('ilo') %}
4
4
  {% set base_class = 'ilo' ~ '--nav-menu' %}
5
-
6
- <div class="{{ base_class }} {{ className }}">
5
+ <div class="{{ base_class }} {{ className }} {% if light|boolval %}{{ base_class }}--light{% endif %}">
7
6
  <ul class="{{ base_class }}__list">
8
7
  {% for item in menu %}
9
8
  <li class="{{ base_class }}__item {{ item.className }}">
@@ -18,7 +17,7 @@
18
17
  class="{{ base_class }}__more"
19
18
  aria-expanded="false"
20
19
  aria-haspopup="menu"
21
- aria-controls="{{ prefix }}--nav-dropdown"
20
+ aria-controls="{{ prefix }}__nav-extra-menu"
22
21
  id="{{ prefix }}--nav-dropdown__button">
23
22
  {{ more.label }}
24
23
  <span class="{{ base_class }}__more-icon"></span>
@@ -0,0 +1,24 @@
1
+ {# navsearch.twig #}
2
+ {% set prefix = prefix|default("ilo") %}
3
+ {% set base_class = 'ilo' ~ "--nav-dropdown" %}
4
+
5
+ <template id="{{ prefix }}--nav-search__template">
6
+ <div class="{{ base_class }} {{ className|default("") }}" id="{{ base_class }}" tabindex="0">
7
+ <div class="{{ base_class }}__container">
8
+ {% include '@components/form/form.twig' with {
9
+ attributes: {
10
+ action: search.url,
11
+ "aria-label": search.label,
12
+ "data-search": "true",
13
+ },
14
+ fieldsets: [{
15
+ fields: [{
16
+ type: "search",
17
+ placeholder: search.label,
18
+ id: 'ilo' ~ '__widgets-search-input-field',
19
+ }]
20
+ }]
21
+ } %}
22
+ </div>
23
+ </div>
24
+ </template>
@@ -9,14 +9,33 @@
9
9
  {% endblock %}
10
10
 
11
11
  {% block mobile_drawer_widgets %}
12
- {% if widgets.search %}
13
- <a class="{{ mobile_class }}__widgets-search" href="{{ widgets.search.url }}" aria-label="{{ widgets.search.label }}">
14
- <span class="{{ mobile_class }}__widgets-search__label">
15
- {{ widgets.search.label }}
16
- </span>
17
- <span class="{{ mobile_class }}__widgets-search__icon" />
18
- </a>
19
- {% endif %}
12
+ {# Search Widget #}
13
+ {% if inputSearch|boolval %}
14
+ <div class="{{ mobile_class }}__widgets-search-input">
15
+ {% include '@components/form/form.twig' with {
16
+ attributes: {
17
+ action: widgets.search.url,
18
+ "aria-label": widgets.search.label,
19
+ "data-search": "true",
20
+ },
21
+ fieldsets: [{
22
+ fields: [{
23
+ type: "search",
24
+ placeholder: widgets.search.label,
25
+ id: prefix|default("ilo") ~ '__widgets-search-input-field',
26
+ }]
27
+ }]
28
+ }
29
+ %}
30
+ </div>
31
+ {% elseif widgets.search %}
32
+ <a class="{{ mobile_class }}__widgets-search" href="{{ widgets.search.url }}" aria-label="{{ widgets.search.label }}">
33
+ <span class="{{ mobile_class }}__widgets-search__label">
34
+ {{ widgets.search.label }}
35
+ </span>
36
+ <span class="{{ mobile_class }}__widgets-search__icon"/>
37
+ </a>
38
+ {% endif %}
20
39
 
21
40
  {% if widgets.link %}
22
41
  <a class="{{ mobile_class }}__widgets-link" href="{{ widgets.link.href }}">{{ widgets.link.label }}</a>
@@ -7,7 +7,7 @@
7
7
 
8
8
  class StatefulComponent{constructor(element,initialState={}){this.element=element;this.initialState=initialState;this.state=this.#setupState(this.initialState);this.stateHandlers=new Map;this.#init();}#init(){this.setupState=this.#setupState.bind(this);this.registerStateHandler=this.registerStateHandler.bind(this);}registerStateHandler(prop,handler){if(!this.stateHandlers.has(prop)){this.stateHandlers.set(prop,[]);}this.stateHandlers.get(prop).push(handler);}#setupState(initialState){if(initialState===void 0)initialState={};return new Proxy(initialState,{set:(target,prop,value)=>{if(value!==target[prop]){target[prop]=value;const handlers=this.stateHandlers.get(prop);if(handlers){handlers.forEach(handler=>handler(value,prop));}}return true}})}}
9
9
 
10
- class Nav extends StatefulComponent{constructor(element){const initialState={dropDownIsOpen:false,isDesktop:true};super(element,initialState);this.startBreakpointObserver=()=>{this.breakpointObserver.start();return this};this.renderClientContent=()=>{const dropdownTemplate=this.element.querySelector(`#${this.prefix}--nav-dropdown__template`);if(dropdownTemplate){const dropdownContent=dropdownTemplate.content.cloneNode(true);document.body.appendChild(dropdownContent);}return this};this.cacheDomReferences=()=>{this.dropdownButton=this.element.querySelector(`.${this.prefix}--nav-menu__more`);this.dropdown=document.body.querySelector(`.${this.prefix}--nav-dropdown`);return this};this.enableHandlers=()=>{if(this.dropdownButton){this.dropdownButton.addEventListener("click",this.handleDropdownClick);}return this};this.registerStateHandlers=()=>{this.registerStateHandler("dropDownIsOpen",value=>{if(value){this.handleOpenDropdown();}else {this.handleCloseDropdown();}});this.registerStateHandler("isDesktop",this.handleBreakpointChange);return this};this.handleBreakpointChange=isDesktop=>{if(!isDesktop){this.state.dropDownIsOpen=false;}};this.handleOpenDropdown=()=>{this.handleResizeDropdown();this.resizeObserver.observe(this.element);window.addEventListener("click",this.handleOutsideClick);this.dropdown?.classList.add(`${this.prefix}--nav-dropdown--open`);this.dropdownButton.setAttribute("aria-expanded","true");this.dropdownButton?.classList.add(`${this.prefix}--nav-menu__more--open`);this.handleTabNavigation();};this.handleCloseDropdown=()=>{this.dropdown?.classList.remove(`${this.prefix}--nav-dropdown--open`);this.dropdownButton?.classList.remove(`${this.prefix}--nav-menu__more--open`);this.dropdownButton.setAttribute("aria-expanded","false");this.resizeObserver.disconnect();window.removeEventListener("click",this.handleOutsideClick);};this.handleResizeDropdown=()=>{this.dropdown.style.width=`${this.element.offsetWidth}px`;this.dropdown.style.left=`${this.element.getBoundingClientRect().left}px`;this.dropdown.style.top=`${this.element.getBoundingClientRect().bottom}px`;};this.handleDropdownClick=()=>{this.state.dropDownIsOpen=!this.state.dropDownIsOpen;};this.handleOutsideClick=event=>{if(this.state.dropDownIsOpen&&!this.element?.contains(event.target)&&!this.dropdown?.contains(event.target)){this.state.dropDownIsOpen=false;}};this.handleFocusTrap=event=>{createFocusTrap(event,this.dropdown.querySelectorAll("a"),()=>{this.state.dropDownIsOpen=false;this.dropdownButton.focus();});};this.handleTabNavigation=()=>{setTimeout(()=>{this.dropdown.focus();this.dropdown.addEventListener("keydown",this.handleFocusTrap);},100);};this.prefix=this.element.dataset.prefix;this.dropdown=null;this.breakpointObserver=createBreakpointObserver(breakpoint=>{this.state.isDesktop=["xl","xxl"].includes(breakpoint);});this.resizeObserver=new ResizeObserver(()=>{if(this.state.dropDownIsOpen){this.handleResizeDropdown();}});this.init();}init(){this.renderClientContent().cacheDomReferences().enableHandlers().registerStateHandlers().startBreakpointObserver();return this}}
10
+ class Nav extends StatefulComponent{constructor(element){const initialState={dropDownIsOpen:false,searchIsOpen:false,isDesktop:true};super(element,initialState);this.startBreakpointObserver=()=>{this.breakpointObserver.start();return this};this.renderClientContent=()=>{const items=[`#${this.prefix}--nav-dropdown__template`,`#${this.prefix}--nav-search__template`];for(const templateSelector of items){const template=document.querySelector(templateSelector);if(template){const content=template.content.cloneNode(true);document.body.appendChild(content);}}return this};this.cacheDomReferences=()=>{this.dropdownButton=this.element.querySelector(`.${this.prefix}--nav-menu__more`);this.inputSearchButton=this.element.querySelector(`.${this.prefix}--main-nav__nav-search`);this.dropdown=document.body.querySelector(`.${this.prefix}__nav-extra-menu.${this.prefix}--nav-dropdown`);this.inputSearch=document.body.querySelector(`.${this.prefix}--main-nav__nav-extra-search.${this.prefix}--nav-dropdown`);return this};this.enableHandlers=()=>{if(this.dropdownButton){this.dropdownButton.addEventListener("click",()=>{this.state.dropDownIsOpen=!this.state.dropDownIsOpen;});}if(this.inputSearchButton){this.inputSearchButton.addEventListener("click",()=>{this.state.searchIsOpen=!this.state.searchIsOpen;});}return this};this.registerStateHandlers=()=>{this.registerStateHandler("dropDownIsOpen",value=>{if(value){this.handleOpen("dropdown");}else {this.handleClose("dropdown");}});this.registerStateHandler("searchIsOpen",value=>{if(value){this.handleOpen("search");}else {this.handleClose("search");}});this.registerStateHandler("isDesktop",this.handleBreakpointChange);return this};this.handleBreakpointChange=isDesktop=>{if(!isDesktop){this.state.dropDownIsOpen=false;this.state.searchIsOpen=false;}};this.getDropdownConfig=type=>{const configs={dropdown:{element:this.dropdown,button:this.dropdownButton,stateKey:"dropDownIsOpen",otherStateKey:"searchIsOpen",resizeObserver:this.menuResizeObserver,focusTrapHandler:this.handleMenuFocusTrap},search:{element:this.inputSearch,button:this.inputSearchButton,stateKey:"searchIsOpen",otherStateKey:"dropDownIsOpen",resizeObserver:this.searchResizeObserver,focusTrapHandler:this.handleSearchFocusTrap}};return configs[type]};this.handleOpen=type=>{const config=this.getDropdownConfig(type);if(!config.element||!config.button)return;this.state[config.otherStateKey]=false;this.handleResize(config.element);config.resizeObserver.observe(this.element);window.addEventListener("click",this.handleOutsideClick);config.element.classList.add(`${this.prefix}--nav-dropdown--open`);config.button.setAttribute("aria-expanded","true");this.handleTabNavigation(config);};this.handleClose=type=>{const config=this.getDropdownConfig(type);if(!config.element||!config.button)return;config.element.classList.remove(`${this.prefix}--nav-dropdown--open`);config.button.setAttribute("aria-expanded","false");if(!this.state.dropDownIsOpen&&!this.state.searchIsOpen){config.resizeObserver.disconnect();window.removeEventListener("click",this.handleOutsideClick);}};this.handleResize=element=>{element.style.width=`${this.element.offsetWidth}px`;element.style.left=`${this.element.getBoundingClientRect().left}px`;element.style.top=`${this.element.getBoundingClientRect().bottom}px`;};this.handleOutsideClick=event=>{if(this.state.dropDownIsOpen&&!this.element?.contains(event.target)&&!this.dropdown?.contains(event.target)){this.state.dropDownIsOpen=false;}if(this.state.searchIsOpen&&!this.element?.contains(event.target)&&!this.inputSearch?.contains(event.target)){this.state.searchIsOpen=false;}};this.handleMenuFocusTrap=event=>{createFocusTrap(event,this.dropdown.querySelectorAll("a"),()=>{this.state.dropDownIsOpen=false;this.dropdownButton.focus();});};this.handleSearchFocusTrap=event=>{createFocusTrap(event,this.inputSearch.querySelectorAll("input"),()=>{this.state.searchIsOpen=false;this.inputSearchButton.focus();});};this.handleTabNavigation=config=>{setTimeout(()=>{config.element.focus();config.element.addEventListener("keydown",config.focusTrapHandler);},100);};this.prefix=this.element.dataset.prefix;this.dropdown=null;this.inputSearch=null;this.breakpointObserver=createBreakpointObserver(breakpoint=>{this.state.isDesktop=["xl","xxl"].includes(breakpoint);});this.menuResizeObserver=new ResizeObserver(()=>{if(this.state.dropDownIsOpen){this.handleResize(this.dropdown);}});this.searchResizeObserver=new ResizeObserver(()=>{if(this.state.searchIsOpen){this.handleResize(this.inputSearch);}});this.init();}init(){this.renderClientContent().cacheDomReferences().enableHandlers().registerStateHandlers().startBreakpointObserver();return this}}
11
11
 
12
12
  class MobileNav extends StatefulComponent{constructor(element){const initialState={isMobile:false,mobDrawerIsOpen:false,languagesMobDrawerIsOpen:false,moreMobDrawerIsOpen:false};super(element,initialState);this.init=()=>{this.renderClientContent().cacheDomReferences().enableHandlers().registerStateHandlers().startBreakpointObserver();return this};this.startBreakpointObserver=()=>{this.breakpointObserver.start();return this};this.renderClientContent=()=>{const mobileDrawerTemplates=[`${this.prefix}--nav-mobile-drawer__template__main`,`${this.prefix}--nav-mobile-drawer__template__languages`,`${this.prefix}--nav-mobile-drawer__template__more`];mobileDrawerTemplates.forEach(templateId=>{const template=this.element.querySelector(`#${templateId}`);if(template){const content=template.content.cloneNode(true);document.body.appendChild(content);}});return this};this.cacheDomReferences=()=>{this.burger=this.element.querySelector(`[class$="burger"]`);this.mobileDrawer=document.body.querySelector(`#${this.prefix}--nav-mobile-drawer__main`);this.menuHomeButtons=document.body.querySelectorAll(`.${this.prefix}--nav-mobile__nested__header`);this.mobileDrawerCloseButtons=document.body.querySelectorAll(`.${this.prefix}--nav-mobile-drawer__header-close`);this.mobileLanguageButton=this.mobileDrawer.querySelector(`.${this.prefix}--nav-mobile__widgets-language`);this.languagesMobileDrawer=document.body.querySelector(`#${this.prefix}--nav-mobile-drawer__languages`);this.moreMobileDrawer=document.body.querySelector(`#${this.prefix}--nav-mobile-drawer__more`);this.mobileMoreButton=this.mobileDrawer.querySelector(`.${this.prefix}--nav-mobile__more`);return this};this.enableHandlers=()=>{this.burger.addEventListener("click",this.handleBurgerClick);if(this.mobileLanguageButton){this.mobileLanguageButton.addEventListener("click",this.handleLanguageButtonClick);}if(this.mobileMoreButton){this.mobileMoreButton.addEventListener("click",this.handleMoreButtonClick);}this.mobileDrawerCloseButtons.forEach(button=>{button.addEventListener("click",this.handleMobileDrawerClose);});this.menuHomeButtons.forEach(button=>{button.addEventListener("click",this.handleMenuHomeButtonClick);});return this};this.registerStateHandlers=()=>{this.registerStateHandler("mobDrawerIsOpen",value=>{if(value){this.handleOpenMobileDrawer();}else {this.handleCloseMobileDrawer();}});this.registerStateHandler("languagesMobDrawerIsOpen",value=>{if(value){this.handleOpenLanguagesMobileDrawer();}else {this.handleCloseLanguagesMobileDrawer();}});this.registerStateHandler("moreMobDrawerIsOpen",value=>{if(value){this.handleOpenMoreMobileDrawer();}else {this.handleCloseMoreMobileDrawer();}});this.registerStateHandler("isMobile",this.handleBreakpointChange);return this};this.handleBurgerClick=()=>{this.burger.setAttribute("aria-expanded","true");this.state.mobDrawerIsOpen=true;};this.handleLanguageButtonClick=()=>{this.state.languagesMobDrawerIsOpen=true;};this.handleMoreButtonClick=()=>{this.state.moreMobDrawerIsOpen=true;};this.handleMenuHomeButtonClick=()=>{this.state.languagesMobDrawerIsOpen=false;this.state.moreMobDrawerIsOpen=false;};this.handleMobileDrawerClose=()=>{this.state.mobDrawerIsOpen=false;this.state.languagesMobDrawerIsOpen=false;this.state.moreMobDrawerIsOpen=false;};this.handleOpenMobileDrawer=()=>{this.mobileDrawer.inert=false;this.mobileDrawer?.classList.add(`${this.prefix}--nav-mobile-drawer--open`);};this.handleCloseMobileDrawer=()=>{this.mobileDrawer.inert=true;this.mobileDrawer?.classList.remove(`${this.prefix}--nav-mobile-drawer--open`);this.burger.setAttribute("aria-expanded","false");};this.handleOpenLanguagesMobileDrawer=()=>{this.languagesMobileDrawer.inert=false;this.mobileDrawer.inert=true;this.mobileLanguageButton.setAttribute("aria-expanded","true");this.languagesMobileDrawer.classList.add(`${this.prefix}--nav-mobile-drawer--open`);};this.handleCloseLanguagesMobileDrawer=()=>{this.languagesMobileDrawer.inert=true;this.mobileDrawer.inert=false;this.mobileLanguageButton.setAttribute("aria-expanded","false");this.languagesMobileDrawer?.classList.remove(`${this.prefix}--nav-mobile-drawer--open`);};this.handleOpenMoreMobileDrawer=()=>{this.moreMobileDrawer.inert=false;this.mobileDrawer.inert=true;this.mobileMoreButton.setAttribute("aria-expanded","true");this.moreMobileDrawer.classList.add(`${this.prefix}--nav-mobile-drawer--open`);};this.handleCloseMoreMobileDrawer=()=>{this.moreMobileDrawer.inert=true;this.mobileDrawer.inert=false;this.mobileMoreButton.setAttribute("aria-expanded","false");this.moreMobileDrawer?.classList.remove(`${this.prefix}--nav-mobile-drawer--open`);};this.handleBreakpointChange=isMobile=>{if(!isMobile){this.state.mobDrawerIsOpen=false;this.state.languagesMobDrawerIsOpen=false;this.state.moreMobDrawerIsOpen=false;}};this.prefix=this.element.dataset.prefix;this.mobileDrawer=null;this.mobileDrawerClose=null;this.languagesMobileDrawer=null;this.languagesMobileDrawerClose=null;this.mobileLanguageButton=null;this.burger=null;this.breakpointObserver=createBreakpointObserver(breakpoint=>{this.state.isMobile=!["xl","xxl"].includes(breakpoint);});this.init();}}
13
13
 
@@ -18,9 +18,6 @@ nav:
18
18
  link:
19
19
  href: "https://live.ilo.org"
20
20
  label: "ILO Live Homepage"
21
- tag:
22
- main: "Advancing social justice, promoting decent work"
23
- sub: "ILO is a specialized agency of the United Nations"
24
21
  widgets:
25
22
  type: object
26
23
  label: Widgets
@@ -104,5 +101,67 @@ nav:
104
101
  options:
105
102
  compact: compact
106
103
  complex: complex
107
- preview: "complex"
104
+ main: main
105
+ preview: "compact"
106
+
107
+ variants:
108
+ default:
109
+ label: Default
110
+ compact:
111
+ label: Compact
112
+ complex:
113
+ label: Complex
114
+ fields:
115
+ navtype: complex
116
+ branding:
117
+ tag:
118
+ main: "Advancing social justice, promoting decent work"
119
+ sub: "ILO is a specialized agency of the United Nations"
120
+ logo:
121
+ main: "images/ilo-live-logo-en-dark.png"
122
+ mobile: "images/ilo-live-logo-en-light.png"
123
+ drawer: "images/ilo-live-logo-en-dark.png"
124
+ alt: "ILO Logo"
125
+ link:
126
+ href: "https://live.ilo.org"
127
+ label: "ILO Live Homepage"
128
+ main:
129
+ label: Main
130
+ fields:
131
+ navtype: main
132
+ branding:
133
+ tag:
134
+ main: "Advancing social justice, promoting decent work"
135
+ sub: "ILO is a specialized agency of the United Nations"
136
+ logo:
137
+ main: "images/logo_en_horizontal_white.svg"
138
+ mobile: "images/logo_en_horizontal_white.svg"
139
+ drawer: "images/logo_en_horizontal_blue.svg"
140
+ alt: "ILO Logo"
141
+ link:
142
+ href: "https://live.ilo.org"
143
+ label: "ILO Live Homepage"
144
+ widgets:
145
+ language:
146
+ label: "Language"
147
+ language: "English"
148
+ links:
149
+ - label: "English"
150
+ url: "https://www.ilo.org/en"
151
+ - label: "Français"
152
+ url: "https://www.ilo.org/fr"
153
+ - label: "Español"
154
+ url: "https://www.ilo.org/es"
155
+ - label: "العربية"
156
+ url: "https://www.ilo.org/ar"
157
+ - label: "中文"
158
+ url: "https://www.ilo.org/ru"
159
+ - label: "Português"
160
+ url: "https://www.ilo.org/pt"
161
+ - label: "Italiano"
162
+ url: "https://www.ilo.org/it"
163
+ search:
164
+ label: "Search"
165
+ url: "https://www.ilo.org/search"
166
+
108
167
  visibility: storybook
@@ -1,5 +1,7 @@
1
1
  {% if navtype == 'compact' %}
2
2
  {% include '@components/nav/nav_compact.twig' %}
3
- {% else %}
3
+ {% elseif navtype == 'complex' %}
4
4
  {% include '@components/nav/nav_complex.twig' %}
5
+ {% else %}
6
+ {% include '@components/nav/nav_main.twig' %}
5
7
  {% endif %}
@@ -18,9 +18,6 @@ nav:
18
18
  link:
19
19
  href: "https://live.ilo.org"
20
20
  label: "ILO Live Homepage"
21
- tag:
22
- main: "Advancing social justice, promoting decent work"
23
- sub: "ILO is a specialized agency of the United Nations"
24
21
  widgets:
25
22
  type: object
26
23
  label: Widgets
@@ -104,5 +101,67 @@ nav:
104
101
  options:
105
102
  compact: compact
106
103
  complex: complex
107
- preview: "complex"
104
+ main: main
105
+ preview: "compact"
106
+
107
+ variants:
108
+ default:
109
+ label: Default
110
+ compact:
111
+ label: Compact
112
+ complex:
113
+ label: Complex
114
+ fields:
115
+ navtype: complex
116
+ branding:
117
+ tag:
118
+ main: "Advancing social justice, promoting decent work"
119
+ sub: "ILO is a specialized agency of the United Nations"
120
+ logo:
121
+ main: "images/ilo-live-logo-en-dark.png"
122
+ mobile: "images/ilo-live-logo-en-light.png"
123
+ drawer: "images/ilo-live-logo-en-dark.png"
124
+ alt: "ILO Logo"
125
+ link:
126
+ href: "https://live.ilo.org"
127
+ label: "ILO Live Homepage"
128
+ main:
129
+ label: Main
130
+ fields:
131
+ navtype: main
132
+ branding:
133
+ tag:
134
+ main: "Advancing social justice, promoting decent work"
135
+ sub: "ILO is a specialized agency of the United Nations"
136
+ logo:
137
+ main: "images/logo_en_horizontal_white.svg"
138
+ mobile: "images/logo_en_horizontal_white.svg"
139
+ drawer: "images/logo_en_horizontal_blue.svg"
140
+ alt: "ILO Logo"
141
+ link:
142
+ href: "https://live.ilo.org"
143
+ label: "ILO Live Homepage"
144
+ widgets:
145
+ language:
146
+ label: "Language"
147
+ language: "English"
148
+ links:
149
+ - label: "English"
150
+ url: "https://www.ilo.org/en"
151
+ - label: "Français"
152
+ url: "https://www.ilo.org/fr"
153
+ - label: "Español"
154
+ url: "https://www.ilo.org/es"
155
+ - label: "العربية"
156
+ url: "https://www.ilo.org/ar"
157
+ - label: "中文"
158
+ url: "https://www.ilo.org/ru"
159
+ - label: "Português"
160
+ url: "https://www.ilo.org/pt"
161
+ - label: "Italiano"
162
+ url: "https://www.ilo.org/it"
163
+ search:
164
+ label: "Search"
165
+ url: "https://www.ilo.org/search"
166
+
108
167
  visibility: storybook
@@ -72,7 +72,8 @@
72
72
  {% if moreItems %}
73
73
  {% include "@components/nav/desktop/navdropdown.twig" with {
74
74
  menu: moreItems,
75
- prefix: prefix
75
+ prefix: prefix,
76
+ className: 'ilo' ~ '__nav-extra-menu'
76
77
  } only %}
77
78
  {% endif %}
78
79
 
@@ -88,7 +88,8 @@
88
88
  {% if moreItems|length %}
89
89
  {% include "@components/nav/desktop/navdropdown.twig" with {
90
90
  menu: moreItems,
91
- prefix: prefix
91
+ prefix: prefix,
92
+ className: 'ilo' ~ '__nav-extra-menu'
92
93
  } only %}
93
94
  {% endif %}
94
95
 
@@ -136,4 +137,3 @@
136
137
  </nav>
137
138
  </div>
138
139
  </header>
139
-
@@ -0,0 +1,135 @@
1
+ {# navcomplex.twig #}
2
+
3
+ {% set prefix = prefix|default('ilo') %}
4
+ {% set base_class = 'ilo' ~ '--main-nav' %}
5
+ {% set mobile_drawer_class = 'ilo' ~ '--nav-mobile-drawer' %}
6
+
7
+ <header class="{{ base_class }}" data-loadcomponent="Nav" data-prefix="ilo">
8
+ <div class="{{ base_class }}-bg--dark">
9
+ <div class="{{ base_class }}__widgets {{ base_class }}__container">
10
+ <span class="{{ base_class }}__widgets-bar-corner"></span>
11
+ <span class="{{ base_class }}__widgets-bar">
12
+ {% if widgets.language %}
13
+ {% include "@components/languagetoggle/languagetoggle.twig" with {
14
+ className: base_class ~ '__widgets-bar__language',
15
+ hideIcon: false,
16
+ language: widgets.language.language,
17
+ links: widgets.language.links,
18
+ theme: "dark-blue"
19
+ } %}
20
+ {% endif %}
21
+ </span>
22
+ </div>
23
+ </div>
24
+
25
+ <div class="{{ base_class }}-bg--dark">
26
+ <div class="{{ base_class }}__branding {{ base_class }}__container">
27
+ <div class="{{ base_class }}__branding-main">
28
+ <div class="{{ base_class }}__branding-main__logo" role="button" tabindex="0" aria-label="Branding">
29
+ {% include "@components/logo/logo.twig" with {
30
+ src: branding.logo.main,
31
+ alt: branding.logo.alt,
32
+ link: branding.logo.link,
33
+ className: base_class ~ '__branding-main__logo',
34
+ imgClassName: base_class ~ '__branding-main__logo-img',
35
+ prefix: prefix
36
+ } %}
37
+ </div>
38
+ </div>
39
+ <div class="{{ base_class }}__branding-tag">
40
+ <h4 class="{{ base_class }}__branding-tag__main">{{ branding.tag.main }}</h4>
41
+ {% if branding.tag.sub %}
42
+ <span class="{{ base_class }}__branding-tag__sub">{{ branding.tag.sub }}</span>
43
+ {% endif %}
44
+ </div>
45
+ </div>
46
+ </div>
47
+
48
+ <div class="{{ base_class }}-bg--darker">
49
+ <nav class="{{ base_class }}__nav {{ base_class }}__container">
50
+ <div class="{{ base_class }}__nav-mobile">
51
+ <div class="{{ base_class }}__nav-mobile__logo" role="button" tabindex="0" aria-label="Branding">
52
+ {% include "@components/logo/logo.twig" with {
53
+ src: branding.logo.mobile,
54
+ alt: branding.logo.alt,
55
+ link: branding.logo.link,
56
+ className: base_class ~ '__nav-mobile__logo',
57
+ imgClassName: base_class ~ '__nav-mobile__logo-img',
58
+ prefix: prefix
59
+ } %}
60
+ </div>
61
+ </div>
62
+
63
+ {% if facadeItems %}
64
+ {% include "@components/nav/desktop/navmenu.twig" with {
65
+ className: base_class ~ '__nav-menu',
66
+ menu: facadeItems,
67
+ more: moreItems|length ? {
68
+ label: labels.more,
69
+ } : null,
70
+ prefix: prefix,
71
+ light: true
72
+ } only %}
73
+ {% endif %}
74
+
75
+ {% if moreItems|length %}
76
+ {% include "@components/nav/desktop/navdropdown.twig" with {
77
+ menu: moreItems,
78
+ prefix: prefix,
79
+ className: 'ilo' ~ '__nav-extra-menu'
80
+ } only %}
81
+ {% endif %}
82
+
83
+ <button class="{{ base_class }}__nav-search" aria-label="Open search"
84
+ aria-extanded="false"
85
+ aria-haspopup="menu"
86
+ aria-controls="{{ prefix }}__extra-"
87
+ >
88
+ <span class="{{ base_class }}__nav-search__icon"></span>
89
+ </button>
90
+
91
+ {% include "@components/nav/desktop/navsearch.twig" with {
92
+ prefix: prefix,
93
+ search: widgets.search,
94
+ className: base_class ~ '__nav-extra-search ' ~ 'ilo' ~ '--main-nav__nav-search-dropdown'
95
+ } only %}
96
+
97
+ <button class="{{ base_class }}__nav-burger" aria-label="Toggle navigation" aria-expanded="false" aria-haspopup="menu" aria-controls="{{ prefix }}--nav-mobile-drawer__main">
98
+ <span class="{{ base_class }}__nav-burger__icon"></span>
99
+ </button>
100
+
101
+ {% include "@components/nav/mobile/mobiledrawer_main.twig" with {
102
+ menu: facadeItems,
103
+ prefix: prefix,
104
+ branding: branding,
105
+ widgets: widgets,
106
+ labels: labels,
107
+ showMoreButton: moreItems|length,
108
+ inputSearch: true,
109
+ id: "main",
110
+ } only %}
111
+
112
+ {% if widgets.language.links|length %}
113
+ {% include "@components/nav/mobile/mobiledrawer_nested.twig" with {
114
+ menu: widgets.language.links,
115
+ prefix: prefix,
116
+ title: labels.language,
117
+ menu_home: labels.home,
118
+ isActiveLabel: widgets.language.language,
119
+ id: "languages",
120
+ } only %}
121
+ {% endif %}
122
+
123
+ {% if moreItems|length %}
124
+ {% include "@components/nav/mobile/mobiledrawer_nested.twig" with {
125
+ menu: moreItems,
126
+ prefix: prefix,
127
+ title: labels.more,
128
+ menu_home: labels.home,
129
+ id: "more",
130
+ } only %}
131
+ {% endif %}
132
+
133
+ </nav>
134
+ </div>
135
+ </header>
@@ -31,6 +31,17 @@ socialmedia:
31
31
  large: large
32
32
  preview: normal
33
33
  defaultValue: normal
34
+ titleLevel:
35
+ type: select
36
+ label: Headline Title Level
37
+ description: Select the title level for the headline.
38
+ required: false
39
+ options:
40
+ h2: h2
41
+ h3: h3
42
+ h4: h4
43
+ h5: h5
44
+ preview: "h5"
34
45
  fields:
35
46
  headline:
36
47
  type: string
@@ -73,6 +84,15 @@ socialmedia:
73
84
  - icon: "wechat"
74
85
  label: "WeChat"
75
86
  url: "https://weixin.qq.com"
87
+ - icon: "spotify"
88
+ label: "Spotify"
89
+ url: "https://open.spotify.com/user/iloorg"
90
+ - icon: "apple_podcasts"
91
+ label: "Apple Podcasts"
92
+ url: "https://podcasts.apple.com"
93
+ - icon: "rss"
94
+ label: "RSS"
95
+ url: "https://ilo.org/rss.xml"
76
96
 
77
97
  required: true
78
98
  visibility: storybook