diff --git a/src/backend/views/components/button.twig b/src/backend/views/components/button.twig new file mode 100644 index 0000000..9527399 --- /dev/null +++ b/src/backend/views/components/button.twig @@ -0,0 +1,37 @@ +{# + Reusable button component. + Available props: + - label + - icon + - name + - style: primary, secondary or warning + - size: small, default + - url: URL to navigate in case if button is the navigation link + - class: additional class for the button + + Usage example: + {% include 'components/button.twig' with {label: 'Label', icon: 'check', style: 'secondary', size: 'default'} %} +#} + +{% set mainClass = 'docs-button' %} + + +{% set tag = 'button' %} + +{% if url is not empty %} + {% set tag = 'a' %} +{% endif %} + +<{{tag}} + {{ name is not empty ? 'name="' ~ name ~ '"': '' }} + class="{{ mainClass }} {{ mainClass }}--{{ style|default('primary') }} {{ mainClass }}--{{ size|default('default') }} {{ icon ? mainClass ~ '--with-icon' : '' }} {{ class ?? '' }}" + {{ url is not empty ? 'href="' ~ url ~ '"' : '' }} +> + {% if icon %} +
+ {{ svg(icon) }} +
+ {% endif %} + + {{ label }} + diff --git a/src/backend/views/components/header.twig b/src/backend/views/components/header.twig index 90dc96d..3707906 100644 --- a/src/backend/views/components/header.twig +++ b/src/backend/views/components/header.twig @@ -5,15 +5,12 @@