Skip to content

Commit

Permalink
release(2.2.0): tema risultati di ricerca ouitoulia/diagraphe#22
Browse files Browse the repository at this point in the history
  • Loading branch information
arturu committed Apr 30, 2024
1 parent 82f171a commit d03a0d9
Show file tree
Hide file tree
Showing 18 changed files with 343 additions and 16 deletions.
119 changes: 119 additions & 0 deletions components/card/card-highlighting-search-results.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
{#
/**
* @file
* Default theme implementation to display a node.
*
* Available variables:
* - node: The node entity with limited access to object properties and methods.
* Only method names starting with "get", "has", or "is" and a few common
* methods such as "id", "label", and "bundle" are available. For example:
* - node.getCreatedTime() will return the node creation timestamp.
* - node.hasField('field_example') returns TRUE if the node bundle includes
* field_example. (This does not indicate the presence of a value in this
* field.)
* - node.isPublished() will return whether the node is published or not.
* Calling other methods, such as node.delete(), will result in an exception.
* See \Drupal\node\Entity\Node for a full list of public properties and
* methods for the node object.
* - label: (optional) The title of the node.
* - content: All node items. Use {{ content }} to print them all,
* or print a subset such as {{ content.field_example }}. Use
* {{ content|without('field_example') }} to temporarily suppress the printing
* of a given child element.
* - author_picture: The node author user entity, rendered using the "compact"
* view mode.
* - metadata: Metadata for this node.
* - date: (optional) Themed creation date field.
* - author_name: (optional) Themed author name field.
* - url: Direct URL of the current node.
* - display_submitted: Whether submission information should be displayed.
* - attributes: HTML attributes for the containing element.
* The attributes.class element may contain one or more of the following
* classes:
* - node: The current template type (also known as a "theming hook").
* - node--type-[type]: The current node type. For example, if the node is an
* "Article" it would result in "node--type-article". Note that the machine
* name will often be in a short form of the human readable label.
* - node--view-mode-[view_mode]: The View Mode of the node; for example, a
* teaser would result in: "node--view-mode-teaser", and
* full: "node--view-mode-full".
* The following are controlled through the node publishing options.
* - node--promoted: Appears on nodes promoted to the front page.
* - node--sticky: Appears on nodes ordered above other non-sticky nodes in
* teaser listings.
* - node--unpublished: Appears on unpublished nodes visible only to site
* admins.
* - title_attributes: Same as attributes, except applied to the main title
* tag that appears in the template.
* - content_attributes: Same as attributes, except applied to the main
* content tag that appears in the template.
* - author_attributes: Same as attributes, except applied to the author of
* the node tag that appears in the template.
* - title_prefix: Additional output populated by modules, intended to be
* displayed in front of the main title tag that appears in the template.
* - title_suffix: Additional output populated by modules, intended to be
* displayed after the main title tag that appears in the template.
* - view_mode: View mode; for example, "teaser" or "full".
* - teaser: Flag for the teaser state. Will be true if view_mode is 'teaser'.
* - page: Flag for the full page state. Will be true if view_mode is 'full'.
* - readmore: Flag for more state. Will be true if the teaser content of the
* node cannot hold the main body content.
* - logged_in: Flag for authenticated user status. Will be true when the
* current user is a logged-in member.
* - is_admin: Flag for admin user status. Will be true when the current user
* is an administrator.
*
* @see template_preprocess_node()
*
* @ingroup themeable
*/
#}
{% apply spaceless %}
{# Set defaults #}
{% set _card_variant = card_variant|default('petrol') %}

{% set classes = [
'node',
'article-wrapper',
'node--type-' ~ node.bundle|clean_class,
node.isPromoted() ? 'node--promoted',
node.isSticky() ? 'node--sticky',
not node.isPublished() ? 'node--unpublished',
view_mode ? 'node--view-mode-' ~ view_mode|clean_class,
] %}
<article{{ attributes.addClass(classes) }}>
<header>
{% if title_prefix %}
<small class="text-{{ _card_variant }}">
{{ title_prefix }}
</small>
{% endif %}
<h3{{ title_attributes.addClass(['h4', 'mb-2']) }}>
<a href="{{ url }}" title="{{ 'Read more about:'|t }} {{ label[0]['#context'].value }}" rel="bookmark">
{{ label }}
{% if title_suffix %}<small class="d-block fw-normal lh-1 mt-1">{{ title_suffix }}</small>{% endif %}
</a>
</h3>
</header>
<section{{ content_attributes.addClass(['node__content', 'pt-2']) }}>
{% if content.field_copertina[0] is iterable %}
<div class="float-start me-3 mb-1">
{{ content.field_copertina }}
</div>
{% endif %}
<div>
{{ content|without('field_copertina', 'field_argomenti') }}
</div>
<div class="pt-3">
{{ content.field_argomenti }}
</div>
</section>
<footer class="mt-3" aria-label="Collegamenti per approfondire {{ label[0]['#context'].value }}">
<a class="read-more text-{{ _card_variant }}" href="{{ url }}" title="{{ 'Read more about'|t }} {{ label[0]['#context'].value }}" rel="bookmark">
<span class="text">{{ 'Read more'|t }}</span>
<span class="visually-hidden">{{ 'about'|t }} {{ label[0]['#context'].value }}</span>
{% include '@bi-bcl/icon/icon.html.twig' with {name: 'it-arrow-right'} %}
</a>
</footer>
</article>
{% endapply %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% include '@bi-field/field-reference--format-label--component-badge.html.twig' with {
background: 'petrol',
rounded_pill: true,
outline: true,
attributes: attributes.addClass('badges'),
} %}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
{% set giorno_fine = content.field_data_fine[0]['#attributes']['datetime']|date('Y-m-d') %}
{% if giorno_inizio == giorno_fine %}
{{ content.field_data_inizio }} dalle {{ content.field_data_inizio[0]['#attributes']['datetime']|date('H:i') }} alle {{ content.field_data_fine[0]['#attributes']['datetime']|date('H:i') }}
{% else %}
{% elseif content.field_data_fine[0] is iterable %}
dal {{ content.field_data_inizio }} al {{ content.field_data_fine }}
{% else %}
{{ content.field_data_inizio }}
{% endif %}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% include '@skenografia/field/_field--raw.html.twig' %}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% include '@skenografia/field/_field--raw.html.twig' %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% include '@skenografia_components/card/card-highlighting-search-results.html.twig' with {
card_variant: 'greendark',
title_prefix: 'Circolare ' ~ content.field_numero_circolare|render|striptags|trim ~ '-' ~ content.field_anno_scolastico|render|striptags|trim,
title_suffix: content.field_abstract|render|striptags|trim,
content: content|without('field_numero_circolare', 'field_anno_scolastico', 'field_abstract')
} %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% include '@skenografia_components/card/card-highlighting-search-results.html.twig' with {
card_variant: 'redbrown',
title_prefix: 'Documento Prot. ' ~ content.field_protocollo|render|striptags|trim ~ ' del ' ~ content.field_data_inizio|render|striptags|trim ~ ' - ' ~ content.field_tipologia_documento|render|striptags|trim,
title_suffix: content.field_abstract|render|striptags|trim,
content: content|without('field_protocollo', 'field_data_inizio', 'field_tipologia_documento','field_abstract')
} %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% apply spaceless %}
{% set _dal_al %}
{% include '@skenografia/node/_partial.field--type-date--name-dal-al.html.twig' %}
{% endset %}
{% include '@skenografia_components/card/card-highlighting-search-results.html.twig' with {
card_variant: 'greendark',
title_prefix: 'Evento ' ~ _dal_al|striptags|trim,
title_suffix: content.field_abstract|render|striptags|trim,
content: content|without('field_data_inizio', 'field_data_fine','field_abstract')
} %}
{% endapply %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% include '@skenografia_components/card/card-highlighting-search-results.html.twig' with {
card_variant: 'greendark',
title_prefix: 'Finanziamento ' ~ content.field_tipologia_finanziamento|render|striptags|trim,
title_suffix: content.field_abstract|render|striptags|trim,
content: content|without('field_tipologia_finanziamento', 'field_abstract')
} %}
94 changes: 94 additions & 0 deletions templates/node/node--search-result.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{#
/**
* @file
* Default theme implementation to card display a node.
* To activate this template you need to add a display named 'card'.
*
* Available variables:
* - node: The node entity with limited access to object properties and methods.
* Only method names starting with "get", "has", or "is" and a few common
* methods such as "id", "label", and "bundle" are available. For example:
* - node.getCreatedTime() will return the node creation timestamp.
* - node.hasField('field_example') returns TRUE if the node bundle includes
* field_example. (This does not indicate the presence of a value in this
* field.)
* - node.isPublished() will return whether the node is published or not.
* Calling other methods, such as node.delete(), will result in an exception.
* See \Drupal\node\Entity\Node for a full list of public properties and
* methods for the node object.
* - label: (optional) The title of the node.
* - content: All node items. Use {{ content }} to print them all,
* or print a subset such as {{ content.field_example }}. Use
* {{ content|without('field_example') }} to temporarily suppress the printing
* of a given child element.
* - author_picture: The node author user entity, rendered using the "compact"
* view mode.
* - metadata: Metadata for this node.
* - date: (optional) Themed creation date field.
* - author_name: (optional) Themed author name field.
* - url: Direct URL of the current node.
* - display_submitted: Whether submission information should be displayed.
* - attributes: HTML attributes for the containing element.
* The attributes.class element may contain one or more of the following
* classes:
* - node: The current template type (also known as a "theming hook").
* - node--type-[type]: The current node type. For example, if the node is an
* "Article" it would result in "node--type-article". Note that the machine
* name will often be in a short form of the human readable label.
* - node--view-mode-[view_mode]: The View Mode of the node; for example, a
* teaser would result in: "node--view-mode-teaser", and
* full: "node--view-mode-full".
* The following are controlled through the node publishing options.
* - node--promoted: Appears on nodes promoted to the front page.
* - node--sticky: Appears on nodes ordered above other non-sticky nodes in
* teaser listings.
* - node--unpublished: Appears on unpublished nodes visible only to site
* admins.
* - title_attributes: Same as attributes, except applied to the main title
* tag that appears in the template.
* - content_attributes: Same as attributes, except applied to the main
* content tag that appears in the template.
* - author_attributes: Same as attributes, except applied to the author of
* the node tag that appears in the template.
* - title_prefix: Additional output populated by modules, intended to be
* displayed in front of the main title tag that appears in the template.
* - title_suffix: Additional output populated by modules, intended to be
* displayed after the main title tag that appears in the template.
* - view_mode: View mode; for example, "teaser" or "full".
* - teaser: Flag for the teaser state. Will be true if view_mode is 'teaser'.
* - page: Flag for the full page state. Will be true if view_mode is 'full'.
* - readmore: Flag for more state. Will be true if the teaser content of the
* node cannot hold the main body content.
* - logged_in: Flag for authenticated user status. Will be true when the
* current user is a logged-in member.
* - is_admin: Flag for admin user status. Will be true when the current user
* is an administrator.
*
* @see template_preprocess_node()
*
* @ingroup themeable
*/
#}
{% apply spaceless %}
{% set node_variants_map = {
'persona': 'redbrown',
'luogo': 'redbrown',
'documento': 'redbrown',
'struttura-organizzativa': 'redbrown',
'servizio': 'purplelight',
'percorso-di-studio': 'purplelight',
'article': 'greendark',
'circolare': 'greendark',
'evento': 'greendark',
'finanziamento': 'greendark',
'scheda-didattica': 'bluelectric',
'progetto': 'bluelectric',
'classe': 'bluelectric'
} %}
{% include '@skenografia_components/card/card-highlighting-search-results.html.twig' with {
card_variant: node_variants_map[node.bundle|clean_id] ?? 'petrol',
title_prefix: drupal_config('node.type.' ~ node.bundle, 'name'),
title_suffix: content.field_abstract|render|striptags|trim,
content: content|without('field_abstract')
} %}
{% endapply %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% apply spaceless %}
{% set _dal_al %}
{% include '@skenografia/node/_partial.field--type-date--name-dal-al.html.twig' %}
{% endset %}
{% include '@skenografia_components/card/card-highlighting-search-results.html.twig' with {
card_variant: 'bluelectric',
title_prefix: 'Progetto - ' ~ _dal_al|striptags|trim,
title_suffix: content.field_abstract|render|striptags|trim,
content: content|without('field_data_inizio', 'field_data_fine','field_abstract')
} %}
{% endapply %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% include '@skenografia_components/card/card-highlighting-search-results.html.twig' with {
card_variant: 'purplelight',
title_prefix: 'Servizio per ' ~ content.field_tipologia_servizio|render|striptags|trim,
title_suffix: content.field_abstract|render|striptags|trim,
content: content|without('field_tipologia_servizio', 'field_abstract')
} %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% include '@skenografia_components/card/card-highlighting-search-results.html.twig' with {
card_variant: 'redbrown',
title_prefix: 'Struttura organizzativa - ' ~ content.field_tipologia_struttura|render|striptags|trim,
title_suffix: content.field_abstract|render|striptags|trim,
content: content|without('field_tipologia_struttura', 'field_abstract')
} %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{#
/**
* @file
* Default theme implementation to display a block.
*
* Available variables:
* - plugin_id: The ID of the block implementation.
* - label: The configured label of the block if visible.
* - configuration: A list of the block's configuration values.
* - label: The configured label for the block.
* - label_display: The display settings for the label.
* - provider: The module or other provider that provided this block plugin.
* - Block plugin specific settings will also be stored here.
* - content: The content of this block.
* - attributes: array of HTML attributes populated by modules, intended to
* be added to the main container tag of this template.
* - id: A valid HTML ID and guaranteed unique.
* - title_attributes: Same as attributes, except applied to the main title
* tag that appears in the template.
* - title_prefix: Additional output populated by modules, intended to be
* displayed in front of the main title tag that appears in the template.
* - title_suffix: Additional output populated by modules, intended to be
* displayed after the main title tag that appears in the template.
*
* @see template_preprocess_block()
*
* @ingroup themeable
*/
#}
{% apply spaceless %}
{% set id_block = 'it-' ~ attributes.id %}
{% set classes = [
'block',
'block-' ~ configuration.provider|clean_class,
'block-' ~ plugin_id|clean_class,
'mt-5',
'd-none',
'd-lg-block'
] %}

<div{{ attributes.addClass(classes).setAttribute('id', id_block) }}>
{{ title_prefix }}
{% if label %}
<h2{{ title_attributes }}>{{ label }}</h2>
{% endif %}
{{ title_suffix }}
{% block content %}
{{ content }}
{% endblock %}
</div>
{% endapply %}
2 changes: 1 addition & 1 deletion templates/views/search/form-element--name--ftxt.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
{% include '@bi-bcl/icon/icon.html.twig' with {
name: 'icon-search',
size: 'lg',
color: 'bluelectric',
color: 'petrol',
icon_classes: ['svg-search']
} %}
</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% include '@skenografia/views/search/input--submit--id--edit-submit-risultati-ricerca.html.twig' %}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@
.setAttribute('type', 'submit')
%}

<button{{ _attributes
.removeClass('btn-outline-bluelectric')
.addClass('btn-outline-primary')
.setAttribute('aria-label', 'Avvia la ricerca')
.setAttribute('data-element', 'search-submit')
.setAttribute('onclick', 'addHiddenValues(["tutti_i_valori"])')
}}>
Cerca in
<strong class="text-uppercase text-small-bold">tutto il sito</strong>
</button>

<button{{ _attributes
.addClass('btn-outline-redbrown')
.setAttribute('aria-label', 'Avvia la ricerca nella sezione scuola')
Expand Down Expand Up @@ -59,17 +70,6 @@
<strong class="text-uppercase text-small-bold">Didattica</strong>
</button>

<button{{ _attributes
.removeClass('btn-outline-bluelectric')
.addClass('btn-outline-primary')
.setAttribute('aria-label', 'Avvia la ricerca')
.setAttribute('data-element', 'search-submit')
.setAttribute('onclick', 'addHiddenValues(["tutti_i_valori"])')
}}>
Cerca in
<strong class="text-uppercase text-small-bold">tutto il sito</strong>
</button>

<input type="hidden" name="f[]" id="hidden-field" value="">
</div>
{% endapply %}
Expand Down
Loading

0 comments on commit d03a0d9

Please sign in to comment.