@openeuropa/bcl-alert 0.1.2 → 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 +55 -16
  2. package/package.json +2 -2
package/alert.html.twig CHANGED
@@ -1,36 +1,75 @@
1
- {% spaceless %}
1
+ {% apply spaceless %}
2
2
 
3
3
  {# Parameters:
4
4
  - message (string) (default: '')
5
5
  - heading (string) (default: '')
6
6
  - variant (string) (default: 'primary')
7
- - disimissible (boolean) (default: true)
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 _dismiss_class = '' %}
17
- {% set _class = 'alert alert-' ~ _variant %}
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
+ %}
18
34
 
19
35
  {% if _dismissible %}
20
- {% set _class = _class ~ ' alert-dismissible' %}
36
+ {% set _classes = _classes|merge(['alert-dismissible']) %}
21
37
  {% endif %}
22
38
  {% if _animated_dismiss %}
23
- {% set _class = _class ~ ' fade show' %}
39
+ {% set _classes = _classes|merge(['fade', 'show']) %}
24
40
  {% endif %}
25
41
 
26
- <div
27
- class="{{ _class }}"
28
- role="alert"
29
- >
30
- {%- if _heading is not empty -%}
31
- <h4 class="alert-heading">{{ _heading }}</h4>
32
- {%- endif -%}
33
- {{- message -}}
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
+
54
+ {% set attributes = attributes.addClass(_classes).setAttribute('role', 'alert') %}
55
+
56
+ <div {{ attributes }}>
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>
34
73
  {%- if _dismissible -%}
35
74
  <button
36
75
  type="button"
@@ -41,4 +80,4 @@
41
80
  {%- endif -%}
42
81
  </div>
43
82
 
44
- {% 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.2",
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": "b242dcb5ed9578fcd212c98cf722eabc845d313b"
24
+ "gitHead": "7ee2013f7f64a70ddfa35228a9a65967dd71eec3"
25
25
  }