Skip to content

Commit

Permalink
OEL-579: Adapt special card pattern for search page.
Browse files Browse the repository at this point in the history
  • Loading branch information
escuriola committed Oct 27, 2021
1 parent 4636572 commit 98c34ed
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
16 changes: 16 additions & 0 deletions templates/patterns/card_search/card_search.ui_patterns.yml
Original file line number Diff line number Diff line change
@@ -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
41 changes: 41 additions & 0 deletions templates/patterns/card_search/pattern-card_search.html.twig
Original file line number Diff line number Diff line change
@@ -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
}) }}

0 comments on commit 98c34ed

Please sign in to comment.