@ilo-org/twig 1.8.6 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +101 -0
- package/dist/components/card_detail/card_detail.twig +8 -1
- package/dist/components/dropdown/dropdown.twig +3 -3
- package/dist/components/icon/icon.behavior.js +835 -610
- package/dist/components/icon/icon.twig +1 -1
- package/dist/components/image/image.component.yml +7 -0
- package/dist/components/image/image.twig +18 -6
- package/dist/components/image/image.wingsuit.yml +7 -0
- package/dist/components/linklist/linklist.component.yml +11 -0
- package/dist/components/linklist/linklist.twig +3 -1
- package/dist/components/linklist/linklist.wingsuit.yml +11 -0
- package/dist/components/list/list.component.yml +11 -0
- package/dist/components/list/list.twig +2 -1
- package/dist/components/list/list.wingsuit.yml +11 -0
- package/dist/components/nav/desktop/navmenu.twig +2 -3
- package/dist/components/nav/desktop/navsearch.twig +24 -0
- package/dist/components/nav/mobile/mobiledrawer_main.twig +27 -8
- package/dist/components/nav/nav.behavior.js +1 -1
- package/dist/components/nav/nav.component.yml +63 -4
- package/dist/components/nav/nav.twig +3 -1
- package/dist/components/nav/nav.wingsuit.yml +63 -4
- package/dist/components/nav/nav_compact.twig +2 -1
- package/dist/components/nav/nav_complex.twig +2 -2
- package/dist/components/nav/nav_main.twig +135 -0
- package/dist/components/socialmedia/socialmedia.component.yml +20 -0
- package/dist/components/socialmedia/socialmedia.twig +3 -1
- package/dist/components/socialmedia/socialmedia.wingsuit.yml +20 -0
- package/dist/components/tableofcontents/tableofcontents.twig +12 -12
- package/dist/components/video/video.twig +1 -1
- package/dist/styles/components/accordion.css +1 -1
- package/dist/styles/components/blockquote.css +1 -1
- package/dist/styles/components/breadcrumb.css +1 -1
- package/dist/styles/components/button.css +1 -1
- package/dist/styles/components/callout.css +1 -1
- package/dist/styles/components/card.css +1 -1
- package/dist/styles/components/cardgroup.css +1 -1
- package/dist/styles/components/checkbox.css +1 -1
- package/dist/styles/components/container.css +1 -1
- package/dist/styles/components/contextmenu.css +1 -1
- package/dist/styles/components/datacard.css +1 -1
- package/dist/styles/components/datepicker.css +1 -1
- package/dist/styles/components/detailcard.css +1 -1
- package/dist/styles/components/dropdown.css +1 -1
- package/dist/styles/components/empty.css +1 -1
- package/dist/styles/components/factlistcard.css +1 -1
- package/dist/styles/components/featurecard.css +1 -1
- package/dist/styles/components/fieldset.css +1 -1
- package/dist/styles/components/file-upload.css +1 -1
- package/dist/styles/components/footer.css +1 -1
- package/dist/styles/components/form.css +1 -1
- package/dist/styles/components/formcontrol.css +1 -1
- package/dist/styles/components/hero.css +1 -1
- package/dist/styles/components/herocard.css +1 -1
- package/dist/styles/components/image.css +1 -1
- package/dist/styles/components/input.css +1 -1
- package/dist/styles/components/languagetoggle.css +1 -1
- package/dist/styles/components/link.css +1 -1
- package/dist/styles/components/linklist.css +1 -1
- package/dist/styles/components/list.css +1 -1
- package/dist/styles/components/loading.css +1 -1
- package/dist/styles/components/logogrid.css +1 -1
- package/dist/styles/components/modal.css +1 -1
- package/dist/styles/components/multilinkcard.css +1 -1
- package/dist/styles/components/navigation.css +1 -1
- package/dist/styles/components/notification.css +1 -1
- package/dist/styles/components/pagination.css +1 -1
- package/dist/styles/components/profile.css +1 -1
- package/dist/styles/components/promocard.css +1 -1
- package/dist/styles/components/radio.css +1 -1
- package/dist/styles/components/readmore.css +1 -1
- package/dist/styles/components/richtext.css +1 -1
- package/dist/styles/components/scorecard.css +1 -1
- package/dist/styles/components/searchfield.css +1 -1
- package/dist/styles/components/socialmedia.css +1 -1
- package/dist/styles/components/statcard.css +1 -1
- package/dist/styles/components/status.css +1 -1
- package/dist/styles/components/table.css +1 -1
- package/dist/styles/components/tableofcontents.css +1 -1
- package/dist/styles/components/tabs.css +1 -1
- package/dist/styles/components/tag.css +1 -1
- package/dist/styles/components/textarea.css +1 -1
- package/dist/styles/components/textcard.css +1 -1
- package/dist/styles/components/textinput.css +1 -1
- package/dist/styles/components/toggle.css +1 -1
- package/dist/styles/components/tooltip.css +1 -1
- package/dist/styles/components/video.css +1 -1
- package/dist/styles/global.css +1 -1
- package/dist/styles/global.css.map +1 -1
- package/dist/styles/index.css +4 -2
- package/dist/styles/index.css.map +1 -1
- package/dist/styles/monorepo.css +4 -2
- package/dist/styles/monorepo.css.map +1 -1
- package/package.json +16 -17
- package/dist/styles/components/credit.css +0 -1
- package/dist/styles/components/heading.css +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# ILO Design System - Twig Package
|
|
2
|
+
|
|
3
|
+
This package provides the implementation of the Design System using [Twig](https://twig.symfony.com/). It also includes a [Storybook](https://storybook.js.org/) project for documentation and development of the components in the system. Storybook and twig integration is done by the internal [Maestro](https://github.com/international-labour-organization/designsystem/tree/develop/packages/maestro). It has dependencies on the following other @ilo-org packages:
|
|
4
|
+
|
|
5
|
+
- [@ilo-org/themes](./packages/themes)
|
|
6
|
+
- [@ilo-org/fonts](./packages/fonts)
|
|
7
|
+
- [@ilo-org/styles](./packages/styles)
|
|
8
|
+
- [@ilo-org/utils](./packages/utils)
|
|
9
|
+
- [@ilo-org/icons](./packages/icons)
|
|
10
|
+
|
|
11
|
+
## Drupal Integration
|
|
12
|
+
|
|
13
|
+
- For the Drupal integration, please refer to the [Main Documentation](https://twig.ui.ilo.org/?path=/docs/get-started-use-with-drupal--docs)
|
|
14
|
+
- [Drupal Base Theme](https://github.com/international-labour-organization/ilo_base_theme)
|
|
15
|
+
|
|
16
|
+
## Available Commands
|
|
17
|
+
|
|
18
|
+
### Prerequisites
|
|
19
|
+
|
|
20
|
+
- Node.js version 20 or higher
|
|
21
|
+
- You can use [nvm](https://github.com/nvm-sh/nvm) to manage your Node.js versions
|
|
22
|
+
- [pnpm](https://pnpm.io/) installed globally or via corepack >= 9.14.0
|
|
23
|
+
|
|
24
|
+
### Getting Started
|
|
25
|
+
|
|
26
|
+
Before running any of the commands below, make sure to:
|
|
27
|
+
|
|
28
|
+
1. Run `pnpm install` from the monorepo root to install all dependencies
|
|
29
|
+
2. Run `pnpm build:libs` from the monorepo root to build all necessary packages
|
|
30
|
+
|
|
31
|
+
| Command | Description |
|
|
32
|
+
| ------------------ | ------------------------------------------------------------ |
|
|
33
|
+
| `pnpm build:lib` | Builds the library |
|
|
34
|
+
| `pnpm build:docs` | Generates static Storybook documentation |
|
|
35
|
+
| `pnpm storybook` | Starts Storybook development server on port 6006 |
|
|
36
|
+
| `pnpm start:theme` | Starts Docker containers in detached mode(Used in tests) |
|
|
37
|
+
| `pnpm cr:theme` | Rebuilds Drupal cache inside Docker container(Used in tests) |
|
|
38
|
+
| `pnpm cy:open` | Opens Cypress test runner(Used in tests) |
|
|
39
|
+
| `pnpm test` | Runs Cypress tests in headless mode(Used in tests) |
|
|
40
|
+
| `pnpm lint` | Runs ESLint to check code quality |
|
|
41
|
+
| `pnpm lint:fix` | Runs ESLint with automatic fixes |
|
|
42
|
+
|
|
43
|
+
## Development
|
|
44
|
+
|
|
45
|
+
Each component is located in the `src/components` folder. Each component has its own folder named after the component. Inside each component folder, you will find:
|
|
46
|
+
|
|
47
|
+
- `[component].twig`: The Twig template file for the component. (Required)
|
|
48
|
+
- `[component].component.yml`: [UI Patterns](https://www.drupal.org/project/ui_patterns) definition for the component. This file will be used for the story generation too. (Required)
|
|
49
|
+
- `[component].js`: The JavaScript file for the component. (Optional)
|
|
50
|
+
- `[component].behavior.js`: The Drupal behavior runner for attaching the JS bundle to the component. (Optional)
|
|
51
|
+
- Sub components can be also created inside the component folder (Check the [`accordion`](./src/components/accordion) component for reference)
|
|
52
|
+
|
|
53
|
+
The storybook is a source of truth for the components. Each component will have its own stories file located in the `stories/[component].stories.js` file. The stories are generated from the UI Patterns definition file using the [Maestro](../maestro/README.md).
|
|
54
|
+
|
|
55
|
+
Here is an example of a story file for the `button` component:
|
|
56
|
+
|
|
57
|
+
```js
|
|
58
|
+
import Button from "../src/components/button/button.twig"; // Twig template
|
|
59
|
+
import ButtonPatterns from "../src/components/button/button.component.yml"; // UI Patterns definition
|
|
60
|
+
import { Maestro } from "@ilo-org/maestro";
|
|
61
|
+
|
|
62
|
+
const story = Maestro.create(Button, ButtonPatterns); // Generates a meta and stories from the UI Patterns definition
|
|
63
|
+
|
|
64
|
+
const Meta = {
|
|
65
|
+
title: "Components/User Interface/Button",
|
|
66
|
+
tags: ["autodocs"],
|
|
67
|
+
...story.meta,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const [Default] = story.stories; // Extracts the generated story
|
|
71
|
+
|
|
72
|
+
export default Meta;
|
|
73
|
+
|
|
74
|
+
export { Default };
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
For more details about the Maestro check the [Maestro documentation](../maestro/README.md).
|
|
78
|
+
|
|
79
|
+
## Testing
|
|
80
|
+
|
|
81
|
+
We are using Cypress for component testing. To achieve this, we have a Drupal instance running inside a Docker container. The Drupal instance has the [ILO Base Theme](https://github.com/international-labour-organization/ilo_base_theme) installed and configured. The components are rendered using the Base Theme and then tested using Cypress.
|
|
82
|
+
|
|
83
|
+
You can start the Docker containers using the following command:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pnpm run start:theme
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
After that you can check the `localhost:8082` to see the Drupal instance running.
|
|
90
|
+
|
|
91
|
+
To open the Cypress test runner, you can use the following command:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
pnpm run cy:open
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
You can find the tests in the `cypress/e2e` folder. Each component will have its own test file named after the component.
|
|
98
|
+
|
|
99
|
+
## Contributing
|
|
100
|
+
|
|
101
|
+
For contribution guidelines, please refer to the [Main Documentation](../contributing.md).
|
|
@@ -35,7 +35,14 @@
|
|
|
35
35
|
{% include "@components/icon/icon.twig" with {
|
|
36
36
|
name: "triangle_right",
|
|
37
37
|
size: 20,
|
|
38
|
-
color: iconColor
|
|
38
|
+
color: iconColor,
|
|
39
|
+
class: 'ilo' ~ "--card--icon-right"
|
|
40
|
+
} %}
|
|
41
|
+
{% include "@components/icon/icon.twig" with {
|
|
42
|
+
name: "triangle_left",
|
|
43
|
+
size: 20,
|
|
44
|
+
color: iconColor,
|
|
45
|
+
class: 'ilo' ~ "--card--icon-left"
|
|
39
46
|
} %}
|
|
40
47
|
{{dateExtra}}
|
|
41
48
|
</p>
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
{% extends "@components/form/formcontrol.twig" %}
|
|
4
4
|
|
|
5
5
|
{% set disabled = disabled|default(false) %}
|
|
6
|
-
{% set
|
|
7
|
-
{% set dropdownClasses = [
|
|
6
|
+
{% set dropdownClass = 'ilo' ~ '--dropdown' %}
|
|
7
|
+
{% set dropdownClasses = [dropdownClass, class] %}
|
|
8
8
|
{% if error %}
|
|
9
9
|
{% set dropdownClasses = dropdownClasses|merge(['error']) %}
|
|
10
10
|
{% endif %}
|
|
11
11
|
|
|
12
12
|
{% block formfield %}
|
|
13
|
-
<div class="{{
|
|
13
|
+
<div class="{{ dropdownClass }}--wrapper" {% if style %} style="{{ style }}" {% endif %}>
|
|
14
14
|
<select id="{{ id|default(name) }}" autocomplete="{{ autocomplete|default('off') }}" name="{{ name }}" {% if required %} required {% endif %} {% if onBlur %} onblur="{{ onBlur }}" {% endif %} {% if disabled %} disabled {% endif %} class="{{ dropdownClasses|join(' ') }}" value="{{ currentvalue|default(value) }}" {% if form %} form="{{ form }}" {% endif %} {% if multiple %} multiple {% endif %} {% if selectSize %} size="{{ selectSize }}" {% endif %} {% if ariaDescribedBy %} aria-describedby="{{ ariaDescribedBy }}" {% endif %}>
|
|
15
15
|
{% for option in options %}
|
|
16
16
|
<option {% if option.disabled %} disabled {% endif %} value="{{ option.value }}" {% if defaultOption and defaultOption == option.value %} selected {% endif %}>
|