diff --git a/modules/productcomments/views/templates/hook/product-comments-list.tpl b/modules/productcomments/views/templates/hook/product-comments-list.tpl index d31dcc8a7..39b6465a0 100644 --- a/modules/productcomments/views/templates/hook/product-comments-list.tpl +++ b/modules/productcomments/views/templates/hook/product-comments-list.tpl @@ -9,18 +9,84 @@ var productCommentAbuseReportErrorMessage = '{l|escape:'javascript' s='Sorry, your abuse report cannot be sent.' d='Modules.Productcomments.Shop'}'; + {assign var='hasSummary' value=($nb_comments > 0 && isset($summary))} + + {capture name='post_review_button'} + {if $nb_comments > 0 && $post_allowed} +
+ +
+ {/if} + {/capture} + + {capture name='comments_title'}{l s='Comments' d='Modules.Productcomments.Shop'}{if !$hasSummary} ({$nb_comments}){/if}{/capture} +
-

- {l s='Comments' d='Modules.Productcomments.Shop'} ({$nb_comments}) -

- {include file='module:productcomments/views/templates/hook/average-grade-stars.tpl' grade=$average_grade showGradeAverage=true showNbComments=false} + {include file='components/section-title.tpl' title=$smarty.capture.comments_title} + + {if $hasSummary} + {$smarty.capture.post_review_button nofilter} + {else} + {include file='module:productcomments/views/templates/hook/average-grade-stars.tpl' grade=$average_grade showGradeAverage=true showNbComments=false} + {/if}
- {if $nb_comments > 0 && $post_allowed} -
- + {if !$hasSummary} + {$smarty.capture.post_review_button nofilter} + {/if} + + {if $hasSummary} +
+
+
+ {$average_grade|number_format:1} + {l s='/5.0' d='Modules.Productcomments.Shop'} +
+
+ {include file='module:productcomments/views/templates/hook/average-grade-stars.tpl' grade=$average_grade showGradeAverage=false showNbComments=false} +
+
+ {if $nb_comments > 1} + {l s='Based on %s reviews' sprintf=[$nb_comments] d='Modules.Productcomments.Shop'} + {else} + {l s='Based on %s review' sprintf=[$nb_comments] d='Modules.Productcomments.Shop'} + {/if} +
+
+ +
+
+ {foreach $summary as $grade => $details} +
+
+ {$grade} +
+ +
+
+ +
+
+
+ + +
+ {/foreach} +
+
{elseif $nb_comments == 0} {include file='module:productcomments/views/templates/hook/empty-product-comment.tpl'} diff --git a/src/scss/prestashop/modules/_productcomments.scss b/src/scss/prestashop/modules/_productcomments.scss index 797571aad..c094ebfa8 100644 --- a/src/scss/prestashop/modules/_productcomments.scss +++ b/src/scss/prestashop/modules/_productcomments.scss @@ -151,14 +151,27 @@ padding: 0; margin-block-end: 1rem; + &:has(#product-comments-list-btn-group) { + justify-content: space-between; + } + .section-title { margin-block-end: 0; } + + #product-comments-list-btn-group { + margin-block-end: 0; + } } // Comments list button group #product-comments-list-btn-group { + width: 100%; margin-block-end: 1rem; + + @include media-breakpoint-up(sm) { + width: auto; + } } // Empty comments @@ -343,7 +356,7 @@ .grade-stars { position: relative; display: inline-block; - min-width: 7.5rem; + min-width: 7rem; height: 1.25rem; &.small-stars { @@ -360,3 +373,80 @@ margin-block-end: 3rem; } } + +/** + * Product comments summary + */ +.product-comments-summary { + display: grid; + grid-template-columns: 1fr; + gap: 1rem; + padding: 1.5rem; + margin-block-end: 1rem; + background: var(--bs-tertiary-bg); + border: var(--bs-border-width) var(--bs-border-style) var(--bs-border-color); + border-radius: var(--bs-border-radius); + + &__left { + display: flex; + flex-flow: column; + align-items: center; + justify-content: center; + } + + &__average-score { + font-size: 3.5rem; + font-weight: 700; + } + + &__stars { + margin-block-end: 0.5rem; + } + + &__star-icon { + position: relative; + display: inline-block; + min-width: 1.5rem; + height: 1.25rem; + } + + &__grade-list { + display: flex; + flex-direction: column; + gap: 0.5rem; + } + + &__grade-item { + display: flex; + gap: 0.5rem; + align-items: center; + } + + &__grade-label { + display: flex; + gap: 0.25rem; + align-items: center; + justify-content: flex-end; + } + + &__grade-value { + width: 1ch; + font-weight: 600; + text-align: center; + } + + &__progress { + --bs-progress-height: 0.625rem; + + flex-grow: 1; + } + + &__stats { + width: 4ch; + text-align: center; + } + + @include media-breakpoint-up(md) { + grid-template-columns: 4fr 8fr; + } +}