-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OEL-579: Adapt special card pattern for search page.
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
templates/patterns/card_search/card_search.ui_patterns.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
41
templates/patterns/card_search/pattern-card_search.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}) }} |