@openeuropa/bcl-alert 0.1.3 → 0.1.202408021145

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/alert.html.twig +49 -8
  2. package/package.json +2 -2
package/alert.html.twig CHANGED
@@ -1,4 +1,4 @@
1
- {% spaceless %}
1
+ {% apply spaceless %}
2
2
 
3
3
  {# Parameters:
4
4
  - message (string) (default: '')
@@ -6,14 +6,31 @@
6
6
  - variant (string) (default: 'primary')
7
7
  - dismissible (boolean) (default: true)
8
8
  - animated_dismiss (boolean) (default: true)
9
+ - icon_path (string) (default: '')
10
+ - icon_name (string) (default: '')
11
+ - attributes (drupal attrs)
9
12
  #}
10
13
 
11
14
  {% set _message = message|default('') %}
12
- {% set _variant = variant|default('primary') %}
13
15
  {% set _heading = heading|default('') %}
16
+ {% set _variant = variant|default('primary') %}
14
17
  {% set _dismissible = dismissible ?? true %}
15
18
  {% set _animated_dismiss = animated_dismiss ?? true %}
16
- {% set _classes = ['alert', 'alert-' ~ _variant|e('html_attr')] %}
19
+ {% set _icon_path = icon_path|default('') %}
20
+ {% set _icon_name = icon_name|default('') %}
21
+
22
+ {% set _classes = ['alert', 'alert-' ~ _variant|e('html_attr'), 'd-flex', 'align-items-center'] %}
23
+ {% set _icon_names = {
24
+ primary: "info-circle-fill",
25
+ secondary: "info-circle-fill",
26
+ success: "check-circle-fill",
27
+ danger: "dash-circle-fill",
28
+ warning: "exclamation-triangle-fill",
29
+ light: "info-circle-fill",
30
+ info: "info-circle-fill",
31
+ dark: "info-circle-fill",
32
+ }
33
+ %}
17
34
 
18
35
  {% if _dismissible %}
19
36
  {% set _classes = _classes|merge(['alert-dismissible']) %}
@@ -22,13 +39,37 @@
22
39
  {% set _classes = _classes|merge(['fade', 'show']) %}
23
40
  {% endif %}
24
41
 
42
+ {% set _classes = _classes|merge(['text-dark']) %}
43
+
44
+ {% set _icon_classes = ['flex-shrink-0 me-3 mt-1 align-self-start' ] %}
45
+
46
+ {% if _variant != 'light' %}
47
+ {% set _icon_classes = _icon_classes|merge(['text-' ~ _variant]) %}
48
+ {% endif %}
49
+
50
+ {% if attributes is empty %}
51
+ {% set attributes = create_attribute() %}
52
+ {% endif %}
53
+
25
54
  {% set attributes = attributes.addClass(_classes).setAttribute('role', 'alert') %}
26
55
 
27
56
  <div {{ attributes }}>
28
- {%- if _heading is not empty -%}
29
- <h4 class="alert-heading">{{ _heading }}</h4>
30
- {%- endif -%}
31
- {{- message -}}
57
+ {% if _icon_path is not empty %}
58
+ {% include '@oe-bcl/bcl-icon/icon.html.twig' with {
59
+ name: _icon_name ?: _icon_names[_variant],
60
+ size: 's',
61
+ path: _icon_path,
62
+ attributes: create_attribute().addClass(_icon_classes),
63
+ } only %}
64
+ {% endif %}
65
+ <div class="alert-content flex-grow-1">
66
+ {%- if _heading is not empty -%}
67
+ <div class="alert-heading h4">{{ _heading }}</div>
68
+ {%- endif -%}
69
+ {%- if _message is not empty -%}
70
+ {{- _message -}}
71
+ {%- endif -%}
72
+ </div>
32
73
  {%- if _dismissible -%}
33
74
  <button
34
75
  type="button"
@@ -39,4 +80,4 @@
39
80
  {%- endif -%}
40
81
  </div>
41
82
 
42
- {% endspaceless %}
83
+ {% endapply %}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@openeuropa/bcl-alert",
3
3
  "author": "European Commission",
4
4
  "license": "EUPL-1.2",
5
- "version": "0.1.3",
5
+ "version": "0.1.202408021145",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
@@ -21,5 +21,5 @@
21
21
  "design-system",
22
22
  "twig"
23
23
  ],
24
- "gitHead": "ab1587b9ba4971ea0ca72c3de6b632f2c314c200"
24
+ "gitHead": "7ee2013f7f64a70ddfa35228a9a65967dd71eec3"
25
25
  }