From f714225e20414b136c919c07ad123b680641a8dd Mon Sep 17 00:00:00 2001 From: Tanya Date: Tue, 24 May 2022 12:49:06 +0800 Subject: [PATCH] Add button component (twig) (#188) * Add button component * Replace old buttons with the new ones * Update icons and border radius * Update add page button * Set size small to add page btn * Update button indentation * Cleanup * icons and button component updated * upd secondary colour, page button call * Update small button padding right Co-authored-by: Peter Savchenko --- src/backend/views/components/button.twig | 37 +++++++++ src/backend/views/components/header.twig | 7 +- src/backend/views/pages/form.twig | 9 ++- src/backend/views/pages/page.twig | 8 +- src/frontend/styles/components/button.pcss | 83 +++++++++++++++++++++ src/frontend/styles/components/header.pcss | 22 +++--- src/frontend/styles/components/page.pcss | 8 +- src/frontend/styles/components/writing.pcss | 7 +- src/frontend/styles/main.pcss | 6 ++ src/frontend/styles/vars.pcss | 23 +++--- src/frontend/svg/check.svg | 3 + src/frontend/svg/pencil.svg | 3 + src/frontend/svg/plus.svg | 4 +- src/frontend/svg/trash.svg | 3 + 14 files changed, 177 insertions(+), 46 deletions(-) create mode 100644 src/backend/views/components/button.twig create mode 100644 src/frontend/styles/components/button.pcss create mode 100644 src/frontend/svg/check.svg create mode 100644 src/frontend/svg/pencil.svg create mode 100644 src/frontend/svg/trash.svg 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 @@