@openeuropa/bcl-badge 0.28.1 → 1.0.2

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.
Files changed (2) hide show
  1. package/badge.html.twig +29 -28
  2. package/package.json +5 -2
package/badge.html.twig CHANGED
@@ -4,7 +4,7 @@
4
4
  - label (string) (default: '')
5
5
  - background: (string) (default: 'primary')
6
6
  - url (string) (default: '')
7
- - title (string) (default: label)
7
+ - title (string) (default: '')
8
8
  - dismissible (boolean) (default: false)
9
9
  - assistive_text (string) (default: '')
10
10
  - rounded_pill (boolean) (default: false)
@@ -16,13 +16,12 @@
16
16
  {% set _label = label|default('') %}
17
17
  {% set _background = background|default('primary') %}
18
18
  {% set _url = url|default('') %}
19
- {% set _title = title|default(_label) %}
20
- {% set _dismissible = dismissible|default(false) %}
19
+ {% set _title = title|default('') %}
20
+ {% set _dismissible = dismissible ?? false %}
21
21
  {% set _assistive_text = assistive_text|default('') %}
22
22
  {% set _rounded_pill = rounded_pill|default(false) %}
23
23
  {% set _outline = outline|default(false) %}
24
24
  {% set _icon_path = icon_path|default('') %}
25
-
26
25
  {% set _classes = ['badge'] %}
27
26
 
28
27
  {% if _rounded_pill %}
@@ -30,47 +29,49 @@
30
29
  {% endif %}
31
30
 
32
31
  {% if _outline %}
33
- {% set _classes = _classes|merge([ 'badge-outline-' ~ _background]) %}
32
+ {% set _classes = _classes|merge(['badge-outline-' ~ _background]) %}
34
33
  {% else %}
35
- {% set _classes = _classes|merge([ 'bg-' ~ _background]) %}
34
+ {% set _classes = _classes|merge(['bg-' ~ _background]) %}
36
35
  {% endif %}
37
36
 
38
37
  {% if attributes is empty %}
39
38
  {% set attributes = create_attribute() %}
40
39
  {% endif %}
41
40
 
42
- {%- if _url is not empty -%}
43
- {% set attributes = attributes.setAttribute('title', _title).setAttribute('href', _url) %}
41
+ {%- if _title is not empty -%}
42
+ {% set attributes = attributes.setAttribute('title', _title) %}
44
43
  {%- endif -%}
45
44
 
46
45
  {% set attributes = attributes.addClass(_classes) %}
47
46
 
48
- {%- if _url is not empty -%}
49
- <a
50
- {{ attributes }}
51
- >
52
- {%- else -%}
53
- <span
54
- {{ attributes }}
55
- >
56
- {%- endif -%}
47
+ {% set _label %}
57
48
  {%- if _assistive_text is not empty -%}
58
- <span class="visually-hidden">
59
- {{- _assistive_text -}}
60
- </span>
49
+ <span class="visually-hidden">
50
+ {{- _assistive_text -}}
51
+ </span>
61
52
  {%- endif -%}
62
- {{- _label -}}
53
+ {{- _label -}}
63
54
  {%- if _dismissible -%}
64
- <span class="icon--close" aria-hidden="true">
65
- {% include '@oe-bcl/bcl-icon/icon.html.twig' with {
66
- name: "x-lg",
67
- path: _icon_path,
68
- } only %}
69
- </span>
55
+ <span class="icon--close" aria-hidden="true">
56
+ {% include '@oe-bcl/bcl-icon/icon.html.twig' with {
57
+ name: "x-lg",
58
+ path: _icon_path,
59
+ } only %}
60
+ </span>
70
61
  {%- endif -%}
62
+ {% endset %}
63
+
71
64
  {%- if _url is not empty -%}
72
- </a>
65
+ {% include '@oe-bcl/bcl-link/link.html.twig' with {
66
+ label: _label,
67
+ path: _url,
68
+ attributes: attributes,
69
+ } only %}
73
70
  {%- else -%}
71
+ <span
72
+ {{ attributes }}
73
+ >
74
+ {{- _label -}}
74
75
  </span>
75
76
  {%- endif -%}
76
77
 
package/package.json CHANGED
@@ -2,10 +2,13 @@
2
2
  "name": "@openeuropa/bcl-badge",
3
3
  "author": "European Commission",
4
4
  "license": "EUPL-1.2",
5
- "version": "0.28.1",
5
+ "version": "1.0.2",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
9
+ "dependencies": {
10
+ "@openeuropa/bcl-link": "^1.0.2"
11
+ },
9
12
  "description": "OE - BCL badge",
10
13
  "repository": {
11
14
  "type": "git",
@@ -21,5 +24,5 @@
21
24
  "design-system",
22
25
  "twig"
23
26
  ],
24
- "gitHead": "3b0d2f4a85c727f38ae4e3403110c98302d09117"
27
+ "gitHead": "54df3dccb26d9f6958862f06103766a0a2d78ca6"
25
28
  }