6868#}
6969
7070{# Remove comment id from element id on top comment #}
71+ {% set is_top_comment = attributes.hasClass (' top-comment' ) %}
7172{% if attributes.hasClass (' top-comment' ) %}
7273 {% set attributes = attributes.setAttribute (' id' , ' top-comment' ) %}
7374{% endif %}
7475
75- <article {{ attributes.addClass (' js-comment os2loop-comment' ) }}>
76+ {% set classes = [
77+ ' js-comment' ,
78+ ' os2loop-comment' ,
79+ ' entity' ,
80+ is_top_comment ? ' top-comment'
81+ ] %}
82+
83+ <article {{ attributes.addClass (classes ) }}>
7684 {#
7785 Hide the "new" indicator by default, let a piece of JavaScript ask the
7886 server which comments are new for the user. Rendering the final "new"
7987 indicator here would break the render cache.
8088 #}
81- <div class =" d-flex align-items-center row no-gutters" >
82- <div class =" reply-header row no-gutters" >
83- {% include ' @os2loop_theme/field/user-info.html.twig' with {user : drupal_entity(' user' , comment .uid .target_id ), date : created , entity : comment } %}
84- {% include ' @os2loop_theme/navigation/comment-tasks.html.twig' with {node : drupal_entity(' node' , comment .entity_id .target_id )} %}
85- </div >
89+ <div class =" container entity-header d-inline-flex align-items-top" >
90+ {% include ' @os2loop_theme/field/user-info.html.twig' with {user : drupal_entity(' user' , comment .uid .target_id ), date : created , entity : comment , attributes : attributes } %}
91+ {% include ' @os2loop_theme/navigation/comment-tasks.html.twig' with {node : drupal_entity(' node' , comment .entity_id .target_id )} %}
8692 </div >
8793 {#
8894 Indicate the semantic relationship between parent and child comments for
8995 accessibility. The list is difficult to navigate in a screen reader
9096 without this information.
9197 #}
92- <div {{ content_attributes.addClass (' reply-body' ) }}>
93- {% if parent %}
94- <p class =" visually-hidden" >{{ parent }}</p >
95- {% endif %}
96- {{ content .os2loop_post_comment }}
97- <div >{{ content .flag_os2loop_upvote_correct_answer }}</div >
98+ <div {{ content_attributes.addClass (' entity-body' ) }}>
99+ <div class =" row" >
100+ <div class =" col" >
101+ {% if parent %}
102+ {# TODO: the value for length (215) is arbitrary - this should be handled using JS function instead #}
103+ {% set toggle_parent_comment = parent_comment .os2loop_post_comment .value | length > 215 %}
104+ <p class =" visually-hidden" >{{ parent }}</p >
105+ <div class =" parent-entity" aria-hidden =" true" >
106+ <div class =" parent-entity-header row no-gutters mb-10" >
107+ {% include ' @os2loop_theme/field/user-info.html.twig' with {user : drupal_entity(' user' , parent_comment .uid .target_id ), date : parent_created , entity : parent_comment , attributes : null } %}
108+ </div >
109+ <div class =" parent-entity-body{{ toggle_parent_comment ? ' collapse' }}" id =" parent-entity-body-{{ parent_comment.id () }}" >
110+ {{ parent_comment .os2loop_post_comment .value }}
111+ </div >
112+ {% if toggle_parent_comment %}
113+ <i class =" bi bi-chevron-up toggle collapsed" data-toggle =" collapse" href =" #parent-entity-body-{{ parent_comment.id () }}" role =" button" ></i >
114+ {% endif %}
115+ </div >
116+ <div class =" child-entity-heading mt-30 mb-15" >{{ ' Answer' | t }}</div >
117+ {% endif %}
118+ {{ content .os2loop_post_comment }}
119+ </div >
120+ </div >
121+ <div class =" row align-items-end" >
122+ {% if content .os2loop_post_comment_media [' #items' ] is not empty %}
123+ <div class =" col" >{{ content .os2loop_post_comment_media }}</div >
124+ {% endif %}
125+ <div class =" col-auto ml-auto" >{{ content .flag_os2loop_upvote_correct_answer }}</div >
126+ </div >
98127 </div >
99- </article >
128+ </article >
0 commit comments