-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from magmodules/release/1.1.0
Release/1.1.0
- Loading branch information
Showing
9 changed files
with
1,238 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
purge: { | ||
content: [ | ||
'../templates/**/*.phtml', | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php declare(strict_types=1); | ||
/** | ||
* Copyright © Magmodules.eu. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
use Magento\Framework\View\Element\Template; | ||
use Hyva\Theme\ViewModel\HeroiconsSolid; | ||
use Hyva\Theme\Model\ViewModelRegistry; | ||
|
||
/** @var Template $block */ | ||
/** @var Escaper $escaper */ | ||
/** @var HeroiconsSolid $heroicons */ | ||
|
||
$heroicons = $viewModels->require(HeroiconsSolid::class); | ||
|
||
$svgSize = $block->hasData('svgSize') ? $block->getData('svgSize') : '20'; | ||
$starColor = $block->hasData('starColor') ? $block->getData('starColor') : ''; | ||
|
||
$svgSizeStyle = 'width: ' . $svgSize . 'px; height: ' . $svgSize . 'px; '; | ||
$starColorStyle = $starColor ? 'color: ' . $starColor : ''; | ||
|
||
$percent = $block->hasData('percent') ? $block->getData('percent') . '%' : '0%'; | ||
?> | ||
|
||
<div data-element="box-stars" class="relative inline-flex" title="<?= $percent ?>"> | ||
<div style="width: <?= $percent; ?>;" | ||
class="absolute top-0 right-0 bottom-0 left-0 overflow-hidden"> | ||
|
||
<div class="inline-flex text-[#ffad0f]"> | ||
<?= $heroicons->starHtml('', null, null, ["style" => $svgSizeStyle . $starColorStyle]); ?> | ||
<?= $heroicons->starHtml('', null, null, ["style" => $svgSizeStyle . $starColorStyle]); ?> | ||
<?= $heroicons->starHtml('', null, null, ["style" => $svgSizeStyle . $starColorStyle]); ?> | ||
<?= $heroicons->starHtml('', null, null, ["style" => $svgSizeStyle . $starColorStyle]); ?> | ||
<?= $heroicons->starHtml('', null, null, ["style" => $svgSizeStyle . $starColorStyle]); ?> | ||
</div> | ||
</div> | ||
|
||
<div class="inline-flex text-gray-300"> | ||
<?= $heroicons->starHtml('', null, null, ["style" => $svgSizeStyle]); ?> | ||
<?= $heroicons->starHtml('', null, null, ["style" => $svgSizeStyle]); ?> | ||
<?= $heroicons->starHtml('', null, null, ["style" => $svgSizeStyle]); ?> | ||
<?= $heroicons->starHtml('', null, null, ["style" => $svgSizeStyle]); ?> | ||
<?= $heroicons->starHtml('', null, null, ["style" => $svgSizeStyle]); ?> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
<?php declare(strict_types=1); | ||
/** | ||
* Copyright © Magmodules.eu. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
use Magmodules\KiyOhSR\Block\Widget\Review\Badge; | ||
use Magento\Framework\Escaper; | ||
use Hyva\Theme\ViewModel\HeroiconsOutline; | ||
use Hyva\Theme\Model\ViewModelRegistry; | ||
|
||
/** @var Badge $block */ | ||
/** @var Escaper $escaper */ | ||
/** @var HeroiconsOutline $heroicons */ | ||
|
||
$uniqId = $block->getUniqueId(); | ||
|
||
$accountInfo = $block->getAccountInfo(); | ||
$reviewsCount = $accountInfo[0]['total']; | ||
$reviewsAvgScore = $accountInfo[0]['avgRatingScore']; | ||
$reviewsAvgRating = $accountInfo[0]['avgRating']; | ||
|
||
$heroicons = $viewModels->require(HeroiconsOutline::class); | ||
?> | ||
|
||
<div x-data="BadgeWidget_<?= $uniqId ?>"> | ||
<section data-element="kiyoh-badge-widget-<?= $uniqId; ?>" | ||
@click="show = !show" | ||
class="inline-grid gap-2 px-3 py-4 bg-white border border-gray-200 shadow rounded-xl | ||
group <?= !$block->showReviewLink() ? 'cursor-default': 'cursor-pointer' ?>"> | ||
|
||
<?php if ($block->showLogo() || $block->showStars()): ?> | ||
<div data-element="box-summary" | ||
class="flex items-center gap-7 | ||
<?= $block->showLogo() && $block->showStars() ? 'justify-between' : 'justify-center'; ?>"> | ||
|
||
<?php if ($block->showLogo()): ?> | ||
<span class="flex items-center gap-2 text-lg font-semibold"> | ||
<img src="<?= $block->escapeUrl($block->getLogoUrl()); ?>" width="32" height="32" | ||
alt="<?= $block->escapeHtml(__('Kiyoh badge widget')); ?>" /> | ||
<span class="text-gray-600">kiyoh</span> | ||
</span> | ||
<?php endif; ?> | ||
|
||
<?php if ($block->showStars()): ?> | ||
<?= $block->getLayout() | ||
->createBlock('Magento\Framework\View\Element\Template') | ||
->setTemplate('Magmodules_HyvaKiyOhSR::widget/helper/stars.phtml') | ||
->setData('svgSize', '22') | ||
->setData('percent', $reviewsAvgRating * 10) | ||
->toHtml(); | ||
?> | ||
<?php endif;?> | ||
</div> | ||
<?php endif;?> | ||
|
||
<div data-element="box-information" | ||
class="flex gap-5 text-sm <?= $block->showReviewLink() ? 'justify-between': 'justify-center' ?>"> | ||
<div> | ||
<b><?= $block->escapeHtml($reviewsAvgScore); ?></b> | ||
<?= $block->escapeHtml(__('based on')); ?> | ||
<b> | ||
<?= $block->escapeHtml($reviewsCount); ?> | ||
<?= $reviewsCount > 1 | ||
? $block->escapeHtml(__('reviews')) | ||
: $block->escapeHtml(__('review')); ?> | ||
</b> | ||
</div> | ||
|
||
<?php if ($block->showReviewLink()): ?> | ||
<span data-element="link-icon" class="h-5 text-blue-500 transition-colors duration-300 group-hover:text-blue-700"> | ||
<?= $heroicons->externalLinkHtml('', 20, 20, ["style" => "stroke-width: 1.5"]); ?> | ||
</span> | ||
<?php endif;?> | ||
</div> | ||
</section> | ||
|
||
<?php if ($block->showReviewLink()): ?> | ||
<div data-element="kiyoh-badge-reviews-<?= $uniqId; ?>" | ||
class="fixed z-50 w-[90%] duration-300 | ||
<?= $block->getShowReviews() == 'popup' | ||
? 'top-1/2 left-1/2 max-w-[480px] max-h-[90vh] transition-opacity | ||
-translate-x-1/2 -translate-y-1/2 [&>div]:max-h-[90vh] [&>div]:rounded-xl' | ||
: 'top-0 right-0 h-screen max-w-[400px] [&>div]:max-h-screen transition-transform' ?>" | ||
|
||
style="display: none;" | ||
x-show="show" | ||
x-transition:enter="ease-in-out duration-300" | ||
x-transition:enter-start="<?= $block->getShowReviews() == 'popup' ? 'opacity-0 invisible' : 'translate-x-[105%]'; ?>" | ||
x-transition:enter-end="<?= $block->getShowReviews() == 'popup' ? 'opacity-100 visible' : 'translate-x-0'; ?>" | ||
x-transition:leave="ease-in-out duration-300" | ||
x-transition:leave-start="<?= $block->getShowReviews() == 'popup' ? 'opacity-100 visible' : 'translate-x-0'; ?>" | ||
x-transition:leave-end="<?= $block->getShowReviews() == 'popup' ? 'opacity-0 invisible' : 'translate-x-[105%]'; ?>"> | ||
|
||
<div class="grid grid-rows-[auto_1fr] bg-white border border-gray-200"> | ||
<div data-element="reviews-summary" | ||
class="relative grid grid-cols-[60px_1fr] gap-4 p-4 border-b border-gray-200"> | ||
|
||
<img src="<?= $block->escapeUrl($block->getLogoUrl()); ?>" width="60" height="60" | ||
alt="<?= $block->escapeHtml(__('Kiyoh badge widget')); ?>" /> | ||
|
||
<div> | ||
<div data-element="reviews-summary-stars" class="-ml-1.5"> | ||
<?= $block->getLayout() | ||
->createBlock('Magento\Framework\View\Element\Template') | ||
->setTemplate('Magmodules_HyvaKiyOhSR::widget/helper/stars.phtml') | ||
->setData('svgSize', '30') | ||
->setData('percent', $reviewsAvgRating * 10) | ||
->toHtml(); | ||
?> | ||
</div> | ||
|
||
<div data-element="reviews-summary-text" class="text-gray-700 text-sm"> | ||
<?= $block->escapeHtml(__('Rated with')); ?> | ||
<b class="text-[#ffad0f]"><?= $block->escapeHtml($reviewsAvgScore); ?></b> | ||
<?= $block->escapeHtml(__('based on')); ?> | ||
<b class="text-[#ffad0f]"> | ||
<?= $block->escapeHtml($reviewsCount); ?> | ||
<?= $reviewsCount > 1 | ||
? $block->escapeHtml(__('reviews')) | ||
: $block->escapeHtml(__('review')); ?> | ||
</b> | ||
</div> | ||
</div> | ||
|
||
<span data-element="close" @click="show = !show" | ||
class="absolute top-3 right-3 opacity-50 cursor-pointer | ||
transition-opacity hover:opacity-100"> | ||
<?= $heroicons->xHtml('', 24, 24); ?> | ||
</span> | ||
</div> | ||
|
||
<div data-element="reviews" class="h-full overflow-auto max-h-[calc(100%-10px)]"> | ||
<?php foreach ($reviews = $block->getReviews() as $review): ?> | ||
<div data-element="review-item" | ||
class="grid gap-2.5 p-5 border-b border-gray-200 last:border-b-0"> | ||
|
||
<b class="name text-base"><?= $block->escapeHtml($review['name']) ?></b> | ||
<div class="summary flex gap-3 -ml-0.5"> | ||
<?= $block->getLayout() | ||
->createBlock('Magento\Framework\View\Element\Template') | ||
->setTemplate('Magmodules_HyvaKiyOhSR::widget/helper/stars.phtml') | ||
->setData('svgSize', '18') | ||
->setData('percent', floatval($review['total']) * 10) | ||
->toHtml(); | ||
?> | ||
|
||
<span class="opacity-60 text-sm"><?= $block->escapeHtml($review['created']) ?></span> | ||
</div> | ||
<div class="comment text-sm leading-6"> | ||
<b class="block text-gray-700 mb-1"><?= $block->escapeHtml($review['default_oneliner']['rating']) ?></b> | ||
<span class="text-gray-500"><?= $block->escapeHtml($review['default_opinion']['rating']) ?></span> | ||
</div> | ||
</div> | ||
<?php endforeach;?> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<span data-element="kiyoh-badge-overlay-<?= $uniqId; ?>" | ||
@click="show = !show" | ||
class="fixed top-0 right-0 bottom-0 left-0 z-40 bg-black/40" | ||
style="display: none;" | ||
x-show="show" | ||
x-transition:enter="ease-in-out duration-300" | ||
x-transition:enter-start="opacity-0 invisible" | ||
x-transition:enter-end="opacity-100 visible" | ||
x-transition:leave="ease-in-out duration-300" | ||
x-transition:leave-start="opacity-100 visible" | ||
x-transition:leave-end="opacity-0 invisible"></span> | ||
<?php endif;?> | ||
</div> | ||
|
||
<script> | ||
'use strict'; | ||
|
||
function BadgeWidget_<?= $uniqId ?>() { | ||
return { | ||
show: false, | ||
} | ||
} | ||
</script> |
Oops, something went wrong.