EC System

Profile topbar

Defines the profile topbar component.

{#
  Parameters:
    - "context_nav" (object) - data for @ecl/ec-component-context-nav component composition
    - "profile" (object): profile-specific information
      - "image" (object): data for @ecl/ec-style-image component composition
      - "expandable" (object): data related to the expandable part of the component
        - "button" (object): data for @ecl/ec-component-button component composition
        - "expandable_body" (array): accepts `extra_attributes` for the expandable
    - "extra_classes" (string) (default: '')
    - "extra_attributes" (array) (default: []): format: [
        {
          "name" (string) (default: ''),
          "value" (string) (default: '')
        },
        ...
      ]
    - "system" (string) (default: "generic")
  Blocks:
    - "body" (default: lorem ipsum text): content in the expandable area
#}

{# Internal properties #}

{% set _context_nav = context_nav|default({}) %}
{% set _css_class = 'ecl-profile-topbar' %}
{% set _profile = {
  'image': {},
  'expandable': {},
}|merge(profile|default({})) %}
{% set _extra_attributes = '' %}

{# Internal logic - Process properties #}

{% if extra_classes is defined and extra_classes is not empty %}
  {% set _css_class = _css_class ~ ' ' ~ extra_classes %}
{% endif %}

{% if extra_attributes is defined and extra_attributes is not empty and extra_attributes is iterable %}
  {% for attr in extra_attributes %}
    {% set _extra_attributes = _extra_attributes ~ ' ' ~ attr.name ~ '="' ~ attr.value|e ~'"' %}
  {% endfor %}
{% endif %}

{# Print the result #}

<div class="{{ _css_class }}"{{ _extra_attributes|raw }}>
  <div class="ecl-container">
    <div class="ecl-row">
      <div class="ecl-col-md-2">
        {% include '@ecl/ec-style-image' with profile.image only %}
      </div>
      <div class="ecl-col-md-10 ecl-profile-topbar__pane">
        {% include '@ecl/ec-component-context-nav' with _context_nav only %}
        {% include '@ecl/ec-component-button' with profile.expandable.button only %}
      </div>
    </div>
  </div>
  <div
    {% if profile.expandable.expandable_body.extra_attributes is defined %}
      {% for attr in profile.expandable.expandable_body.extra_attributes %}
        {% set attribute = attr.name ~ '="' ~ attr.value|e ~'"' %}
        {{ attribute }}
      {% endfor %}
    {% endif %}
  >
    <div class="ecl-container">
      {% block body %}
        <p>
          Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce et augue quis est dignissim lacinia. Curabitur interdum iaculis sagittis. Maecenas sodales elit est, et suscipit nisl vulputate eget. Mauris vel pulvinar odio. Sed diam turpis, cursus vel congue vel, lobortis a ipsum. Donec vel quam nec enim tristique efficitur at eget nisl.
        </p>
      {% endblock %}
    </div>
  </div>
</div>
{
  "_demo": {
    "scripts": "document.addEventListener('DOMContentLoaded', function () { ECL.initExpandables('#ecl-profile-topbar__expandable-button-1'); });"
  },
  "profile": {
    "image": {
      "src": "../../assets/demo_images/default_profile_image.png",
      "alt": "Example profile image"
    },
    "expandable": {
      "button": {
        "label": "See details",
        "type_attribute": "button",
        "extra_classes": "ecl-expandable__button ecl-profile-topbar__pane-button",
        "extra_attributes": [
          {
            "name": "aria-controls",
            "value": "ecl-profile-topbar__expandable-1"
          },
          {
            "name": "aria-expanded",
            "value": "false"
          },
          {
            "name": "id",
            "value": "ecl-profile-topbar__expandable-button-1"
          }
        ]
      },
      "expandable_body": {
        "extra_attributes": [
          {
            "name": "aria-hidden",
            "value": "true"
          },
          {
            "name": "aria-labelledby",
            "value": "ecl-profile-topbar__expandable-button-1"
          },
          {
            "name": "id",
            "value": "ecl-profile-topbar__expandable-1"
          },
          {
            "name": "class",
            "value": "ecl-profile-topbar__collapsible-area"
          }
        ]
      }
    }
  },
  "context_nav": {
    "label": "Department",
    "items": [
      {
        "href": "../../example.html#",
        "label": "Trade"
      },
      {
        "href": "../../example.html#",
        "label": " European Anti-Fraud Office"
      }
    ]
  }
}
<div class="ecl-profile-topbar">
  <div class="ecl-container">
    <div class="ecl-row">
      <div class="ecl-col-md-2">

        <img class="ecl-image" alt="Example profile image" src="../../assets/demo_images/default_profile_image.png" />

      </div>
      <div class="ecl-col-md-10 ecl-profile-topbar__pane">

        <div class="ecl-context-nav">
          <span class="ecl-context-nav__label">Department</span>
          <ul class="ecl-context-nav__list">
            <li class="ecl-context-nav__item">

              <a class="ecl-link ecl-link--standalone" href="../../example.html#">Trade</a>
            </li>
            <li class="ecl-context-nav__item">

              <a class="ecl-link ecl-link--standalone" href="../../example.html#"> European Anti-Fraud Office</a>
            </li>
          </ul>
        </div>

        <button type="button" class="ecl-button ecl-button--default ecl-expandable__button ecl-profile-topbar__pane-button" aria-controls="ecl-profile-topbar__expandable-1" aria-expanded="false" id="ecl-profile-topbar__expandable-button-1">See details</button>
      </div>
    </div>
  </div>
  <div aria-hidden="true" aria-labelledby="ecl-profile-topbar__expandable-button-1" id="ecl-profile-topbar__expandable-1" class="ecl-profile-topbar__collapsible-area">
    <div class="ecl-container">
      <p>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce et augue quis est dignissim lacinia. Curabitur interdum iaculis sagittis. Maecenas sodales elit est, et suscipit nisl vulputate eget. Mauris vel pulvinar odio. Sed diam turpis, cursus vel congue vel, lobortis a ipsum. Donec vel quam nec enim tristique efficitur at eget nisl.
      </p>
    </div>
  </div>
</div>
  • Content:
    /**
     * ECL Profile Topbar
     * @define profile-topbar
     */
    
    // Import base and generic
    @import '@ecl/ec-base/ec-base';
    @import '@ecl/generic-component-profile-topbar/generic-component-profile-topbar';
    
    // Check if overridden dependencies are already loaded, if needed
    @include check-imports(('ec-component-expandable'));
    
    // Use generic mixin
    @include exports('ec-component-profile-topbar') {
      @include ecl-profile-topbar();
    }
    
  • URL: /components/raw/ec-component-profile-topbar/ec-component-profile-topbar.scss
  • Filesystem Path: ../../src/systems/ec/ec-component/ec-component-profile-topbar/ec-component-profile-topbar.scss
  • Size: 425 Bytes
  • Handle: @ecl/ec-component-profile-topbar
  • Tags: organism
  • Preview:
  • Filesystem Path: ../../src/systems/ec/ec-component/ec-component-profile-topbar/ec-component-profile-topbar.twig