@ilo-org/twig 0.13.0 → 0.14.1

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.1 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.1 output /home/runner/work/designsystem/designsystem/packages/twig
8
8
  > node outputtwigs.js
9
9
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # @ilo-org/twig
2
2
 
3
+ ## 0.14.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 9d79b2a6f: Modify tooltip label and icon condition
8
+ - 1e6365385: Add popperjs as a dependency in twig instead of as a dev dependency
9
+
10
+ ## 0.14.0
11
+
12
+ ### Minor Changes
13
+
14
+ - df7080c80: Used popper library to handle tooltip
15
+ - 6fe60e0d6: Add a `gap` setting to the hero card that allows the developer to set an optional background color on the entire Hero,
16
+ 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`.
17
+
18
+ ### Patch Changes
19
+
20
+ - b014e9af0: Fix Breadcrumb incorrectly assuming there will always be at least two links
21
+ - c54ce9923: Fix Breadcrumb spacing vis-a-vis Hero
22
+ - a78b32be4: Add eyebrow to multilink card
23
+ - 9ed7b873d: build(deps-dev): bump postcss from 8.4.21 to 8.4.31
24
+ - Updated dependencies [df7080c80]
25
+ - Updated dependencies [c5eaabd55]
26
+ - Updated dependencies [720825342]
27
+ - Updated dependencies [6f86e7a94]
28
+ - Updated dependencies [94b03b9be]
29
+ - Updated dependencies [c54ce9923]
30
+ - Updated dependencies [6fe60e0d6]
31
+ - Updated dependencies [9ed7b873d]
32
+ - Updated dependencies [c173ec9f8]
33
+ - @ilo-org/styles@0.13.0
34
+
3
35
  ## 0.13.0
4
36
 
5
37
  ### Minor Changes
@@ -4,23 +4,12 @@ import { getStorybook, storiesOf } from "@storybook/react";
4
4
  import LinkTo from "@storybook/addon-links/react";
5
5
 
6
6
  <Meta
7
- title="Introduction"
7
+ title="Getting Started"
8
8
  parameters={{ viewMode: "docs", previewTabs: { canvas: { hidden: true } } }}
9
9
  />
10
10
 
11
11
  <div style={{ paddingTop: "40px", color: "inherit" }}>
12
- <h2
13
- style={{
14
- fontFamily: "Overpass",
15
- fontSize: "56.95px",
16
- fontWeight: "700",
17
- marginBottom: "40px",
18
- border: "none",
19
- }}
20
- >
21
- ILO Design System
22
- </h2>
23
- <h3
12
+ <h1
24
13
  style={{
25
14
  fontFamily: "Overpass",
26
15
  fontSize: "45.56px",
@@ -29,288 +18,167 @@ import LinkTo from "@storybook/addon-links/react";
29
18
  }}
30
19
  >
31
20
  Getting Started
32
- </h3>
21
+ </h1>
33
22
  </div>
34
23
 
35
- This package provides the implementation of the Design System using [Twig](https://twig.symfony.com/doc/). It also includes a [Storybook](https://storybook.js.org/) project for documentation and development of Twig components, using [Wingsuit](https://wingsuit-designsystem.github.io/). Wingsuit uses [Twing](https://www.npmjs.com/package/twing), a Node port of Twig, to compile Twigs to HTML. It has dependencies on the following other @ilo-org packages:
36
-
37
- - [@ilo-org/themes](./packages/themes)
38
- - [@ilo-org/fonts](./packages/fonts)
39
- - [@ilo-org/styles](./packages/styles)
40
- - [@ilo-org/utils](./packages/utils)
41
- - [@ilo-org/icons](./packages/icons)
42
-
43
- <h4
44
- style={{
45
- fontFamily: "Overpass",
46
- fontSize: "29px",
47
- fontWeight: "700",
48
- marginBottom: "40px",
49
- marginTop: "40px",
50
- }}
51
- >
52
- Installation and PNPM Commands
53
- </h4>
54
-
55
- To install
56
-
57
- ```bash
58
- npm i @ilo-org/twig
59
- ```
60
-
61
- To start storybook
62
-
63
- ```bash
64
- pnpm storybook
65
- ```
66
-
67
- To build storybook
68
-
69
- ```bash
70
- pnpm build:storybook
71
- ```
72
-
73
- To build and start storybook
74
-
75
- ```bash
76
- pnpm build
77
- ```
78
-
79
- To build Twigs to be used in a CMS like Drupal (this will output Twigs and necessary JavaScript to a `/dist` folder.)
80
-
81
- ```bash
82
- pnpm output
83
- ```
84
-
85
- This package imports the `prefix` from the `themes` package; to manually import it, run
86
-
87
- ```bash
88
- pnpm import:prefix
89
- ```
90
-
91
- This package imports icon svgs from the `icons` package; to manually import them, run
92
-
93
- ```bash
94
- pnpm import:svgs
95
- ```
96
-
97
- <h4
98
- style={{
99
- fontFamily: "Overpass",
100
- fontSize: "29px",
101
- fontWeight: "700",
102
- marginBottom: "40px",
103
- marginTop: "40px",
104
- }}
105
- >
106
- Architecture
107
- </h4>
108
-
109
- Because this is a modified version of Storybook which compliles and displays Twigs instead of React components, there are some notable differences between this and vanilla versions of Storybook. One prominent difference is in directory structure. Each component folder, located in `src/patterns/components`, contains the following files:
110
-
111
- ```
112
- component.stories.jsx
113
- component.twig
114
- component.wingsuit.yml
115
- index.js
116
- ```
117
-
118
- and potentially, if Javascript interactivity exists, also the following:
119
-
120
- ```
121
- component.behavior.js
122
- component.js
123
- ```
124
-
125
- Wingsuit consumes the `component.wingsuit.yml` file, which is a [UI Pattern YAML](https://wingsuit-designsystem.github.io/components/wingsuit/) borrowed from [Drupal](https://www.drupal.org/project/ui_patterns_settings), and uses this to populate and format the Storybook story for each components. **As such, one is limited in how much one can customize the Storybook experience.**
126
-
127
- <h4
128
- style={{
129
- fontFamily: "Overpass",
130
- fontSize: "29px",
131
- fontWeight: "700",
132
- marginBottom: "40px",
133
- marginTop: "40px",
134
- }}
135
- >
136
- Javascript
137
- </h4>
24
+ Welcome to the ILO Design System Twig component library. This resource is crafted to assist developers in creating accessible, user-friendly websites for Drupal that with the International Labour Organization's Visual Identity. The library offers a variety of easy-to-use components tailored for these popular platforms, ensuring both compliance with web accessibility standards and a cohesive visual style. Components are responsive and are ready-made for RTL layouts.
138
25
 
139
- In this package, Javascript is vanilla, with each component that requires Javascript functionality loading an [ES class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) named after the component, scoped and bound to the component's outermost element. Wingsuit is configured to instantiate view classes via a function that looks for a [data attribute](https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes) that calls the view name provided in that attribute. On page load, the app looks for elements with the data attribute `data-loadcomponent` and loads whatever modules have corresponding names, passing a reference to the `HTMLElement` containing the data attribute. All the JS is bundled by Webpack into one file, meaning the JS file can be cached and only has to be downloaded from the server once per session.
26
+ ## Requirements
140
27
 
141
- The JS is well-documented in comments, so poke around and you'll get the gist of how it works.
28
+ The Design System comprises a series of packages that you can install from the [npm](https://www.npmjs.com/) registry directly into your custom theme. As such, you'll need to have `npm` or similar package manager (`yarn` or `pnpm`) installed in your environment.
142
29
 
143
- Here's an example of HTML component markup that will automatically call some Javascript. Given the following HTML:
30
+ ## Installation
144
31
 
145
- ```
146
- <section class="component componentname" data-loadcomponent="ComponentName">
147
- <!-- component HTML goes here -->
148
- </section>
149
- ```
150
-
151
- Javascript will look in the `ComponentMap` Class for a JS Class called `ComponentName` and then create a new instance of that class and call it. If you've added a new JS Class specific to the module you've built, you'll need to import the JS file to `ComponenetMap` and add it to `ComponenteMap`'s exports. If you've created a new Class, you'll need to make sure to pass the param `element` into the constructor - this is a reference to the DOM element with the `data-loadcomponent` attribute on it. This allows you to scope your JS to each instance of an HTML module.
152
-
153
- <h4
154
- style={{
155
- fontFamily: "Overpass",
156
- fontSize: "29px",
157
- fontWeight: "700",
158
- marginBottom: "40px",
159
- marginTop: "40px",
160
- }}
161
- >
162
- Questions and Feedback
163
- </h4>
164
-
165
- (TBD)
166
-
167
- <h4
168
- style={{
169
- fontFamily: "Overpass",
170
- fontSize: "29px",
171
- fontWeight: "700",
172
- marginBottom: "40px",
173
- marginTop: "40px",
174
- }}
175
- >
176
- Accessibility Standards
177
- </h4>
178
-
179
- (TBD)
180
-
181
- <h4
182
- style={{
183
- fontFamily: "Overpass",
184
- fontSize: "29px",
185
- fontWeight: "700",
186
- marginBottom: "40px",
187
- marginTop: "40px",
188
- }}
189
- >
190
- Contributing
191
- </h4>
192
-
193
- ILO Design System is an open-source project and we welcome your contributions! Before submitting a pull request, please take a moment to review the following guidelines.
194
-
195
- ## Branches
196
-
197
- | Branch | Purpose |
198
- | --------- | ---------------------------------- |
199
- | `main` | The latest version of all packages |
200
- | `develop` | The next release of all packages |
201
-
202
- ## Contribution workflow
203
-
204
- 1. Fork and clone the repo
205
- 2. Create a new branch from the `develop` branch
206
- 3. Make your changes and [add a changeset](#versioning) identifying the changes and affected packages
207
- 4. Push your branch to the forked version of the repo
208
- 5. Open a pull request back to the `develop` branch of the main repo
209
-
210
- ## Versioning
211
-
212
- The project uses [changesets](https://github.com/changesets/changesets) to manage package versioning. All pull requests that will affect the project's semantic versioning must include a changest.
213
-
214
- See more information on [how to add a changeset](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md)
215
-
216
- ## Conventions
217
-
218
- Contributions should respect the following conventions for branch names, commit messages and pull request descriptions
32
+ You will want to install the latest versions of both `@ilo-org/twig` and `@ilo-org/styles`. The first includes all of the Twig and JavaScript files that you'll need to use the component, whereas the second includes the stylesheets that you'll need to render them.
219
33
 
220
- ### Commits
34
+ In the root of your custom theme, run the following command:
221
35
 
222
- Commits should follow [Angular Commit Message Guidelines](https://github.com/angular/angular/blob/22b96b9/CONTRIBUTING.md#commit).
36
+ `$ npm i @ilo-org/twig @ilo-org/styles`
223
37
 
224
- ```
225
- <type>(<scope>): <subject>
226
- ```
227
-
228
- Examples:
229
-
230
- ```
231
- fix(react): change button color on hover
232
- feat(twig): add button component
233
- ci(github): add release workflow
234
- perf(react): improve modal animations
235
- ```
236
-
237
- #### Types
238
-
239
- - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
240
- - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
241
- - docs: Documentation only changes
242
- - feat: A new feature
243
- - fix: A bug fix
244
- - perf: A code change that improves performance
245
- - refactor: A code change that neither fixes a bug nor adds a feature
246
- - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
247
- - test: Adding missing tests or correcting existing tests
248
-
249
- #### Scopes
38
+ ⚠️ Note that the two libraries are versioned separately so you'll want to make sure that you're always using the latest versions of both to ensure they're both in sync. You should see an installation warning if you try to install incompatible versions.
250
39
 
251
- This should be a package name or an aspect of the project's configuration.
40
+ ## Usage
252
41
 
253
- ### Branches
42
+ Now that you have installed the component library, you'll need to expose them so that you can integrate them into your templates.
254
43
 
255
- Branch names should broadly mirror the same convention as commits.
44
+ ### Bundle JavaScript
256
45
 
257
- Examples:
46
+ You'll want to start by moving the components' JavaScript to a distribution folder where you can serve it as static assets. The easiest way to do this is with a JavaScript bundler like [Rollup.js](https://rollupjs.org/). Here's a sample configuration to illustrate.
258
47
 
259
- ```
260
- feat/react/modal-wrapper
261
- fix/twig/modal-wrapper
262
- ```
263
-
264
- ### Pull requests
265
-
266
- Pull requests should include a descriptive name and detailed explanation of what merging the pull request will accomplish. Authors should make sure to reference Github issues that the the pull request will fix or affect.
267
-
268
- ## Building the project
48
+ ```js
49
+ import { nodeResolve } from "@rollup/plugin-node-resolve";
50
+ import commonjs from "@rollup/plugin-commonjs";
51
+ import { globSync } from "glob";
269
52
 
270
- Use [nvm](https://github.com/nvm-sh/nvm) to make sure you have the correct version of node installed.
53
+ const designSystemEntries = globSync(
54
+ "node_modules/@ilo-org/twig/dist/components/**"
55
+ );
271
56
 
272
- ```bash
273
- nvm use
57
+ export default () => {
58
+ return designSystemEntries.map((entry) => {
59
+ return {
60
+ input: entry,
61
+ output: {
62
+ dir: "dist/js",
63
+ compact: true,
64
+ format: "umd",
65
+ name: entry.match(/([^\/]+)\.js$/)[1],
66
+ },
67
+ plugins: [nodeResolve(), commonjs()],
68
+ };
69
+ });
70
+ };
274
71
  ```
275
72
 
276
- Install [pnpm](https://pnpm.io/).
73
+ This will output all of the Components JavaScript files into a `dist/js` directory so you'll have a list of both the component JavaScript and the `Drupal.behavior` declarations that you'll need to attach them to components.
277
74
 
278
- ```bash
279
- npm i -g pnpm
75
+ ```tree
76
+ 📦js
77
+ ┣ 📜accordion.behavior.js
78
+ ┣ 📜accordion.js
79
+ ┣ 📜breadcrumb.behavior.js
80
+ ┣ 📜breadcrumb.js
81
+ ┣ 📜callout.behavior.js
82
+ ┣ 📜callout.js
83
+ ...
280
84
  ```
281
85
 
282
- Install dependencies
86
+ ### Bundle CSS
283
87
 
284
- ```bash
285
- pnpm recursive install
286
- ```
287
-
288
- Build all packages.
88
+ The CSS files are available in the 'dist/css' subdirectories:
289
89
 
290
- ```bash
291
- pnpm build:all
90
+ ```tree
91
+ 📦css
92
+ ┣ 📂00-base
93
+ ┃ ┣ 📜base.css
94
+ ┣ 📂01-paragraphs
95
+ ┃ ┣ 📜paragraphs.css
96
+ ┃ ┗ 📜breadcrumb.css
97
+ ┣ 📂02-templates
98
+ ┃ ┣ 📜maintenance-page.css
99
+ ...
292
100
  ```
293
101
 
294
- Start React storybook
295
-
296
- ```bash
297
- pnpm start:react-storybook
298
- ```
102
+ ### Populating the theme.libraries.yml file
299
103
 
300
- Start Twig storybook
104
+ The theme.libraries.yml should first include the base CSS file:
301
105
 
302
- ```bash
303
- pnpm start:twig-storybook
106
+ ```yaml
107
+ base:
108
+ css:
109
+ theme:
110
+ dist/css/00-base/base.css: {}
111
+ node_modules/@ilo-org/styles/css/global.css: {}
112
+ node_modules/@ilo-org/styles/css/components/container.css: {}
304
113
  ```
305
114
 
306
- Check types
115
+ Then, for each component, you have to declare the CSS file in the theme.libraries.yml file. For example, for the breadcrumb component:
307
116
 
308
- ```bash
309
- pnpm check:types
117
+ ```yaml
118
+ breadcrumb:
119
+ css:
120
+ theme:
121
+ dist/css/01-paragraphs/breadcrumb.css: {}
310
122
  ```
311
123
 
312
- Run all tests
124
+ With the 'dist' directory in your theme, you have to declare the components in the theme.libraries.yml file. For example, for the breadcrumb component:
313
125
 
314
- ```bash
315
- pnpm test:all
126
+ ```yaml
127
+ breadcrumb:
128
+ css:
129
+ theme:
130
+ dist/css/01-paragraphs/breadcrumb.css: {}
131
+ embeds:
132
+ js:
133
+ dist/js/embeds.js: { defer: true }
134
+ ```
135
+
136
+ The documentation for the theme.libraries.yml file is available [here](https://www.drupal.org/docs/8/creating-custom-modules/adding-stylesheets-css-and-javascript-js-to-a-drupal-8-module).
137
+
138
+ In the template file of the component, you have to declare the component in the Twig file. For example, for the breadcrumb component:
139
+
140
+ ```twig
141
+ {{ attach_library('ilo/breadcrumb') }}
142
+
143
+ {% include '@ilo-org/twig/breadcrumb/breadcrumb.twig' with {
144
+ home: breadcrumb_home,
145
+ links: breadcrumb_links,
146
+ } %}
147
+ ```
148
+
149
+ A helper function in your theme.theme file to aggregate all .behavior.js files:
150
+
151
+ ```php
152
+ /**
153
+ * Implements hook_library_info_build().
154
+ *
155
+ * Generate libraries for all components if they don't already exist.
156
+ * The library name will mapped be the name of the source CSS / JS file,
157
+ * e.g. site_header.css will be mapped to `{THEME}/site_header`.
158
+ *
159
+ */
160
+ function theme_library_info_build() {
161
+ // Define libraries based on the components.
162
+ $extensions = ['css'];
163
+ $directory = 'themes/custom/ilo/node_modules/@ilo-org/styles/css/components';
164
+ $css = 'node_modules/@ilo-org/styles/css/components';
165
+ $js = 'dist/js';
166
+ $extensions = array_map('preg_quote', $extensions);
167
+ $extensions = implode('|', $extensions);
168
+ $file_scan = \Drupal::service('file_system')->scanDirectory($directory, "/{$extensions}$/");
169
+ $libraries = [];
170
+ foreach ($file_scan as $file) {
171
+ $libraries[$file->name]['css'] = [
172
+ 'component' => [
173
+ $css . '/' . $file->name . '.css' => [],
174
+ ],
175
+ ];
176
+ if (file_exists('themes/custom/ilo/' . $js . '/' . $file->name . '.behavior.js')) {
177
+ $libraries[$file->name]['js'] = [
178
+ $js . '/' . $file->name . '.behavior.js' => [],
179
+ ];
180
+ }
181
+
182
+ return $libraries;
183
+ }
316
184
  ```
@@ -24,12 +24,21 @@ import LinkTo from "@storybook/addon-links/react";
24
24
  </a>
25
25
  <a
26
26
  class="ilo--button ilo--button--large ilo--button--tertiary optionalclass"
27
- href="https://brand.ilo.org"
27
+ href="https://brand.ilo.org/designsystem"
28
28
  target="true"
29
29
  rel="noopener noreferrer"
30
30
  style={{ margin: "1rem 20px 0 0" }}
31
31
  >
32
32
  <span class="link__label">Design Docs</span>
33
+ </a>
34
+ <a
35
+ class="ilo--button ilo--button--large ilo--button--tertiary optionalclass"
36
+ href="https://www.figma.com/file/RRxsfLNxjoypKrfJg1EwJf/ILO-Components-Library?type=design&node-id=34%3A1554&mode=design&t=mMJCQdfOgEz1AsYP-1"
37
+ target="true"
38
+ rel="noopener noreferrer"
39
+ style={{ margin: "1rem 20px 0 0" }}
40
+ >
41
+ <span class="link__label">Figma</span>
33
42
  </a>
34
43
  <a
35
44
  class="ilo--button ilo--button--large ilo--button--tertiary optionalclass"
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.1",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Twig components for the ILO's Design System",
6
6
  "main": "",
@@ -21,11 +21,12 @@
21
21
  "components"
22
22
  ],
23
23
  "dependencies": {
24
+ "@popperjs/core": "^2.11.8",
24
25
  "video.js": "^7.21.2",
25
26
  "@ilo-org/brand-assets": "0.2.0",
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/fonts": "0.1.2",
29
+ "@ilo-org/styles": "0.13.0",
29
30
  "@ilo-org/themes": "0.7.0",
30
31
  "@ilo-org/utils": "0.0.11"
31
32
  },
@@ -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",
@@ -76,8 +77,8 @@
76
77
  "webpack": "^4.46.0",
77
78
  "yaml-loader": "0.6.0",
78
79
  "yo": "^3.1.1",
79
- "@ilo-org/eslint-config": "0.1.0",
80
- "@ilo-org/prettier-config": "0.0.2"
80
+ "@ilo-org/prettier-config": "0.0.2",
81
+ "@ilo-org/eslint-config": "0.1.0"
81
82
  },
82
83
  "scripts": {
83
84
  "storybook": "node importprefix.js && node importsvgs.js && start-storybook --config-dir apps/storybook",
@@ -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
  }
@@ -3,12 +3,12 @@
3
3
  {% set icontheme = icontheme|default("light") %}
4
4
  {% set theme = theme|default("dark") %}
5
5
 
6
- <div class="{{prefix}}--tooltip--wrapper {% if icon %} {{prefix}}--tooltip--wrapper__icon {{prefix}}--tooltip--wrapper__icon__theme__{{icontheme}} {% endif %}" role="status" aria-live="polite" aria-relevant="additions" data-loadcomponent="Tooltip" data-prefix="{{prefix}}">
6
+ <div class="{{prefix}}--tooltip--wrapper {% if icon and icon != "false" %} {{prefix}}--tooltip--wrapper__icon {{prefix}}--tooltip--wrapper__icon__theme__{{icontheme}} {% endif %}" role="status" aria-live="polite" aria-relevant="additions" data-loadcomponent="Tooltip" data-prefix="{{prefix}}">
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>