Skip to content

Commit

Permalink
button
Browse files Browse the repository at this point in the history
  • Loading branch information
JayBox325 committed Jan 27, 2021
1 parent f7d7d8e commit 51d4d76
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 910 deletions.
16 changes: 6 additions & 10 deletions _gulp/html/elements/button.njk
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
{% import '_macros/macros.njk' as macro %}

{# Content #}
{% set title = button.title|default("Read more") %}
{% set label = button.label|default("Read more") %}
{% set action = button.action|default(null) %}

{# Options #}
{% set type = button.type|default('link') %}
{% set download = '' %}
{% set target = button.target|default(false) %}
{% set full = button.full|default(false) %}
{% set classes = button.classes|default('bg-orange-500 hover:bg-orange-600 text-white') %}

{# Append the download attribute to the link type #}
{% if type == 'link' or type == 'download' %}
{% set download = true %}
{% if type == 'download' %}
{% set download = 'download' %}
{% set type = 'link' %}
{% endif %}

{# Add the full class if required #}
{% if full %}
{% set classes = classes + ' btn--full' %}
{% endif %}

{% switch type %}
{% case 'button' %}
<button {{ action }} class="btn {{ classes }}">{{ title }}</button>
<button {{ action }} class="btn {{ classes }}">{{ label }}</button>
{% case 'link' %}
<a href="{{ action }}" {{ macro.external(target) }} class="btn {{ classes }}" {% if download %}download{% endif %}>{{ title }}</a>
<a href="{{ action }}" {{ macro.external(target) }} class="btn {{ classes }}" {{ download }}>{{ label }}</a>
{% endswitch %}
Loading

0 comments on commit 51d4d76

Please sign in to comment.