Comments
Why and how to use this component
Allows users to comment.
When to use this component
- blogposts
- articles
{#
Accepts:
- "image" (object): image to display on the left (optional)
- "src" (string): image's URL
- "alt" (string): alt text
- "author" (string): author name
- "date" (string): formatted date
- "title" (object): comment's title
- "href" (string): link to point to
- "label" (string): text to display
- "body" (string): comment's text
- "operations" (object): object of operations (reply, edit, delete)
- "delete|edit|reply" (object):
- href (string)
- label (string)
- visible (boolean)
#}
{# Internal properties #}
{% set _css_class = 'ecl-row ecl-comment' %}
{% set _extra_attributes = '' %}
{# Internal logic - Process properties #}
{% if extra_class is defined %}
{% set _css_class = _css_class ~ ' ' ~ extra_class %}
{% endif %}
{% if extra_attributes is defined %}
{% for attr in extra_attributes %}
{% set _extra_attributes = _extra_attributes ~ ' ' ~ attr.name ~ '="' ~ attr.value ~ '"' %}
{% endfor %}
{% endif %}
<div class="{{ _css_class }}" {{ _extra_attributes|raw }}>
{% if image is defined %}
<div class="ecl-comment__image-wrapper">
<img class="ecl-comment__image" src="{{ image.src }}" alt="{{ image.alt }}">
</div>
{% endif %}
<div class="ecl-comment__body">
<div class="ecl-comment__meta">
<span class="ecl-comment__author">{{ author }}</span> |
<span class="ecl-comment__date">{{ date }}</span>
</div>
{% include '@ec-europa/ecl-links' with {
'extra_classes': 'ecl-heading ecl-heading--h3 ecl-comment__title',
}|merge(title)
%}
<div class="ecl-comment__text">
<p class="ecl-paragraph">{{ body }}</p>
</div>
{% if operations is defined %}
<ul class="ecl-list ecl-list--inline ecl-comment__operations">
{% if operations.reply is defined and operations.reply.visible %}
<li>
{% include '@ec-europa/ecl-links' with {
'extra_classes': 'ecl-comment__reply',
}|merge(operations.reply)
%}
</li>
{% endif %}
{% if operations.edit is defined and operations.edit.visible %}
<li>
{% include '@ec-europa/ecl-links' with {
'extra_classes': 'ecl-comment__edit',
}|merge(operations.edit)
%}
</li>
{% endif %}
{% if operations.delete is defined and operations.delete.visible %}
<li>
{% include '@ec-europa/ecl-links' with {
'extra_classes': 'ecl-comment__delete',
}|merge(operations.delete)
%}
</li>
{% endif %}
</ul>
{% endif %}
</div>
</div>
{
"image": {
"src": "https://unsplash.it/300/400?image=1005",
"alt": "Martin's photo"
},
"author": "Martin (Not verified)",
"date": "26 March 2015",
"title": {
"href": "#",
"label": "Nice article"
},
"body": "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Culpa dolorem eius enim eos error esse fugiat incidunt iste laudantium nemo, numquam quam quasi repudiandae sapiente soluta sunt tempore ullam voluptatem.",
"operations": {
"delete": {
"href": "#",
"label": "Delete",
"visible": true
},
"edit": {
"href": "#",
"label": "Edit",
"visible": true
},
"reply": {
"href": "#",
"label": "Reply",
"visible": true
}
}
}
<div class="ecl-row ecl-comment">
<div class="ecl-comment__image-wrapper">
<img class="ecl-comment__image" src="https://unsplash.it/300/400?image=1005" alt="Martin's photo">
</div>
<div class="ecl-comment__body">
<div class="ecl-comment__meta">
<span class="ecl-comment__author">Martin (Not verified)</span> |
<span class="ecl-comment__date">26 March 2015</span>
</div>
<a class="ecl-link ecl-heading ecl-heading--h3 ecl-comment__title" href="#">Nice article</a>
<div class="ecl-comment__text">
<p class="ecl-paragraph">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Culpa dolorem eius enim eos error esse fugiat incidunt iste laudantium nemo, numquam quam quasi repudiandae sapiente soluta sunt tempore ullam voluptatem.</p>
</div>
<ul class="ecl-list ecl-list--inline ecl-comment__operations">
<li>
<a class="ecl-link ecl-comment__reply" href="#">Reply</a>
</li>
<li>
<a class="ecl-link ecl-comment__edit" href="#">Edit</a>
</li>
<li>
<a class="ecl-link ecl-comment__delete" href="#">Delete</a>
</li>
</ul>
</div>
</div>
-
Content:
/** * Comments component * @define comment */ .ecl-comment { display: flex; flex-wrap: nowrap; margin: 0; } .ecl-comment__image-wrapper { display: none; flex-shrink: 0; @include ecl-media-breakpoint-up(md) { display: block; padding-right: map-get($ecl-spacing, 'm'); width: 20%; } } .ecl-comment__image { border: 1px solid map-get($ecl-colors, 'yellow-100'); padding: 1px; } .ecl-comment__body { background-color: #fff; flex-grow: 1; flex-shrink: 1; font-size: map-get($ecl-font-size, 's'); padding: map-get($ecl-spacing, 'm') map-get($ecl-spacing, 'l'); position: relative; } .ecl-comment__body::before { @include ecl-media-breakpoint-up(md) { border: map-get($ecl-spacing, 'xs') solid rgba(255, 255, 255, 0); border-right-color: #fff; content: ' '; height: 0; margin-top: -map-get($ecl-spacing, 'xs'); pointer-events: none; position: absolute; right: 100%; top: map-get($ecl-spacing, 'm'); width: 0; } } .ecl-comment__meta { border-bottom: 1px solid map-get($ecl-colors, 'yellow-100'); margin-bottom: map-get($ecl-spacing, 'xs'); padding-bottom: map-get($ecl-spacing, 'xxxs'); } .ecl-comment__title { color: $ecl-color-shade; display: block; padding: map-get($ecl-spacing, 's') 0; }
- URL: /components/raw/ecl-comments/_comments.scss
- Filesystem Path: framework/components/ecl-comments/_comments.scss
- Size: 1.3 KB
- Handle: @ec-europa/ecl-comments
- Tags: molecule
- Preview:
- Filesystem Path: framework/components/ecl-comments/ecl-comments.twig