|
25 | 25 | {% set border_radius = "full" %}
|
26 | 26 | {% endif %}
|
27 | 27 |
|
| 28 | +{# DEPRECATED. Use the `type` property for a reset or submit button. Tag is determined automatically based on whether you pass a url. #} |
| 29 | +{% if tag in ["reset", "submit"] %} |
| 30 | + {% set type = type|default(tag) %} |
| 31 | +{% endif %} |
| 32 | + |
28 | 33 | {# Set up checks to validate that the component's prop values are allowed, based on the component's schema #}
|
29 | 34 | {% set size_options = schema.properties.size.enum %}
|
30 | 35 | {% set style_options = schema.properties.style.enum %}
|
31 | 36 | {% set width_options = schema.properties.width.enum %}
|
32 | 37 | {% set border_radius_options = schema.properties.border_radius.enum %}
|
33 | 38 | {% set align_options = schema.properties.align.enum %}
|
34 | 39 | {% set transform_options = schema.properties.transform.enum %}
|
35 |
| -{% set tag_options = schema.properties.tag.enum %} |
36 | 40 | {% set icon_positions = schema.properties.icon.properties.position.enum %}
|
37 | 41 | {% set iconOnly_options = schema.properties.iconOnly.enum %}
|
38 | 42 |
|
|
43 | 47 | {% set border_radius = border_radius in border_radius_options ? border_radius : schema.properties.border_radius.default %}
|
44 | 48 | {% set align = align in align_options ? align : schema.properties.align.default %}
|
45 | 49 | {% set transform = transform in transform_options ? transform : schema.properties.transform.default %}
|
46 |
| -{% set tag = tag in tag_options ? tag : schema.properties.tag.default %} |
47 | 50 | {% set iconOnly = iconOnly is sameas(true) or iconOnly is sameas(false) ? iconOnly : scheuma.properties.iconOnly.default %}
|
48 | 51 |
|
49 |
| -{% if tag == "submit" or type == "submit" %} |
50 |
| - {% set tag = "button" %} |
51 |
| - {% set inner_attributes = inner_attributes.setAttribute("type", "submit") %} |
52 |
| -{% elseif tag == "link" or tag == "a" or url != null %} |
| 52 | +{% if url != null %} |
53 | 53 | {% set tag = "a" %}
|
54 | 54 | {% if disabled %}
|
55 | 55 | {% set inner_attributes = inner_attributes.setAttribute("aria-disabled", "true") %}
|
|
61 | 61 | {% if attributes.target %}
|
62 | 62 | {% set inner_attributes = inner_attributes.setAttribute("target", attributes.target) %}
|
63 | 63 | {% endif %}
|
64 |
| -{% elseif tag == "reset" or type == "reset" %} |
| 64 | +{% else %} |
65 | 65 | {% set tag = "button" %}
|
66 |
| - {% set inner_attributes = inner_attributes.setAttribute("type", "reset") %} |
67 |
| -{% endif %} |
68 |
| - |
69 |
| -{# shorthand for manually setting HTML attribute `type` such as submit or reset #} |
70 |
| -{% if type %} |
71 |
| - {% set inner_attributes = inner_attributes.setAttribute("type", type) %} |
| 66 | + {% set type = type in type_options ? type : "button" %} |
| 67 | + {% set inner_attributes = inner_attributes.setAttribute("type", type ) %} |
72 | 68 | {% endif %}
|
73 | 69 |
|
74 | 70 | {# Array of classes based on the defined + default props #}
|
|
0 commit comments