@rijkshuisstijl-community/components-twig 1.0.0 → 1.1.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/dist/Heading.twig +1 -5
- package/dist/Icon.twig +2 -3
- package/dist/OrderedList.twig +1 -1
- package/package.json +5 -2
- package/dist/utils/attributes.twig +0 -69
package/dist/Heading.twig
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
{% from "attributes.twig" import parse_attributes %}
|
|
2
|
-
{%- set attributes = attributes|default({'class': []})|merge({
|
|
3
|
-
'class': attributes.class|default([]),
|
|
4
|
-
}) -%}
|
|
5
1
|
{%- if appearance is not empty -%}
|
|
6
2
|
{% set attributes = attributes|merge({'appearance': appearance}) %}
|
|
7
3
|
{%- endif -%}
|
|
8
4
|
{%- if level is empty -%}
|
|
9
5
|
{% set level = 1 %}
|
|
10
6
|
{%- endif -%}
|
|
11
|
-
<h{{ level }}{{
|
|
7
|
+
<h{{ level }}{{ attributes }}>{{ children }}</h{{ level }}>
|
package/dist/Icon.twig
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
{% from "attributes.twig" import parse_attributes %}
|
|
2
1
|
{%- set attributes = attributes|default({'class': []})|merge({
|
|
3
2
|
'class': attributes.class|default(['utrecht-icon']),
|
|
4
3
|
'role': 'presentation',
|
|
@@ -17,8 +16,8 @@
|
|
|
17
16
|
'stroke-linejoin': 'round'
|
|
18
17
|
})
|
|
19
18
|
-%}
|
|
20
|
-
<span{{
|
|
21
|
-
<svg{{
|
|
19
|
+
<span{{ attributes }}>
|
|
20
|
+
<svg{{ svg_attributes }}>
|
|
22
21
|
<use xlink:href="node_modules/@tabler/icons-sprite/dist/tabler-sprite.svg#tabler-{{ icon }}" />
|
|
23
22
|
</svg>
|
|
24
23
|
</span>
|
package/dist/OrderedList.twig
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!-- TODO: This is a dummy component created to setup support for nested Twig templates. It needs to be replaced with an official template -->
|
|
2
2
|
<ol>
|
|
3
3
|
{% for item in items %}
|
|
4
|
-
{% include 'OrderedListItem.twig' with {
|
|
4
|
+
{% include '@rhc/OrderedListItem.twig' with {
|
|
5
5
|
content: item
|
|
6
6
|
} %}
|
|
7
7
|
{% endfor %}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rijkshuisstijl-community/components-twig",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"author": "Community for NL Design System",
|
|
5
5
|
"description": "Twig component library for the Rijkshuisstijl Community repository, based on the NL Design System architecture",
|
|
6
6
|
"license": "EUPL-1.2",
|
|
@@ -23,13 +23,16 @@
|
|
|
23
23
|
],
|
|
24
24
|
"sideEffects": false,
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@rijkshuisstijl-community/components-css": "1.0.
|
|
26
|
+
"@rijkshuisstijl-community/components-css": "1.0.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@nl-design-system/tsconfig": "1.0.1",
|
|
30
30
|
"cpx": "1.5.0",
|
|
31
|
+
"drupal-attribute": "1.1.0",
|
|
32
|
+
"drupal-twig-extensions": "1.0.0-beta.5",
|
|
31
33
|
"npm-run-all": "4.1.5",
|
|
32
34
|
"rimraf": "6.0.1",
|
|
35
|
+
"twig": "1.17.1",
|
|
33
36
|
"typescript": "5.7.3"
|
|
34
37
|
},
|
|
35
38
|
"scripts": {
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
{#
|
|
2
|
-
A custom attributes function.
|
|
3
|
-
|
|
4
|
-
By default it will return an empty string, but if any attributes are available
|
|
5
|
-
they will be used to create the string with attributes.
|
|
6
|
-
|
|
7
|
-
Why do we need this function? Because we want the Twig templates in our
|
|
8
|
-
components to be as clean and Twig-native as possible without dependencies on
|
|
9
|
-
methods like those provided by drupal on the Attributes object. See:
|
|
10
|
-
https://www.drupal.org/docs/8/theming-drupal-8/using-attributes-in-templates#s-attributesmethods
|
|
11
|
-
|
|
12
|
-
Parameters:
|
|
13
|
-
- attributes
|
|
14
|
-
An arrray with attributes as provided by Drupal.
|
|
15
|
-
|
|
16
|
-
Returns:
|
|
17
|
-
- A string with attributes and their values.
|
|
18
|
-
#}
|
|
19
|
-
{%- macro parse_attributes(attributes) -%}
|
|
20
|
-
{%- set str = '' -%}
|
|
21
|
-
{%- set boolean_attributes = [
|
|
22
|
-
'allowfullscreen',
|
|
23
|
-
'allowpaymentrequest',
|
|
24
|
-
'async',
|
|
25
|
-
'autofocus',
|
|
26
|
-
'autoplay',
|
|
27
|
-
'checked',
|
|
28
|
-
'controls',
|
|
29
|
-
'default',
|
|
30
|
-
'disabled',
|
|
31
|
-
'formnovalidate',
|
|
32
|
-
'hidden',
|
|
33
|
-
'ismap',
|
|
34
|
-
'itemscope',
|
|
35
|
-
'loop',
|
|
36
|
-
'multiple',
|
|
37
|
-
'muted',
|
|
38
|
-
'nomodule',
|
|
39
|
-
'novalidate',
|
|
40
|
-
'open',
|
|
41
|
-
'playsinline',
|
|
42
|
-
'readonly',
|
|
43
|
-
'required',
|
|
44
|
-
'reversed',
|
|
45
|
-
'selected',
|
|
46
|
-
'truespeed'
|
|
47
|
-
] -%}
|
|
48
|
-
{# Attributes is optional, so check if it exists. #}
|
|
49
|
-
{%- for key, value in attributes -%}
|
|
50
|
-
{%- if value is iterable -%}
|
|
51
|
-
{%- set unique = [] -%}
|
|
52
|
-
{%- for item in value -%}
|
|
53
|
-
{%- if item not in unique -%}
|
|
54
|
-
{%- set unique = unique|merge([item|trim]) -%}
|
|
55
|
-
{%- endif -%}
|
|
56
|
-
{%- endfor -%}
|
|
57
|
-
{%- set joined = unique|join(' ') -%}
|
|
58
|
-
{%- if joined != '' -%}
|
|
59
|
-
{%- set str = str ~ ' ' ~ key ~ '="' ~ (joined|trim) ~ '"' -%}
|
|
60
|
-
{%- endif -%}
|
|
61
|
-
{%- elseif key in boolean_attributes -%}
|
|
62
|
-
{%- set str = str ~ ' ' ~ key -%}
|
|
63
|
-
{% else %}
|
|
64
|
-
{%- set str = str ~ ' ' ~ key ~ '="' ~ value ~ '"' -%}
|
|
65
|
-
{%- endif -%}
|
|
66
|
-
{%- endfor -%}
|
|
67
|
-
{#- Render the string raw (otherwise quotes will be escaped. -#}
|
|
68
|
-
{{- str|raw -}}
|
|
69
|
-
{%- endmacro -%}
|