@ilo-org/twig 1.4.0 → 1.6.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 (57) hide show
  1. package/dist/components/button/button.component.yml +7 -2
  2. package/dist/components/button/button.twig +25 -10
  3. package/dist/components/button/button.wingsuit.yml +7 -2
  4. package/dist/components/card_detail/card_detail.component.yml +10 -7
  5. package/dist/components/card_detail/card_detail.twig +11 -6
  6. package/dist/components/card_detail/card_detail.wingsuit.yml +10 -7
  7. package/dist/components/card_feature/card_feature.twig +16 -5
  8. package/dist/components/card_multilink/card_multilink.twig +1 -1
  9. package/dist/components/card_promo/card_promo.twig +1 -1
  10. package/dist/components/card_score/card_score.component.yml +102 -0
  11. package/dist/components/card_score/card_score.twig +71 -0
  12. package/dist/components/card_score/card_score.wingsuit.yml +102 -0
  13. package/dist/components/card_text/card_text.component.yml +1 -2
  14. package/dist/components/card_text/card_text.twig +3 -7
  15. package/dist/components/card_text/card_text.wingsuit.yml +1 -2
  16. package/dist/components/icon/icon.behavior.js +1 -1
  17. package/dist/components/icon/icon.twig +1 -1
  18. package/dist/components/languagetoggle/languagetoggle.behavior.js +8 -0
  19. package/dist/components/languagetoggle/languagetoggle.component.yml +43 -0
  20. package/dist/components/languagetoggle/languagetoggle.twig +22 -0
  21. package/dist/components/languagetoggle/languagetoggle.wingsuit.yml +43 -0
  22. package/dist/components/profile/profile.component.yml +10 -0
  23. package/dist/components/profile/profile.twig +29 -17
  24. package/dist/components/profile/profile.wingsuit.yml +10 -0
  25. package/dist/components/status/status.component.yml +33 -0
  26. package/dist/components/status/status.twig +8 -0
  27. package/dist/components/status/status.wingsuit.yml +33 -0
  28. package/dist/components/tag/tag.component.yml +56 -0
  29. package/dist/components/tag/tag.twig +35 -0
  30. package/dist/components/tag/tag.wingsuit.yml +56 -0
  31. package/dist/components/tags/tags.component.yml +21 -13
  32. package/dist/components/tags/tags.twig +12 -7
  33. package/dist/components/tags/tags.wingsuit.yml +21 -13
  34. package/dist/styles/components/button.css +1 -1
  35. package/dist/styles/components/card.css +1 -1
  36. package/dist/styles/components/datacard.css +1 -1
  37. package/dist/styles/components/detailcard.css +1 -1
  38. package/dist/styles/components/featurecard.css +1 -1
  39. package/dist/styles/components/languagetoggle.css +1 -1
  40. package/dist/styles/components/multilinkcard.css +1 -1
  41. package/dist/styles/components/profile.css +1 -1
  42. package/dist/styles/components/scorecard.css +1 -0
  43. package/dist/styles/components/status.css +1 -0
  44. package/dist/styles/components/tag.css +1 -1
  45. package/dist/styles/components/textcard.css +1 -1
  46. package/dist/styles/components/video.css +1 -1
  47. package/dist/styles/global.css +1 -1
  48. package/dist/styles/global.css.map +1 -1
  49. package/dist/styles/index.css +2 -2
  50. package/dist/styles/index.css.map +1 -1
  51. package/dist/styles/monorepo.css +2 -2
  52. package/dist/styles/monorepo.css.map +1 -1
  53. package/package.json +4 -4
  54. package/dist/components/tags/tag.behavior.js +0 -10
  55. package/dist/components/tags/tag.component.yml +0 -38
  56. package/dist/components/tags/tag.twig +0 -30
  57. package/dist/components/tags/tag.wingsuit.yml +0 -38
@@ -33,8 +33,7 @@ button:
33
33
  label: Icon
34
34
  description: Optional icon to include in button. See the `Icon` component for a full list of arguments
35
35
  preview:
36
- name: "plus"
37
- size: 24
36
+ name: "calendar"
38
37
  required: false
39
38
  className:
40
39
  type: string
@@ -42,6 +41,12 @@ button:
42
41
  description: optional class name
43
42
  preview: "optionalclass"
44
43
  required: false
44
+ elementId:
45
+ type: string
46
+ label: ID
47
+ description: optional id
48
+ preview: "optionalid"
49
+ required: false
45
50
  settings:
46
51
  size:
47
52
  type: select
@@ -1,28 +1,43 @@
1
- {#
2
- BUTTON COMPONENT
3
- #}
1
+ {# button.twig #}
2
+
3
+ {# Default values#}
4
+ {% set size = size|default("medium")%}
5
+ {% set type = type|default("primary")%}
6
+ {% set iconPosition = iconPosition|default("left")%}
7
+ {% set icon = icon|default(null)%}
8
+ {% set icononly = icononly|default(false)%}
9
+ {% set disabled = disabled|default(false)%}
10
+ {% set opensmodal = opensmodal|default(false)%}
11
+
12
+ {% set iconSize = 24%}
13
+
14
+ {% if size == 'small' %}
15
+ {% set iconSize = 16 %}
16
+ {% endif %}
17
+
18
+
4
19
  {% if url %}
5
- <a class="ilo--button ilo--button__{{size}} ilo--button__{{type}}{% if icon %} ilo--button--icon ilo--button--icon--position__{{iconPosition}}{% endif %}{% if icononly|boolval %} ilo--button--icon--only{% endif %}{% if className %} {{className}}{% endif %}" href="{{url}}" {% if target is defined and target != 'false' %} target="{{target}}" rel="noopener noreferrer" {% endif %} {{ disabled|boolval ? ' disabled' }}>
6
- <span class="link__label">{{label}}</span>
20
+ <a class="ilo--button ilo--button__{{size}} ilo--button__{{type}}{% if icon %} ilo--button--icon ilo--button--icon--position__{{iconPosition}}{% endif %}{% if icononly|boolval %} ilo--button--icon--only{% endif %}{% if className %} {{className}}{% endif %}" {%if elementId%}id="{{elementId}}"{%endif%} href="{{url}}" {% if target is defined and target != 'false' %} target="{{target}}" rel="noopener noreferrer" {% endif %} {{ disabled|boolval ? ' disabled' }}>
7
21
  {% if icon %}
8
22
  {% include '@components/icon/icon.twig' with {
9
23
  prefix: prefix,
10
24
  name: icon.name,
11
- size: icon.size,
25
+ size: iconSize,
12
26
  color: icon.color
13
- } only %}
27
+ } only %}
14
28
  {% endif %}
29
+ <span class="link__label">{{label}}</span>
15
30
  </a>
16
31
  {% else %}
17
- <button class="ilo--button ilo--button__{{size}} ilo--button__{{type}}{% if icon %} ilo--button--icon ilo--button--icon--position__{{iconPosition}}{% endif %}{% if icononly|boolval %} ilo--button--icon--only{% endif %}{% if className %} {{className}}{% endif %}" {% if kind %} type="{{kind}}" {% endif %} {% if opensmodal %} aria-haspopup="dialog" {% endif %} {{ disabled|boolval ? ' disabled' }}>
18
- <span class="button__label">{{label}}</span>
32
+ <button class="ilo--button ilo--button__{{size}} ilo--button__{{type}}{% if icon %} ilo--button--icon ilo--button--icon--position__{{iconPosition}}{% endif %}{% if icononly|boolval %} ilo--button--icon--only{% endif %}{% if className %} {{className}}{% endif %}" {%if elementId%}id="{{elementId}}"{%endif%} {% if kind %} type="{{kind}}" {% endif %} {% if opensmodal %} aria-haspopup="dialog" {% endif %} {{ disabled|boolval ? ' disabled' }}>
19
33
  {% if icon %}
20
34
  {% include '@components/icon/icon.twig' with {
21
35
  prefix: prefix,
22
36
  name: icon.name,
23
- size: icon.size,
37
+ size: iconSize,
24
38
  color: icon.color
25
39
  } only %}
26
40
  {% endif %}
41
+ <span class="button__label">{{label}}</span>
27
42
  </button>
28
43
  {% endif %}
@@ -33,8 +33,7 @@ button:
33
33
  label: Icon
34
34
  description: Optional icon to include in button. See the `Icon` component for a full list of arguments
35
35
  preview:
36
- name: "plus"
37
- size: 24
36
+ name: "calendar"
38
37
  required: false
39
38
  className:
40
39
  type: string
@@ -42,6 +41,12 @@ button:
42
41
  description: optional class name
43
42
  preview: "optionalclass"
44
43
  required: false
44
+ elementId:
45
+ type: string
46
+ label: ID
47
+ description: optional id
48
+ preview: "optionalid"
49
+ required: false
45
50
  settings:
46
51
  size:
47
52
  type: select
@@ -8,12 +8,15 @@ detailcard:
8
8
  date:
9
9
  type: object
10
10
  label: Date
11
- description: Date copy readable for both humans and machines
11
+ description: Date copy readable for both humans and machines. Will not be shown if `dateExtra` is also used.
12
+ preview:
13
+ human: 20 September 2025
14
+ unix: "1741276180"
12
15
  dateExtra:
13
16
  type: string
14
17
  label: dateExtra
15
- description: Strong date copy that could include other information such as the location of an event.
16
- preview: 20 September 2022 | Geneva
18
+ description: Strong date copy that could include other information such as the location of an event. Overrides the `date` field.
19
+ preview: 20 September 2025 | Kuala Lumpur, Malaysia
17
20
  eyebrow:
18
21
  type: string
19
22
  label: Eyebrow
@@ -28,13 +31,13 @@ detailcard:
28
31
  loading: "lazy"
29
32
  url:
30
33
  - breakpoint: "(min-width: 0px)"
31
- src: "/images/small.jpg"
34
+ src: "/images/publication.jpg"
32
35
  - breakpoint: "(min-width: 800px)"
33
- src: "/images/medium.jpg"
36
+ src: "/images/publication.jpg"
34
37
  - breakpoint: "(min-width: 1200px)"
35
- src: "/images/large.jpg"
38
+ src: "/images/publication.jpg"
36
39
  - breakpoint: "(min-width: 1440px)"
37
- src: "/images/large.jpg"
40
+ src: "/images/publication.jpg"
38
41
  intro:
39
42
  type: string
40
43
  label: Intro
@@ -1,8 +1,6 @@
1
- {#
2
- DETAIL CARD COMPONENT
3
- #}
1
+ {# card_detail.twig #}
4
2
 
5
- <div class="ilo--card ilo--card__type__detail ilo--card__action ilo--card__size__{{size}} {% if isvideo|boolval %} ilo--card__isvideo {% endif %}">
3
+ <div class="ilo--card ilo--card__type__detail ilo--card__size__{{size}} {% if isvideo|boolval %} ilo--card__isvideo {% endif %} ilo--card__theme__light">
6
4
  <a class="ilo--card--link" href="{{link}}" title="{{title}}">
7
5
  <span class="ilo--card--link--text">{{title}}</span>
8
6
  </a>
@@ -26,11 +24,18 @@
26
24
  {% if intro %}
27
25
  <p class="ilo--card--intro">{{intro}}</p>
28
26
  {% endif %}
29
- {% if date %}
27
+ {% if date and not dateExtra %}
30
28
  <time class="ilo--card--date" datetime="{{date.unix}}">{{date.human}}</time>
31
29
  {% endif %}
32
30
  {% if dateExtra %}
33
- <p class="ilo--card--date-extra">{{dateExtra}}</p>
31
+ <p class="ilo--card--date-extra">
32
+ {% include "@components/icon/icon.twig" with {
33
+ name: "triangle_right",
34
+ size: 20,
35
+ color: "var(--ilo-color-gray-charcoal)"
36
+ } %}
37
+ {{dateExtra}}
38
+ </p>
34
39
  {% endif %}
35
40
  </div>
36
41
  </div>
@@ -8,12 +8,15 @@ detailcard:
8
8
  date:
9
9
  type: object
10
10
  label: Date
11
- description: Date copy readable for both humans and machines
11
+ description: Date copy readable for both humans and machines. Will not be shown if `dateExtra` is also used.
12
+ preview:
13
+ human: 20 September 2025
14
+ unix: "1741276180"
12
15
  dateExtra:
13
16
  type: string
14
17
  label: dateExtra
15
- description: Strong date copy that could include other information such as the location of an event.
16
- preview: 20 September 2022 | Geneva
18
+ description: Strong date copy that could include other information such as the location of an event. Overrides the `date` field.
19
+ preview: 20 September 2025 | Kuala Lumpur, Malaysia
17
20
  eyebrow:
18
21
  type: string
19
22
  label: Eyebrow
@@ -28,13 +31,13 @@ detailcard:
28
31
  loading: "lazy"
29
32
  url:
30
33
  - breakpoint: "(min-width: 0px)"
31
- src: "/images/small.jpg"
34
+ src: "/images/publication.jpg"
32
35
  - breakpoint: "(min-width: 800px)"
33
- src: "/images/medium.jpg"
36
+ src: "/images/publication.jpg"
34
37
  - breakpoint: "(min-width: 1200px)"
35
- src: "/images/large.jpg"
38
+ src: "/images/publication.jpg"
36
39
  - breakpoint: "(min-width: 1440px)"
37
- src: "/images/large.jpg"
40
+ src: "/images/publication.jpg"
38
41
  intro:
39
42
  type: string
40
43
  label: Intro
@@ -1,8 +1,10 @@
1
- {#
2
- FEATURE CARD COMPONENT
3
- #}
1
+ {# card_feature.twig #}
4
2
 
5
- <div class="ilo--card ilo--card__type__feature ilo--card__action ilo--card__theme__{{theme}} ilo--card__size__{{ size }} {% if isvideo|boolval %} ilo--card__isvideo {% endif %} {% if cta %} ilo--card__linklist {% endif %}">
3
+ {% set theme = theme|default("light") %}
4
+ {% set titleLevel = titleLevel|default(p) %}
5
+ {% set size = size|default("narrow") %}
6
+
7
+ <div class="ilo--card ilo--card__type__feature ilo--card__theme__{{theme}} ilo--card__size__{{ size }} {% if isvideo|boolval %} ilo--card__isvideo {% endif %} {% if cta %} ilo--card__linklist {% endif %}">
6
8
  <a class="ilo--card--link" href="{{link}}" title="{{title}}">
7
9
  <span class="ilo--card--link--text">{{title}}</span>
8
10
  </a>
@@ -26,7 +28,7 @@
26
28
  {% if date %}
27
29
  <time class="ilo--card--date" datetime="{{date.unix}}">{{date.human}}</time>
28
30
  {% endif %}
29
- {% if cta %}
31
+ {% if cta and size == "narrow" %}
30
32
  {% include "@components/linklist/linklist.twig" with {
31
33
  theme: theme,
32
34
  linkgroup: [{
@@ -37,4 +39,13 @@
37
39
  {% endif %}
38
40
  </div>
39
41
  </div>
42
+ {% if cta and size == "wide" or size == "fluid" %}
43
+ {% include "@components/linklist/linklist.twig" with {
44
+ theme: theme,
45
+ linkgroup: [{
46
+ links: [cta]
47
+ }],
48
+ prefix: prefix
49
+ } only %}
50
+ {% endif %}
40
51
  </div>
@@ -5,7 +5,7 @@
5
5
  {% set theme = "light" %}
6
6
  {% endif %}
7
7
 
8
- <div class="ilo--card ilo--card__theme__{{theme}} ilo--card__type__multilink {% if link|length > 0 %} ilo--card__action {% endif %} ilo--card__size__{{size}} {% if isvideo|boolval %} ilo--card__isvideo {% endif %} {% if linklist %} ilo--card__linklist {% endif %} {% if size == "wide" or size == "fluid" %} ilo--card__align__{{alignment}} {% endif %} {% if not image %} ilo--card--no-image {% endif %}">
8
+ <div class="ilo--card ilo--card__theme__{{theme}} ilo--card__type__multilink {% if link|length > 0 %} {% endif %} ilo--card__size__{{size}} {% if isvideo|boolval %} ilo--card__isvideo {% endif %} {% if linklist %} ilo--card__linklist {% endif %} {% if size == "wide" or size == "fluid" %} ilo--card__align__{{alignment}} {% endif %} {% if not image %} ilo--card--no-image {% endif %}">
9
9
  {% if link|length > 0 %}
10
10
  <a class="ilo--card--link" href="{{link}}" title="{{title}}">
11
11
  <span class="ilo--card--link--text">{{title}}</span>
@@ -3,7 +3,7 @@
3
3
  #}
4
4
 
5
5
  <div class="ilo--card--wrapper ilo--card--wrapper__type__promo ilo--card--wrapper__type__promo__size__{{ size }}">
6
- <div class="ilo--card ilo--card__type__promo ilo--card__size__{{ size }} ilo--card__action ilo--card__theme__{{theme}} {% if cornercut|boolval %}ilo--card__cornercut{% endif %}">
6
+ <div class="ilo--card ilo--card__type__promo ilo--card__size__{{ size }} ilo--card__theme__{{theme}} {% if cornercut|boolval %}ilo--card__cornercut{% endif %}">
7
7
  <a class="ilo--card--link" href="{{link}}" title="{{title}}">
8
8
  <span class="ilo--card--link--text">{{title}}</span>
9
9
  </a>
@@ -0,0 +1,102 @@
1
+ scorecard:
2
+ namespace: Components/Cards
3
+ use: "@components/card_score/card_score.twig"
4
+ label: Score Card
5
+ description: A card component for prominently displaying status information or metadata around topics or events.
6
+ visibility: storybook
7
+ fields:
8
+ status:
9
+ type: object
10
+ label: Status
11
+ description: Sets the status of the card. See the `Status` component for more information. If not set, the status will not be displayed.
12
+ preview:
13
+ content: "Live"
14
+ statusType: "alert"
15
+ dataset:
16
+ type: object
17
+ label: Dataset
18
+ description: Exposes an array of Content objects with `icon` and `label` and an array of CTAs (buttons) with `label`, `icon`, and `url`.
19
+ preview:
20
+ content:
21
+ items:
22
+ - icon: "time"
23
+ label: 28 February 2025
24
+ - icon: "pin"
25
+ label: "Geneva, Switzerland"
26
+ cta:
27
+ items:
28
+ - label: Reminder
29
+ url: "https://www.ilo.org"
30
+ icon: "time"
31
+ - label: Add to calendar
32
+ url: "https://www.ilo.org"
33
+ icon: "calendar"
34
+ eyebrow:
35
+ type: string
36
+ label: Eyebrow
37
+ description: Eyebrow copy
38
+ preview: "Podcast"
39
+ image:
40
+ type: object
41
+ label: Image
42
+ description: Image settings for the card. This should include a `url`, which is an array of objects with an `src` property pointing to the image file and a `breakpoint` property which is either a number indicating the minimum viewport width at which the image should be displayed or a media query. It can also contain an `alt` property for the image's alt text and a `loading` property for the image's loading attribute.
43
+ preview:
44
+ alt: "Image alt text"
45
+ loading: "lazy"
46
+ url:
47
+ - breakpoint: "(min-width: 0px)"
48
+ src: "/images/small.jpg"
49
+ - breakpoint: "(min-width: 800px)"
50
+ src: "/images/medium.jpg"
51
+ - breakpoint: "(min-width: 1200px)"
52
+ src: "/images/large.jpg"
53
+ - breakpoint: "(min-width: 1440px)"
54
+ src: "/images/large.jpg"
55
+ link:
56
+ type: string
57
+ label: Link
58
+ description: Link field for the card
59
+ preview: "https://www.ilo.org/"
60
+ title:
61
+ type: string
62
+ label: Title
63
+ description: Title field for the card
64
+ preview: Can digital technology be an equality machine?
65
+ settings:
66
+ isvideo:
67
+ type: boolean
68
+ label: Is a Video
69
+ description: Whether the card should display a video icon (for Score card)
70
+ preview: false
71
+ size:
72
+ type: select
73
+ label: size
74
+ description: Sets the size of the card. If not set, the card will appear as `narrow`.
75
+ required: false
76
+ preview: "narrow"
77
+ options:
78
+ narrow: narrow
79
+ wide: wide
80
+ fluid: fluid
81
+ simple: simple
82
+ theme:
83
+ type: select
84
+ label: Theme
85
+ description: Sets the card to appear as either light or dark. If not set, the card will inherit the theme of its parent.
86
+ required: false
87
+ preview: "light"
88
+ options:
89
+ dark: Dark
90
+ light: Light
91
+ titleLevel:
92
+ type: select
93
+ label: Title Element
94
+ description: HTML element used for the title
95
+ required: false
96
+ options:
97
+ p: p
98
+ h1: h1
99
+ h2: h2
100
+ h3: h3
101
+ h4: h4
102
+ h5: h5
@@ -0,0 +1,71 @@
1
+ {# card_score.twig #}
2
+
3
+ {% set theme = theme|default("light") %}
4
+ {% set titleLevel = titleLevel|default(p) %}
5
+ {% set size = size|default("narrow") %}
6
+ {% set iconColor = "var(--ilo-color-gray-accessible)" %}
7
+
8
+ {% if theme == "dark" %}
9
+ {% set iconColor = "var(--ilo-color-white)" %}
10
+ {% endif %}
11
+
12
+ <div class="ilo--card ilo--card__type__score ilo--card__theme__{{theme}} ilo--card__size__{{ size }} {% if isvideo|boolval %} ilo--card__isvideo {% endif %}">
13
+ <a class="ilo--card--link" href="{{link}}" title="{{title}}">
14
+ <span class="ilo--card--link--text">{{title}}</span>
15
+ </a>
16
+ <div class="ilo--card--wrap">
17
+ {% if image and size != "simple" %}
18
+ <div class="ilo--card--image--wrapper">
19
+ {% include "@components/picture/picture.twig" with {
20
+ image: image,
21
+ class: "card"
22
+ }
23
+ %}
24
+ </div>
25
+ {% endif %}
26
+ <div class="ilo--card--content">
27
+ {% if status %}
28
+ {% include "@components/status/status.twig" with {
29
+ content: status.content,
30
+ statusType: status.statusType
31
+ } %}
32
+ {% endif %}
33
+ {% if eyebrow and size != "simple" %}
34
+ <p class="ilo--card--eyebrow">{{eyebrow}}</p>
35
+ {% endif %}
36
+ {% if title %}
37
+ <{{titleLevel|default('p')}} class="{{ prefix }}--card--title">{{ title }}</{{titleLevel|default('p')}}>
38
+ {% endif %}
39
+ {% if dataset.content %}
40
+ <div class="ilo--card--area--content">
41
+ {% for item in dataset.content.items %}
42
+ <div class="ilo--card--content--item">
43
+ {% include "@components/icon/icon.twig" with {
44
+ name: item.icon,
45
+ size: 20,
46
+ color: iconColor
47
+ } %}
48
+ <span datetime="{{item.unix}}">{{item.label}}</span>
49
+ </div>
50
+ {% endfor %}
51
+ </div>
52
+ {% endif %}
53
+ {% if dataset.content %}
54
+ <div class="ilo--card--area--cta">
55
+ {% for item in dataset.cta.items %}
56
+ <div class="ilo--card--cta">
57
+ {% include "@components/button/button.twig" with {
58
+ icon: {name: item.icon, size: 16},
59
+ label: item.label,
60
+ prefix: prefix,
61
+ type: "secondary",
62
+ size: "small",
63
+ iconPosition: "left",
64
+ } %}
65
+ </div>
66
+ {% endfor %}
67
+ </div>
68
+ {% endif %}
69
+ </div>
70
+ </div>
71
+ </div>
@@ -0,0 +1,102 @@
1
+ scorecard:
2
+ namespace: Components/Cards
3
+ use: "@components/card_score/card_score.twig"
4
+ label: Score Card
5
+ description: A card component for prominently displaying status information or metadata around topics or events.
6
+ visibility: storybook
7
+ fields:
8
+ status:
9
+ type: object
10
+ label: Status
11
+ description: Sets the status of the card. See the `Status` component for more information. If not set, the status will not be displayed.
12
+ preview:
13
+ content: "Live"
14
+ statusType: "alert"
15
+ dataset:
16
+ type: object
17
+ label: Dataset
18
+ description: Exposes an array of Content objects with `icon` and `label` and an array of CTAs (buttons) with `label`, `icon`, and `url`.
19
+ preview:
20
+ content:
21
+ items:
22
+ - icon: "time"
23
+ label: 28 February 2025
24
+ - icon: "pin"
25
+ label: "Geneva, Switzerland"
26
+ cta:
27
+ items:
28
+ - label: Reminder
29
+ url: "https://www.ilo.org"
30
+ icon: "time"
31
+ - label: Add to calendar
32
+ url: "https://www.ilo.org"
33
+ icon: "calendar"
34
+ eyebrow:
35
+ type: string
36
+ label: Eyebrow
37
+ description: Eyebrow copy
38
+ preview: "Podcast"
39
+ image:
40
+ type: object
41
+ label: Image
42
+ description: Image settings for the card. This should include a `url`, which is an array of objects with an `src` property pointing to the image file and a `breakpoint` property which is either a number indicating the minimum viewport width at which the image should be displayed or a media query. It can also contain an `alt` property for the image's alt text and a `loading` property for the image's loading attribute.
43
+ preview:
44
+ alt: "Image alt text"
45
+ loading: "lazy"
46
+ url:
47
+ - breakpoint: "(min-width: 0px)"
48
+ src: "/images/small.jpg"
49
+ - breakpoint: "(min-width: 800px)"
50
+ src: "/images/medium.jpg"
51
+ - breakpoint: "(min-width: 1200px)"
52
+ src: "/images/large.jpg"
53
+ - breakpoint: "(min-width: 1440px)"
54
+ src: "/images/large.jpg"
55
+ link:
56
+ type: string
57
+ label: Link
58
+ description: Link field for the card
59
+ preview: "https://www.ilo.org/"
60
+ title:
61
+ type: string
62
+ label: Title
63
+ description: Title field for the card
64
+ preview: Can digital technology be an equality machine?
65
+ settings:
66
+ isvideo:
67
+ type: boolean
68
+ label: Is a Video
69
+ description: Whether the card should display a video icon (for Score card)
70
+ preview: false
71
+ size:
72
+ type: select
73
+ label: size
74
+ description: Sets the size of the card. If not set, the card will appear as `narrow`.
75
+ required: false
76
+ preview: "narrow"
77
+ options:
78
+ narrow: narrow
79
+ wide: wide
80
+ fluid: fluid
81
+ simple: simple
82
+ theme:
83
+ type: select
84
+ label: Theme
85
+ description: Sets the card to appear as either light or dark. If not set, the card will inherit the theme of its parent.
86
+ required: false
87
+ preview: "light"
88
+ options:
89
+ dark: Dark
90
+ light: Light
91
+ titleLevel:
92
+ type: select
93
+ label: Title Element
94
+ description: HTML element used for the title
95
+ required: false
96
+ options:
97
+ p: p
98
+ h1: h1
99
+ h2: h2
100
+ h3: h3
101
+ h4: h4
102
+ h5: h5
@@ -25,11 +25,10 @@ textcard:
25
25
  profile:
26
26
  type: object
27
27
  label: Profile
28
- description: Optional profile of the author who created the content
28
+ description: Optional profile of the author who created the content. Uses only the `avatar` and `name` properties from the `Profile` component.
29
29
  preview:
30
30
  avatar: "/images/ilo-dg.jpg"
31
31
  name: "Gilbert F. Houngbo"
32
- role: "ILO Director-General"
33
32
  title:
34
33
  type: string
35
34
  label: Title
@@ -1,9 +1,7 @@
1
- {#
2
- FEATURE CARD COMPONENT
3
- #}
1
+ {# card_text.twig #}
4
2
 
5
3
  <div class="ilo--card--wrapper">
6
- <div class="ilo--card ilo--card__type__text ilo--card__size__{{ size }} ilo--card__action ilo--card__theme__{{theme}}">
4
+ <div class="ilo--card ilo--card__type__text ilo--card__size__{{ size }} ilo--card__theme__{{theme}}">
7
5
  <a class="ilo--card--link" href="{{link}}" title="{{title}}">
8
6
  <span class="ilo--card--link--text">{{title}}</span>
9
7
  </a>
@@ -21,11 +19,9 @@
21
19
  {% if profile %}
22
20
  {% include "@components/profile/profile.twig" with {
23
21
  avatar: profile.avatar,
24
- description: profile.description,
25
- link: profile.link,
26
22
  name: profile.name,
27
- role: profile.role,
28
23
  prefix: prefix,
24
+ size: "small",
29
25
  theme: theme,
30
26
  } only %}
31
27
  {% endif %}
@@ -25,11 +25,10 @@ textcard:
25
25
  profile:
26
26
  type: object
27
27
  label: Profile
28
- description: Optional profile of the author who created the content
28
+ description: Optional profile of the author who created the content. Uses only the `avatar` and `name` properties from the `Profile` component.
29
29
  preview:
30
30
  avatar: "/images/ilo-dg.jpg"
31
31
  name: "Gilbert F. Houngbo"
32
- role: "ILO Director-General"
33
32
  title:
34
33
  type: string
35
34
  label: Title
@@ -920,7 +920,7 @@
920
920
  UploadGlyph: index
921
921
  });
922
922
 
923
- const SIZING=[16,20,24,32];const DEFAULT_SIZE=24;const SVG_NS="http://www.w3.org/2000/svg";const PATH_NS="http://www.w3.org/2000/path";class Icon{constructor(element){this.element=element;this.init();}init(){const isValid=this.validate();if(!isValid){return}const svg=this.build();this.prepare(svg);this.element.outerHTML=svg.outerHTML;return this}validate(){let{name,size}=this.element.dataset;if(!SIZING.includes(+size)){console.warn(`Icon size ${size} is not supported. Defaulting to ${DEFAULT_SIZE}px`);size=DEFAULT_SIZE;}if(!name){console.warn("Icon name is required");return false}const reference=this.getIconConfig(name,size);if(!reference){console.warn(`Icon "${name}" not found`);return false}return true}build(){const{name,size,color}=this.element.dataset;const config=this.getIconConfig(name,size);const element=document.createElementNS(SVG_NS,"svg");for(const[key,value]of Object.entries(config.attrs)){element.setAttribute(key,value);}if(color){element.setAttribute("fill",color);}for(const item of config.content){const child=document.createElementNS(PATH_NS,item.elem);for(let[key,value]of Object.entries(item.attrs)){if(key==="fill"&&color){value=color;}child.setAttribute(key,value);}element.appendChild(child);}return element}getIconConfig(name,size){const nameUpper=name.split("_").map(part=>part.charAt(0).toUpperCase()+part.slice(1)).join("");return Icons[`${nameUpper}${size}`]}prepare(icon){icon.setAttribute("class",this.element.getAttribute("class"));icon.setAttribute("data-js-processed",true);}}
923
+ const SIZING=[16,20,24,32];const DEFAULT_SIZE=24;const SVG_NS="http://www.w3.org/2000/svg";const PATH_NS="http://www.w3.org/2000/path";class Icon{constructor(element){this.element=element;this.init();}init(){const isValid=this.validate();if(!isValid){return}const svg=this.build();this.prepare(svg);this.element.outerHTML=svg.outerHTML;return this}validate(){let{name,size}=this.element.dataset;if(!SIZING.includes(+size)){console.warn(`Icon size ${size} is not supported. Defaulting to ${DEFAULT_SIZE}px`);size=DEFAULT_SIZE;this.element.dataset.size=size;}if(!name){console.warn("Icon name is required");return false}const reference=this.getIconConfig(name,size);if(!reference){console.warn(`Icon "${name}" not found`);return false}return true}build(){const{name,size,color}=this.element.dataset;const config=this.getIconConfig(name,size);const element=document.createElementNS(SVG_NS,"svg");for(const[key,value]of Object.entries(config.attrs)){element.setAttribute(key,value);}if(color){element.setAttribute("fill",color);}for(const item of config.content){const child=document.createElementNS(PATH_NS,item.elem);for(let[key,value]of Object.entries(item.attrs)){if(key==="fill"&&color){value=color;}child.setAttribute(key,value);}element.appendChild(child);}return element}getIconConfig(name,size){const nameUpper=name.split("_").map(part=>part.charAt(0).toUpperCase()+part.slice(1)).join("");return Icons[`${nameUpper}${size}`]}prepare(icon){icon.setAttribute("class",this.element.getAttribute("class"));icon.setAttribute("data-js-processed",true);}}
924
924
 
925
925
  Drupal.behaviors.icon={attach(){Array.prototype.forEach.call(document.querySelectorAll(`[data-loadcomponent="Icon"]`),element=>{if(!element.dataset.jsProcessed){new Icon(element);element.dataset.jsProcessed=true;}});}};
926
926
 
@@ -1 +1 @@
1
- <svg class="ilo--icon" data-name="{{name}}" data-size="{{size}}" data-color="{{color}}" data-loadcomponent="Icon"></svg>
1
+ <svg class="ilo--icon" data-name="{{name}}" data-size="{{size}}" data-color="{{color}}" data-loadcomponent="Icon" aria-hidden="true"></svg>
@@ -0,0 +1,8 @@
1
+ (function () {
2
+ 'use strict';
3
+
4
+ class LanguageToggle{constructor(element){this.element=element;this.prefix=`${this.element.dataset.prefix}--language-toggle`;this.contextMenuVisibleClass=`${this.prefix}--context-menu__open`;this.init();}init(){this.cacheDomReferences().setupHandlers().enable();}cacheDomReferences(){this.contextButton=this.element.querySelector(`.${this.prefix}--container`);this.contextMenu=this.element.querySelector(`.${this.prefix}--context-menu`);return this}setupHandlers(){this.contexMenuIsOpen=this.contexMenuIsOpen.bind(this);this.openContextMenu=this.openContextMenu.bind(this);this.closeContextMenu=this.closeContextMenu.bind(this);this.positionContextMenu=this.positionContextMenu.bind(this);this.onClick=this.onClick.bind(this);return this}enable(){this.contextButton.addEventListener("click",this.onClick.bind(this));window.addEventListener("load",()=>{this.positionContextMenu();});}onClick(e){e.stopPropagation();if(this.contexMenuIsOpen()){this.closeContextMenu();}else {this.openContextMenu();window.addEventListener("click",this.closeContextMenu,{once:true});}return this}openContextMenu(){this.contextMenu.classList.add(this.contextMenuVisibleClass);this.contextMenu.removeAttribute("hidden");this.contextButton.setAttribute("aria-expanded","true");this.positionContextMenu();return this}closeContextMenu(){this.contextMenu.classList.remove(this.contextMenuVisibleClass);this.contextMenu.setAttribute("hidden","hidden");this.contextButton.setAttribute("aria-expanded","false");}positionContextMenu(){const containerRect=this.element.getBoundingClientRect();const contextMenuRect=this.contextMenu.getBoundingClientRect();this.contextMenu.style.left=`${containerRect.left+(containerRect.width-contextMenuRect.width)/2}px`;this.contextMenu.style.top=`${containerRect.bottom}px`;}contexMenuIsOpen(){return this.contextMenu.classList.contains(this.contextMenuVisibleClass)}}
5
+
6
+ Drupal.behaviors.languagetoggle={attach(){Array.prototype.forEach.call(document.querySelectorAll(`[data-loadcomponent="LanguageToggle"]`),element=>{if(!element.dataset.jsProcessed){new LanguageToggle(element);element.dataset.jsProcessed=true;}});}};
7
+
8
+ })();