bootstrap_italia-8.x-0.x-dev/components/components-2/share/share.html.twig
components/components-2/share/share.html.twig
{# /** * @file * Template for share component. * Docs: https://italia.github.io/bootstrap-italia/docs/esempi/comuni/template-novita-notizia/ * Latest revision: v2.7.5 * * Parameters: * - targets (array) (default: [...]) * { 'facebook': { 'enable': true, 'label': 'Facebook', 'icon': 'it-facebook', 'description': 'Share on Facebook'|trans, 'targetType': '_blank', 'targetUrl': 'https://www.facebook.com/sharer/sharer.php?u=' ~ current_url }, ... } * - label (string) (default: '') [deprecated: use dropdown_label] * - icon (string) (default: '') [deprecated: use dropdown_icon] * - dropdown_label (string) (default 'View actions') * - dropdown_icon (string) (default 'it-more-items') * - dropdown_icon_color (string) (default 'black') * - dropdown_icon_size (string) (default 'sm') * - dropdown_button_classes (array) (default: '') * - item_icon_color (string) (default 'primary') * - item_icon_size (string) (default 'sm') * - share_classes (array) (default: '') * - share_attributes (obj attribute) (default: '') * * Examples: {% include '@bi-bcl/share/share.html.twig' with { targets: targets, label: 'label'|t, icon: 'it-icon-name' } %} * */ #} {% apply spaceless %} {# Set defaults #} {% set _targets = targets|default('') %} {% set _dropdown_label = dropdown_label|default('') %} {% set _dropdown_icon = dropdown_icon|default('') %} {% set _dropdown_icon_color = dropdown_icon_color|default('black') %} {% set _dropdown_icon_size = dropdown_icon_size|default('sm') %} {% set _dropdown_button_classes = dropdown_button_classes|default('') %} {% set _item_icon_color = item_icon_color|default('primary') %} {% set _item_icon_size = item_icon_size|default('sm') %} {% set _label = label|default('') %} {# Deprecated #} {% set _icon = icon|default('') %} {# Deprecated #} {% set _share_classes = share_classes|default('') %} {% set _share_attributes = share_attributes|default('') %} {# Retrocompatibility settings #} {% if _dropdown_label is empty and _label is not empty %} {% set _dropdown_label = _label %} {% endif %} {% if _dropdown_icon is empty and _icon is not empty %} {% set _dropdown_icon = _icon %} {% endif %} {# Set options #} {% set _classes = [ 'list-item', 'dropdown-item' ] %} {% if _share_classes is not empty %} {% set _classes = _classes|merge(share_classes) %} {% endif %} {% if _share_attributes is empty %} {% set share_attributes = create_attribute() %} {% endif %} {% set share_attributes = share_attributes .addClass(_classes) .setAttribute('rel', 'noopener') %} {# Component #} {% embed '@bi-bcl/dropdown/dropdown.html.twig' with { label: _dropdown_label, icon_before: _dropdown_icon, size: _dropdown_icon_size, hide_block_after: true, icon_color: _dropdown_icon_color, button_classes: _dropdown_button_classes, dropdown_classes: ['shadow-lg'], } %} {% block dropdownContent %} <div class="link-list-wrapper"> <ul class="link-list"> {% for target in _targets %} {% if target['enable'] %} {% if target['id'] %} {% set share_attributes = share_attributes.setAttribute('id', target['id']) %} {% endif %} {% if target['targetType'] %} {% set share_attributes = share_attributes.setAttribute('target', target['targetType']) %} {% endif %} {% if target['description'] %} {% set share_attributes = share_attributes.setAttribute('aria-label', target['description']) %} {% endif %} <li> <a href="{{ target['targetUrl'] }}" {{ share_attributes }} {{ target['customAttributes'] }}> {% include '@bi-bcl/icon/icon.html.twig' with { name: target['icon'], color: _item_icon_color, size: _item_icon_size, } %} <span>{{ target['label'] }}</span> </a> </li> {% endif %} {% endfor %} </ul> </div> {% endblock %} {% endembed %} {% endapply %}