From 98c34ed9263ee3518193ba77a2ce10e065773423 Mon Sep 17 00:00:00 2001 From: escuriola Date: Wed, 27 Oct 2021 09:12:29 +0200 Subject: [PATCH] OEL-579: Adapt special card pattern for search page. --- .../card_search/card_search.ui_patterns.yml | 16 ++++++++ .../card_search/pattern-card_search.html.twig | 41 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 templates/patterns/card_search/card_search.ui_patterns.yml create mode 100644 templates/patterns/card_search/pattern-card_search.html.twig diff --git a/templates/patterns/card_search/card_search.ui_patterns.yml b/templates/patterns/card_search/card_search.ui_patterns.yml new file mode 100644 index 000000000..2965744a9 --- /dev/null +++ b/templates/patterns/card_search/card_search.ui_patterns.yml @@ -0,0 +1,16 @@ +card_search: + label: Card search page + description: Formatted card to display the search result content. + fields: + title: + type: text + label: Title of the search-card + text: + type: array + label: Text of the search-card result + image: + type: array + label: Image of the search-card + content: + type: array + label: Badges of the search-card diff --git a/templates/patterns/card_search/pattern-card_search.html.twig b/templates/patterns/card_search/pattern-card_search.html.twig new file mode 100644 index 000000000..04f953d96 --- /dev/null +++ b/templates/patterns/card_search/pattern-card_search.html.twig @@ -0,0 +1,41 @@ +{% set badges = [] %} +{% if content is not empty %} + {% set badge_attr = create_attribute({'class': ['me-2']}) %} + {% for key,item in content %} + {% if key|first != '#' %} + {% set badges = badges|merge([{ + '#type': 'pattern', + '#id': 'badge', + '#fields': { + label: item['#title'], + attributes: badge_attr + } + }]) %} + {% endif %} + {% endfor %} +{% endif %} +{% if image is defined and image['#markup'] is not empty %} + {% set _image = { + path: image['#markup'], + position: "top", + } %} +{% endif %} +{{ pattern('card', { + horizontal: true, + horizontal_grid: { + left_col_classes: "col-md-3", + right_col_classes: "col-md-9", + gutter: 0, + }, + title: { + content: title, + classes: "mb-4", + }, + text: { + content: text|render|striptags, + classes: "mb-4", + }, + attributes: attributes.addClass(["border-0", "mb-5"]), + image:_image, + content: badges|render +}) }}