@ilo-org/twig 0.13.0 → 0.14.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.
@@ -1,9 +1,9 @@
1
1
 
2
- > @ilo-org/twig@0.13.0 build:lib /home/runner/work/designsystem/designsystem/packages/twig
2
+ > @ilo-org/twig@0.14.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.13.0 output /home/runner/work/designsystem/designsystem/packages/twig
7
+ > @ilo-org/twig@0.14.0 output /home/runner/work/designsystem/designsystem/packages/twig
8
8
  > node outputtwigs.js
9
9
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @ilo-org/twig
2
2
 
3
+ ## 0.14.0
4
+
5
+ ### Minor Changes
6
+
7
+ - df7080c80: Used popper library to handle tooltip
8
+ - 6fe60e0d6: Add a `gap` setting to the hero card that allows the developer to set an optional background color on the entire Hero,
9
+ which fills the "gap" between the bottom of the Hero Card and the bottom of the hero image when `align` is set to `bottom` or `baseline`. Options are `transparent`, `white`, `light` and `dark`.
10
+
11
+ ### Patch Changes
12
+
13
+ - b014e9af0: Fix Breadcrumb incorrectly assuming there will always be at least two links
14
+ - c54ce9923: Fix Breadcrumb spacing vis-a-vis Hero
15
+ - a78b32be4: Add eyebrow to multilink card
16
+ - 9ed7b873d: build(deps-dev): bump postcss from 8.4.21 to 8.4.31
17
+ - Updated dependencies [df7080c80]
18
+ - Updated dependencies [c5eaabd55]
19
+ - Updated dependencies [720825342]
20
+ - Updated dependencies [6f86e7a94]
21
+ - Updated dependencies [94b03b9be]
22
+ - Updated dependencies [c54ce9923]
23
+ - Updated dependencies [6fe60e0d6]
24
+ - Updated dependencies [9ed7b873d]
25
+ - Updated dependencies [c173ec9f8]
26
+ - @ilo-org/styles@0.13.0
27
+
3
28
  ## 0.13.0
4
29
 
5
30
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ilo-org/twig",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Twig components for the ILO's Design System",
6
6
  "main": "",
@@ -25,13 +25,14 @@
25
25
  "@ilo-org/brand-assets": "0.2.0",
26
26
  "@ilo-org/fonts": "0.1.2",
27
27
  "@ilo-org/icons": "0.2.1",
28
- "@ilo-org/styles": "0.12.0",
28
+ "@ilo-org/styles": "0.13.0",
29
29
  "@ilo-org/themes": "0.7.0",
30
30
  "@ilo-org/utils": "0.0.11"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@babel/core": "^7.20.12",
34
34
  "@babel/preset-env": "^7.20.2",
35
+ "@popperjs/core": "^2.11.8",
35
36
  "@storybook/addon-actions": "^6.5.16",
36
37
  "@storybook/addon-essentials": "^6.5.16",
37
38
  "@storybook/addon-links": "^6.5.16",
@@ -58,7 +59,7 @@
58
59
  "lodash": "^4.17.21",
59
60
  "mini-css-extract-plugin": "^1.6.2",
60
61
  "optimize-css-assets-webpack-plugin": "^5.0.8",
61
- "postcss": "^8.4.21",
62
+ "postcss": "^8.4.31",
62
63
  "postcss-loader": "^4.3.0",
63
64
  "postcss-nested": "^4.2.3",
64
65
  "postcss-scss": "^4.0.6",
@@ -10,28 +10,34 @@
10
10
  <span class="{{prefix}}--breadcrumb--link--label">{{home.label}}</span>
11
11
  </a>
12
12
  </li>
13
- <li class="{{prefix}}--breadcrumb--item first">
14
- <a class="{{prefix}}--breadcrumb--link" href="{{firstlink.url}}">
15
- <span class="{{prefix}}--breadcrumb--link--label">{{firstlink.label}}</span>
16
- </a>
17
- </li>
18
- <li class="{{prefix}}--breadcrumb--item--context">
19
- <ul class="{{prefix}}--breadcrumb--items context--menu">
20
- {% for link in links %}
21
- {% if not loop.first and not loop.last %}
22
- <li class="{{prefix}}--breadcrumb--item">
23
- <a href="{{link.url}}" class="{{prefix}}--breadcrumb--link">
24
- <span class="{{prefix}}--breadcrumb--link--label">{{link.label}}</span>
25
- </a>
26
- </li>
27
- {% endif %}
28
- {% endfor %}
29
- </ul>
30
- </li>
31
- <li class="{{prefix}}--breadcrumb--item final">
32
- <a class="{{prefix}}--breadcrumb--link" href="{{lastlink.url}}">
33
- <span class="{{prefix}}--breadcrumb--link--label">{{lastlink.label}}</span>
34
- </a>
35
- </li>
13
+ {% if links|length >= 2 %}
14
+ <li class="{{prefix}}--breadcrumb--item first">
15
+ <a class="{{prefix}}--breadcrumb--link" href="{{firstlink.url}}">
16
+ <span class="{{prefix}}--breadcrumb--link--label">{{firstlink.label}}</span>
17
+ </a>
18
+ </li>
19
+ {% endif %}
20
+ {% if links|length >= 3%}
21
+ <li class="{{prefix}}--breadcrumb--item--context">
22
+ <ul class="{{prefix}}--breadcrumb--items context--menu">
23
+ {% for link in links %}
24
+ {% if not loop.first and not loop.last %}
25
+ <li class="{{prefix}}--breadcrumb--item">
26
+ <a href="{{link.url}}" class="{{prefix}}--breadcrumb--link">
27
+ <span class="{{prefix}}--breadcrumb--link--label">{{link.label}}</span>
28
+ </a>
29
+ </li>
30
+ {% endif %}
31
+ {% endfor %}
32
+ </ul>
33
+ </li>
34
+ {% endif %}
35
+ {% if links|length >= 1%}
36
+ <li class="{{prefix}}--breadcrumb--item final">
37
+ <a class="{{prefix}}--breadcrumb--link" href="{{lastlink.url}}">
38
+ <span class="{{prefix}}--breadcrumb--link--label">{{lastlink.label}}</span>
39
+ </a>
40
+ </li>
41
+ {% endif %}
36
42
  </ol>
37
43
  </nav>
@@ -17,6 +17,9 @@
17
17
  %}
18
18
  </div>
19
19
  <div class="{{prefix}}--card--content">
20
+ {% if eyebrow %}
21
+ <p class="{{prefix}}--card--eyebrow">{{eyebrow}}</p>
22
+ {% endif %}
20
23
  {% if title %}
21
24
  <h5 class="{{prefix}}--card--title">{{title}}</h5>
22
25
  {% endif %}
@@ -12,6 +12,11 @@ multilinkcard:
12
12
  preview:
13
13
  human: 20 September 2022
14
14
  unix: 1670389200
15
+ eyebrow:
16
+ type: string
17
+ label: Eyebrow
18
+ description: Eyebrow copy
19
+ preview: "Podcast"
15
20
  image:
16
21
  type: object
17
22
  label: Image
@@ -3,7 +3,7 @@
3
3
  {% set theme = theme|default(herocard.theme) %}
4
4
  {% set background = background|default(herocard.background) %}
5
5
 
6
- <div class="hero hero__card-justify__{{ justify }} hero__poster-size__{{ postersize }} hero__card-size__{{ cardsize }} hero__card-align__{{ align }} hero__card-theme__{{ theme }}">
6
+ <div class="hero {% if gap %} hero__gap__{{ gap }} {% endif %} hero__card-justify__{{ justify }} hero__poster-size__{{ postersize }} hero__card-size__{{ cardsize }} hero__card-align__{{ align }} hero__card-theme__{{ theme }} hero__card-background__{{ background }}">
7
7
  <figure class="hero--background">
8
8
  {% block hero_image %}
9
9
  {% if image %}
@@ -19,7 +19,6 @@
19
19
  {% endblock %}
20
20
  </figure>
21
21
  {% if breadcrumb %}
22
- <div class="hero--breadcrumbs-offset"></div>
23
22
  <div class="hero--breadcrumbs">
24
23
  <div class="hero--breadcrumbs--wrapper">
25
24
  {% include "@components/breadcrumb/breadcrumb.twig" with {
@@ -65,6 +65,15 @@ hero:
65
65
  preview:
66
66
  label: A metalurgy worker at a manufacturing plant in Viet Nam. © ILO/Minh Quang
67
67
  settings:
68
+ gap:
69
+ label: Gap
70
+ description: The color of the gap between the bottom of the hero image and the bottom of the card if there is one. In practice, this is the background color of the entire Hero component which will usually only be visible in that space.
71
+ type: select
72
+ options:
73
+ transparent: transparent
74
+ white: white
75
+ light: light
76
+ dark: dark
68
77
  justify:
69
78
  label: Justify
70
79
  description: Sets the horizontal alignment of the hero card. `start` is on the left in LTR layouts and on the right in RTL layouts.
@@ -3,6 +3,9 @@
3
3
  *
4
4
  * @class Tooltip
5
5
  */
6
+
7
+ import { createPopper, right } from "@popperjs/core";
8
+
6
9
  export default class Tooltip {
7
10
  /**
8
11
  * Tooltip constructor which assigns the element passed into the constructor
@@ -100,96 +103,54 @@ export default class Tooltip {
100
103
  }
101
104
 
102
105
  handleOnMouseOut() {
103
- this.tooltip.classList.remove(`${this.prefix}--tooltip--fade`);
104
106
  setTimeout(() => {
107
+ this.tooltip.classList.remove(`${this.prefix}--tooltip--fade`);
105
108
  this.tooltip.classList.remove(`${this.prefix}--tooltip--visible`);
106
- }, 150);
109
+ }, 200);
107
110
 
108
111
  return this;
109
112
  }
110
113
 
111
114
  postMouseOver(hoverRect) {
112
- // position the tooltip after showing it
113
- let placement = "center";
114
- let alignment = "left";
115
-
116
115
  const ttNode = this.tooltip;
116
+ this.setMaxWidthAndClass(this.tooltip);
117
117
  if (ttNode != null) {
118
- let x = 0,
119
- y = 0;
120
-
121
- const docWidth = document.documentElement.clientWidth,
122
- docHeight = document.documentElement.clientHeight;
123
-
124
- const rx = hoverRect.x + hoverRect.width, // most right x
125
- lx = hoverRect.x, // most left x
126
- ty = hoverRect.y, // most top y
127
- by = hoverRect.y + hoverRect.height; // most bottom y
128
-
129
- // tooltip rectange
130
- const ttRect = ttNode.getBoundingClientRect();
131
-
132
- const bRight =
133
- rx + ttRect.width <= window.scrollX + docWidth &&
134
- ty + ttRect.height <= window.scrollY + docHeight;
135
- const bLeft =
136
- lx - ttRect.width >= 0 &&
137
- ty + ttRect.height <= window.scrollY + docHeight;
138
- const bAbove = ty - ttRect.height >= 0;
139
- const bBellow = by + ttRect.height <= window.scrollY + docHeight;
140
-
141
- // the tooltip doesn't fit to the left
142
- if (bRight) {
143
- x = hoverRect.width + 32;
144
- y = 0;
145
- placement = "negative";
146
- alignment = "right";
147
- } else if (bBellow) {
148
- x = 0;
149
- y = hoverRect.height + 32;
150
-
151
- placement = "center";
152
- alignment = "bottom";
153
- } else if (bLeft) {
154
- x = -ttRect.width - 32;
155
- y = 0;
156
-
157
- placement = "negative";
158
- alignment = "left";
159
- } else if (bAbove) {
160
- x = 0;
161
- y = -ttRect.height - 32;
162
-
163
- placement = "center";
164
- alignment = "top";
118
+ // Create Popper instance if not already existing
119
+ if (!this.popper) {
120
+ this.popper = createPopper(this.element, this.tooltip, {
121
+ // Set tooltip priority to be placed on top first
122
+ placement: "top",
123
+ modifiers: [
124
+ "flip", // Changes the side of the tooltip if there isnt space
125
+ "preventOverflow",
126
+ {
127
+ name: "offset",
128
+ options: {
129
+ offset: [0, 12], // Adjust offset as needed
130
+ },
131
+ },
132
+ ],
133
+ });
165
134
  }
166
135
 
167
- // set style top and left on tooltip
168
- this.tooltip.style.top = y;
169
- this.tooltip.style.left = x;
170
-
171
- // set class for placement on arrow
172
- this.arrow.classList.remove(
173
- `${this.prefix}--tooltip--arrow--placement-${this.placement}`
174
- );
175
- this.arrow.classList.add(
176
- `${this.prefix}--tooltip--arrow--placement-${this.placement}`
177
- );
178
- this.placement = placement;
179
- this.arrow.setAttribute("data-placement", placement);
180
-
181
- // set class for alignment on tooltip
182
- this.tooltip.classList.remove(
183
- `${this.prefix}--tooltip--alignment-${this.alignment}`
184
- );
185
- this.tooltip.classList.add(
186
- `${this.prefix}--tooltip--alignment-${this.alignment}`
187
- );
188
- this.alignment = alignment;
189
-
190
- this.tooltip.setAttribute("data-alignment", alignment);
136
+ // Update Popper position
137
+ this.popper.update();
191
138
  }
192
139
 
193
140
  return this;
194
141
  }
142
+
143
+ /**
144
+ * Set max width and add class based on content length
145
+ *
146
+ * @param {string} content - Tooltip content
147
+ */
148
+ setMaxWidthAndClass(tooltip) {
149
+ const tooltipText = tooltip.textContent || tooltip.innerText;
150
+ const textLength = tooltipText.trim().length;
151
+
152
+ if (textLength > 50) {
153
+ this.tooltip.classList.add(`${this.prefix}--tooltip--long`);
154
+ }
155
+ }
195
156
  }
@@ -7,8 +7,8 @@
7
7
  {% if not icon or icon == "false" %}
8
8
  {{ children|raw }}
9
9
  {% endif %}
10
- <span class="{{prefix}}--tooltip {{prefix}}--tooltip--{{theme}}" data-alignment="left" id={{tooltipId}}>
11
- <span class="{{prefix}}--tooltip--arrow {{prefix}}--tooltip--arrow--placement-negative" data-placement="negative" role="presentation"></span>
10
+ <span data-id={{tooltipId}} id="tooltip" role="tooltip" class="{{prefix}}--tooltip {{prefix}}--tooltip--{{theme}}" data-alignment="left" >
11
+ <span data-popper-arrow class="{{prefix}}--tooltip--arrow {{prefix}}--tooltip--arrow--placement-negative" data-placement="negative" role="presentation"></span>
12
12
  {{label}}
13
13
  </span>
14
14
  </div>