@robert.tools/molecule-button-link 1.0.0 → 1.0.1

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/package.json +1 -1
  2. package/src/index.njk +14 -29
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robert.tools/molecule-button-link",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "A Component to provide a wrapper between button and link.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
package/src/index.njk CHANGED
@@ -1,30 +1,23 @@
1
1
  {% set dimension = [params.width, params.height] if params.width and params.height else params.size %}
2
2
  {% set class_svg = params.class_svg | safeParam() %}
3
3
  {% set class_modifier = params.class_modifier | safeParam() %}
4
+
4
5
  {% set pre_html = (params.image_before | replace("./assets/", "") | svg(dimension, class_svg, attributes) | safe) if params.image_before is defined else "" %}
5
6
  {% set post_html = (params.image_after | replace("./assets/", "") | svg(dimension, class_svg, attributes) | safe) if params.image_after is defined else "" %}
6
7
 
7
8
  {% set type = params.type | safeParam(params.type_button) %}
8
9
  {% set text = params.text | safeParam() %}
9
- {% set class_css = params.class | safeParam() %}
10
10
  {% set type_content = params.type_content | safeParam() %}
11
- {# set button type #}
12
- {# {% set class_modifier = "" %} #}
13
- {# {% if type == "link" %}
14
- {% set class_modifier = "btn--ghost" %}
15
- {% endif %}
16
- {% if type == "cta" %}
17
- {% set class_modifier = "btn--cta" %}
18
- {% endif %} #}
19
- {% set component_name = "button" | safeParamIf(type == "button", "link") %}
20
11
 
21
- {% if params.type_content and component_name == "button" %}
12
+ {# set component type #}
13
+ {% set component_name = "atom/button" if type == "button" else "molecule/link" %}
14
+
15
+ {% if params.type_content and type == "button" %}
22
16
  {% set class_modifier = class_modifier + " btn btn-" + type_content %}
23
17
  {% endif %}
24
18
 
25
19
  {# set optional attributes #}
26
20
  {% set attributes = {} %}
27
-
28
21
  {% if params.focusable is defined %}
29
22
  {% set attributes = attributes | merge({"focusable": params.focusable}) %}
30
23
  {% endif %}
@@ -33,20 +26,12 @@
33
26
  {% set attributes = attributes | merge({"ariaHidden": params.aria_hidden}) %}
34
27
  {% endif %}
35
28
 
36
- {{
37
- component(component_name, {
38
- class: class_css,
39
- class_modifier: class_modifier,
40
- url: params.url,
41
- target: params.target,
42
- disabled: params.disabled,
43
- text: text,
44
- collapseID: params.collapseID,
45
- collapseShow: params.collapseShow,
46
- type_content: type_content,
47
- pre_html: pre_html,
48
- post_html: post_html,
49
- attributes: attributes
50
- })
51
- }}
52
-
29
+ {{
30
+ component(component_name, params | merge({
31
+ class_modifier: class_modifier,
32
+ type_content: type_content,
33
+ pre_html: pre_html,
34
+ post_html: post_html,
35
+ attributes: attributes
36
+ }))
37
+ }}