@ilo-org/twig 0.1.2 → 0.1.3

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @ilo-org/twig
2
2
 
3
+ ## 0.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 774682316: Card fixes such as font sizes and some slight tweaks to make sure all the data is displayed
8
+ - 2d7d8114a: Bug fixes and right-to-left stlying for rich text, tabs, image and credit components
9
+ - 04fe60f9f: Mostly design bugfixes across multiple components
10
+ - Updated dependencies [774682316]
11
+ - Updated dependencies [2d7d8114a]
12
+ - Updated dependencies [04fe60f9f]
13
+ - @ilo-org/icons@0.1.3
14
+ - @ilo-org/styles@0.1.3
15
+ - @ilo-org/themes@0.1.3
16
+
3
17
  ## 0.1.2
4
18
 
5
19
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ilo-org/twig",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Twig components for the ILO's Design System",
6
6
  "main": "",
@@ -21,9 +21,9 @@
21
21
  ],
22
22
  "dependencies": {
23
23
  "@ilo-org/fonts": "0.0.2",
24
- "@ilo-org/icons": "0.1.2",
25
- "@ilo-org/styles": "0.1.2",
26
- "@ilo-org/themes": "0.1.2",
24
+ "@ilo-org/icons": "0.1.3",
25
+ "@ilo-org/styles": "0.1.3",
26
+ "@ilo-org/themes": "0.1.3",
27
27
  "@ilo-org/utils": "0.0.1",
28
28
  "@wingsuit-designsystem/preset-scss": "^1.2.3",
29
29
  "video.js": "^7.19.2"
@@ -47,6 +47,8 @@ export default class Breadcrumb {
47
47
  cacheDomReferences() {
48
48
  this.breadcrumbs = this.element.querySelector('.ilo--breadcrumb--items');
49
49
  this.breadcrumbwidth = this.breadcrumbs.offsetWidth;
50
+ this.ContextButton = this.element.querySelector(`.${this.prefix}--breadcrumb--item--context`);
51
+ this.ContextMenu = this.element.querySelector(`.context--menu`);
50
52
 
51
53
  return this;
52
54
  }
@@ -59,6 +61,7 @@ export default class Breadcrumb {
59
61
  */
60
62
  setupHandlers() {
61
63
  this.onResize = this.onResize.bind(this);
64
+ this.onClick = this.onClick.bind(this);
62
65
 
63
66
  return this;
64
67
  }
@@ -71,6 +74,7 @@ export default class Breadcrumb {
71
74
  */
72
75
  enable() {
73
76
  window.addEventListener(EVENTS.RESIZE, (e) => this.onResize(e));
77
+ this.ContextButton.addEventListener(EVENTS.CLICK, () => this.onClick());
74
78
 
75
79
  return this;
76
80
  }
@@ -84,8 +88,28 @@ export default class Breadcrumb {
84
88
  onResize(e) {
85
89
  if (this.breadcrumbwidth > this.element.offsetWidth / 2) {
86
90
  this.element.classList.add('contextmenu');
91
+ this.ContextMenu.classList.remove('open');
87
92
  } else {
88
93
  this.element.classList.remove('contextmenu');
94
+ this.ContextMenu.classList.remove('open');
95
+ }
96
+
97
+ return this;
98
+ }
99
+
100
+ /**
101
+ * OnClick interaction with the ContextMenu button
102
+ *
103
+ * @return {Object} Breadcrumb A reference to the instance of the class
104
+ * @chainable
105
+ */
106
+ onClick() {
107
+ if (this.element.classList.contains('contextmenu')) {
108
+ if (this.ContextMenu.classList.contains('open')) {
109
+ this.ContextMenu.classList.remove('open');
110
+ } else {
111
+ this.ContextMenu.classList.add('open');
112
+ }
89
113
  }
90
114
 
91
115
  return this;
@@ -2,7 +2,7 @@
2
2
  BUTTON COMPONENT
3
3
  #}
4
4
  {% if url %}
5
- <a class="{{prefix}}--button ilo--button--{{size}} {{prefix}}--button--{{type}}{% if icon %} icon icon__position--{{iconPos}}{% endif %}{% if icononly %} icon--only{% endif %}{% if className %} {{className}}{% endif %}" href="{{url}}" {% if target is defined and target == 'true' %}target="{{target}}" rel="noopener noreferrer"{% endif %} {% if disabled is defined and disabled == 'true' %}disabled{% endif %}>
5
+ <a class="{{prefix}}--button ilo--button--{{size}} {{prefix}}--button--{{type}}{% if icon %} icon icon__position--{{iconPos}}{% endif %}{% if icononly %} icon--only{% endif %}{% if className %} {{className}}{% endif %}" href="{{url}}" {% if target is defined and target != 'false' %}target="{{target}}" rel="noopener noreferrer"{% endif %} {% if disabled is defined and disabled == 'true' %}disabled{% endif %}>
6
6
  <span class="link__label">{{label}}</span>
7
7
  {% if icon %}
8
8
  {% include '@components/icon/icon.twig' with {icon: icon} %}
@@ -2,8 +2,11 @@
2
2
  CARD COMPONENT
3
3
  #}
4
4
  <div class="{{prefix}}--card {{prefix}}--card--{{theme}} {{prefix}}--card--{{variant}}{% if cornercut %} {{prefix}}--card--{{cornercut}}{% endif %}{% if color %} {{prefix}}--card--{{color}}{% endif %}{% if alignment %} {{prefix}}--card--{{alignment}}{% endif %} {% if link %} {{prefix}}--card--action{% endif %}{% if type %}
5
- {{prefix}}--card--{{type}}{% endif %}{% if type %}
5
+ {{prefix}}--card--{{type}}{% endif %}{% if size %}
6
6
  {{prefix}}--card--{{size}}{% endif %}">
7
+ {% if type == "" %}
8
+ {% set type = variant %}
9
+ {% endif %}
7
10
  {% if link %}
8
11
  <a class="{{prefix}}--card--link" href="{{link}}" title="{{title}}"><span class="{{prefix}}--card--link--text">{{title}}</span></a>
9
12
  {% endif %}
@@ -18,7 +21,7 @@
18
21
  {% if title %}
19
22
  <h5 class="{{prefix}}--card--title">{{title}}</h5>
20
23
  {% endif %}
21
- {% if type == "multilink" and image %}
24
+ {% if type == "multilink" or type == "data" and image %}
22
25
  <div class="{{prefix}}--card--image--wrapper"><picture><img class="{{prefix}}--card--image" src="{{image}}" alt="{{title}}"></picture></div>
23
26
  {% endif %}
24
27
  {% if intro %}
@@ -50,7 +53,7 @@
50
53
  } only %}
51
54
  {% endif %}
52
55
  {% if cta %}
53
- <a class="{{prefix}}--card--cta {{prefix}}--button {{prefix}}--button--small {{prefix}}--button--primary" href="{{cta.url}}">
56
+ <a class="{{prefix}}--card--cta {{prefix}}--button {{prefix}}--button--medium {{prefix}}--button--primary" href="{{cta.url}}">
54
57
  <span class="link__label">{{cta.label}}</span>
55
58
  </a>
56
59
  {% endif %}
@@ -86,6 +89,7 @@
86
89
  {% endif %}
87
90
  {% if dataset.links %}
88
91
  <div class="{{prefix}}--card--data--content-links">
92
+ <p class="{{prefix}}--card--data--content-label">{{ dataset.links.headline }}</p>
89
93
  {% for item in dataset.links.items %}
90
94
  {% include "@components/link/link.twig" with {
91
95
  url: item.url,
@@ -156,7 +156,6 @@ card:
156
156
  source:
157
157
  label: "Source: lorem ipsum dolor sit amet, 2020"
158
158
  url: "https://www.google.com/search?q=stat"
159
- color: blue
160
159
  multilink:
161
160
  label: Multilink Card
162
161
  description: The multilink Card
@@ -338,8 +338,7 @@ cardgroup:
338
338
  fields:
339
339
  group:
340
340
  - title: ""
341
- image: ""
342
- # image: "https://placekitten.com/205/179"
341
+ image: "https://placekitten.com/205/179"
343
342
  intro: ""
344
343
  eyebrow: "Event details"
345
344
  date: ""
@@ -101,7 +101,6 @@ form:
101
101
  label: "File Upload Field Label"
102
102
  name: "fileupload"
103
103
  placeholder: "File Upload Field"
104
- tooltip: "Tooltip"
105
104
  type: "file"
106
105
  - field:
107
106
  label: "Date Picker Field Label"
@@ -105,7 +105,7 @@ export default class Modal {
105
105
  * @chainable
106
106
  */
107
107
  closeButtonClick() {
108
- this.element.classList.remove('fadeout');
108
+ this.element.classList.remove('fadein');
109
109
  setTimeout(() => {
110
110
  this.element.classList.remove('show');
111
111
  }, 125);
@@ -8,8 +8,8 @@ modal:
8
8
  label: Closee Button
9
9
  description: Label and settings for the "close" button
10
10
  preview:
11
- size: 'small'
12
- type: 'secondary'
11
+ size: 'medium'
12
+ type: 'tertiary'
13
13
  label: 'Close Button'
14
14
  icon: close
15
15
  iconPos: center
@@ -28,15 +28,6 @@ notification:
28
28
  description: The headline of the notification
29
29
  required: true
30
30
  preview: 'With CTA'
31
- placement:
32
- type: select
33
- label: Placement
34
- description: The placement of the notification
35
- required: true
36
- options:
37
- inline: Inline
38
- dialog: Dialog
39
- preview: 'dialog'
40
31
  type:
41
32
  type: select
42
33
  label: Type
@@ -55,4 +46,13 @@ notification:
55
46
  preview:
56
47
  human: Dec 7, 2022
57
48
  unix: 1670389200
49
+ settings:
50
+ placement:
51
+ type: select
52
+ label: Placement
53
+ description: Is this notification inline (in the flow of the document) or a dialog (highest on the z-index and fixed-position)?
54
+ options:
55
+ inline: Inline
56
+ dialog: Dialog
57
+ preview: 'dialog'
58
58
  visibility: storybook
@@ -18,5 +18,5 @@ searchfield:
18
18
  helper: "The search field's helper text"
19
19
  name: "text"
20
20
  placeholder: "Search Field"
21
- type: "text"
21
+ type: "search"
22
22
  visibility: storybook
@@ -201,6 +201,10 @@ export default class Table {
201
201
  );
202
202
  });
203
203
 
204
+ if (e.target.hasAttribute('href')) {
205
+ window.location.href = e.target.getAttribute('href');
206
+ }
207
+
204
208
  return this;
205
209
  }
206
210
 
@@ -5,6 +5,9 @@
5
5
  <header class="{{prefix}}--table--header">
6
6
  <h3 class="{{prefix}}--table--headline">
7
7
  {{headline}}
8
+ {% if tooltip %}
9
+ {% include '@components/tooltip/tooltip.twig' with tooltip %}
10
+ {% endif %}
8
11
  </h3>
9
12
  {% if description is defined %}
10
13
  <p class="{{prefix}}--table--description">
@@ -9,7 +9,7 @@ table:
9
9
  description: The table's headline
10
10
  preview: "Headline"
11
11
  required: true
12
- toolip:
12
+ tooltip:
13
13
  type: object
14
14
  label: Tooltip
15
15
  description: If there is a tooltip next to the headline, the tooltip's data
@@ -4,3 +4,4 @@
4
4
  // Module template
5
5
  import './tableofcontents.twig';
6
6
  import './tableofcontents.wingsuit.yml';
7
+ import './tableofcontents.behavior';
@@ -0,0 +1,14 @@
1
+ import TableOfContents from './tableofcontents';
2
+
3
+ Drupal.behaviors.tableofcontents = {
4
+ attach() {
5
+ Array.prototype.forEach.call(
6
+ document.querySelectorAll(`[data-loadcomponent="TableOfContents"]`),
7
+ (element) => {
8
+ // eslint-disable-next-line no-console
9
+ console.log('loading TableOfContents component....');
10
+ new TableOfContents(element);
11
+ }
12
+ );
13
+ },
14
+ };
@@ -0,0 +1,164 @@
1
+ import { EVENTS } from '@ilo-org/utils';
2
+
3
+ /**
4
+ * The TableOfContents module which handles control and display of a TableOfContents dialog
5
+ *
6
+ *
7
+ * @class TableOfContents
8
+ */
9
+ export default class TableOfContents {
10
+ /**
11
+ * TableOfContents constructor which assigns the element passed into the constructor
12
+ * to the `this.element` property for later reference
13
+ *
14
+ * @param {HTMLElement} element - REQUIRED - the module's container
15
+ */
16
+ constructor(element) {
17
+ /**
18
+ * Reference to the DOM element that is the root of the component
19
+ * @property {Object}
20
+ */
21
+ this.element = element;
22
+
23
+ // get the theme prefix
24
+ this.prefix = this.element.dataset.prefix;
25
+
26
+ // Initialize the view
27
+ this.init();
28
+ }
29
+
30
+ /**
31
+ * Initializes the view by calling the functions to
32
+ * create DOM references, setup event handlers and
33
+ * then create the event listeners
34
+ *
35
+ * @return {Object} TableOfContents A reference to the instance of the class
36
+ * @chainable
37
+ */
38
+ init() {
39
+ this.cacheDomReferences().setupHandlers().enable();
40
+
41
+ return this;
42
+ }
43
+
44
+ /**
45
+ * Find all necessary DOM elements used in the view and cache them
46
+ *
47
+ * @return {Object} ReadMore A reference to the instance of the class
48
+ * @chainable
49
+ */
50
+ cacheDomReferences() {
51
+ /**
52
+ * The button for toggling Read More state
53
+ * @type {Object}
54
+ */
55
+ this.OpenButton = this.element.querySelector(`.toc--modal--open`);
56
+ this.CloseButton = this.element.querySelector(`.toc--modal--close`);
57
+ this.trigger = this.element.querySelector(`.${this.prefix}--table-of-contents--trigger`);
58
+ this.modalUx = this.element.querySelector(`.${this.prefix}--table-of-contents--modal`);
59
+ this.toc = this.element.querySelector(`.${this.prefix}--table-of-contents`);
60
+ this.tocItems = this.element.querySelectorAll(`.${this.prefix}--table-of-contents--link`);
61
+
62
+ return this;
63
+ }
64
+
65
+ /**
66
+ * Bind event handlers with the proper context of `this`.
67
+ *
68
+ * @return {Object} TableOfContents A reference to the current instance of the class
69
+ * @chainable
70
+ */
71
+ setupHandlers() {
72
+ this.OpenButtonHandler = this.openButtonClick.bind(this);
73
+ this.CloseHandler = this.closeButtonClick.bind(this);
74
+ this.KeyPressHandler = this.keyPress.bind(this);
75
+ this.linkClickHandler = this.linkClick.bind(this);
76
+
77
+ return this;
78
+ }
79
+
80
+ /**
81
+ * Creates event listeners to enable interaction with view
82
+ *
83
+ * @return {Object} TableOfContents A reference to the instance of the class
84
+ * @chainable
85
+ */
86
+ enable() {
87
+ this.OpenButton.addEventListener(EVENTS.CLICK, () => this.OpenButtonHandler());
88
+ this.CloseButton.addEventListener(EVENTS.CLICK, () => this.CloseHandler());
89
+
90
+ if (this.tocItems.length > 0) {
91
+ this.tocItems.forEach((link, i) => {
92
+ link.addEventListener(EVENTS.CLICK, () => this.linkClickHandler());
93
+ });
94
+ }
95
+
96
+ return this;
97
+ }
98
+
99
+ /**
100
+ * Actions performed on click of the open button
101
+ *
102
+ * @return {Object} TableOfContents A reference to the instance of the class
103
+ * @chainable
104
+ */
105
+ openButtonClick() {
106
+ this.trigger.classList.add('hide');
107
+ this.element.classList.add('show');
108
+ this.modalUx.classList.add('show');
109
+ this.toc.classList.add('show');
110
+ setTimeout(() => {
111
+ this.modalUx.classList.add('fadein');
112
+ this.toc.classList.add('fadein');
113
+ }, 125);
114
+ window.addEventListener(EVENTS.KEY_DOWN, (e) => this.KeyPressHandler(e));
115
+
116
+ return this;
117
+ }
118
+
119
+ /**
120
+ * Actions performed on click of the close button
121
+ *
122
+ * @return {Object} TableOfContents A reference to the instance of the class
123
+ * @chainable
124
+ */
125
+ closeButtonClick() {
126
+ this.modalUx.classList.remove('fadein');
127
+ this.toc.classList.remove('fadein');
128
+ setTimeout(() => {
129
+ this.modalUx.classList.remove('show');
130
+ this.toc.classList.remove('show');
131
+ this.element.classList.remove('show');
132
+ this.trigger.classList.remove('hide');
133
+ }, 125);
134
+ window.removeEventListener(EVENTS.KEY_DOWN, (e) => this.KeyPressHandler(e));
135
+
136
+ return this;
137
+ }
138
+
139
+ /**
140
+ * Actions performed on click of any link
141
+ *
142
+ * @return {Object} TableOfContents A reference to the instance of the class
143
+ * @chainable
144
+ */
145
+ linkClick() {
146
+ this.closeButtonClick();
147
+
148
+ return this;
149
+ }
150
+
151
+ /**
152
+ * Actions performed on key press
153
+ *
154
+ * @return {Object} TableOfContents A reference to the instance of the class
155
+ * @chainable
156
+ */
157
+ keyPress(e) {
158
+ if (e.key === 'Escape') {
159
+ this.closeButtonClick();
160
+ }
161
+
162
+ return this;
163
+ }
164
+ }
@@ -2,13 +2,22 @@
2
2
  TABLE OF CONTENTS COMPONENT
3
3
  #}
4
4
  {% if items %}
5
- <nav class="{{prefix}}--table-of-contents">
6
- <ul class="{{prefix}}--table-of-contents--list">
7
- {% for item in items %}
8
- <li class="{{prefix}}--table-of-contents--list--item">
9
- <a class="{{prefix}}--table-of-contents--link" href="{{item.href}}">{{item.label}}</a>
10
- </li>
11
- {% endfor %}
12
- </ul>
13
- </nav>
5
+ <div class="{{prefix}}--table-of-contents--wrapper" data-loadcomponent="TableOfContents" data-prefix="{{prefix}}">
6
+ <div class="{{prefix}}--table-of-contents--trigger">
7
+ {% include '@components/button/button.twig' with openbutton %}
8
+ </div>
9
+ <div class="{{prefix}}--table-of-contents--modal">
10
+ <h3 class="{{prefix}}--table-of-contents--headline">{{headline}}</h3>
11
+ {% include '@components/button/button.twig' with closebutton %}
12
+ </div>
13
+ <nav class="{{prefix}}--table-of-contents">
14
+ <ul class="{{prefix}}--table-of-contents--list">
15
+ {% for item in items %}
16
+ <li class="{{prefix}}--table-of-contents--list--item">
17
+ <a class="{{prefix}}--table-of-contents--link" href="{{item.href}}">{{item.label}}</a>
18
+ </li>
19
+ {% endfor %}
20
+ </ul>
21
+ </nav>
22
+ </div>
14
23
  {% endif %}
@@ -3,6 +3,35 @@ tableofcontents:
3
3
  label: Table Of Contents
4
4
  description: A component for displaying links internal to a page
5
5
  fields:
6
+ openbutton:
7
+ type: object
8
+ label: Open Button
9
+ description: The label and settings for the button that will show the table of contents at small breakpoints
10
+ preview:
11
+ size: 'medium'
12
+ type: 'secondary'
13
+ label: 'Open Button'
14
+ className: 'toc--modal--open'
15
+ opensmodal: true
16
+ required: true
17
+ closebutton:
18
+ type: object
19
+ label: Close Button
20
+ description: Label and settings for the "close" button
21
+ preview:
22
+ size: 'large'
23
+ type: 'tertiary'
24
+ label: 'Close Button'
25
+ icon: close
26
+ iconPos: center
27
+ icononly: true
28
+ className: 'toc--modal--close'
29
+ headline:
30
+ type: string
31
+ label: Headline
32
+ description: A headline for the small breakpoint view of the table of contents, shown when it is opened. Design recommendation is that this matches the page title as shown in the hero.
33
+ preview: "Page Title"
34
+ required: true
6
35
  items:
7
36
  type: object
8
37
  label: Items
@@ -6,7 +6,6 @@
6
6
  {% for item in items %}
7
7
  {% set tabids = tabids|merge([random(100000)]) %}
8
8
  {% endfor %}
9
-
10
9
  <div class="{{prefix}}--tabs" data-prefix="{{prefix}}" id="tabs--{{uid}}" data-loadcomponent="Tabs">
11
10
  <ul class="{{prefix}}--tabs--selection" aria-controls="tabs--{{uid}}" role="tablist" style="--tabscount: {{items|length}};">
12
11
  {% for item in items %}