init
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0"?>
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
|
||||
<head>
|
||||
<css src="Esun_InteractiveCards::css/cards.css"/>
|
||||
<css src="Esun_InteractiveCards::css/product-cards.css"/>
|
||||
</head>
|
||||
</page>
|
||||
@@ -0,0 +1,546 @@
|
||||
.esun-interactive-cards {
|
||||
--esun-card-gap: 16px;
|
||||
--esun-card-height: 400px;
|
||||
--esun-card-width: 360px;
|
||||
--esun-active-width: 680px;
|
||||
--esun-side-width: 220px;
|
||||
--esun-green: #19ad61;
|
||||
width: 100%;
|
||||
padding: 24px 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.esun-interactive-cards *,
|
||||
.esun-interactive-cards *::before,
|
||||
.esun-interactive-cards *::after {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.esun-interactive-cards__viewport {
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.esun-interactive-cards__track {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: stretch;
|
||||
gap: var(--esun-card-gap);
|
||||
width: 100%;
|
||||
transition: transform 0.55s cubic-bezier(0.22, 0.61, 0.36, 1);
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
.esun-interactive-cards.is-carousel .esun-interactive-cards__track {
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
.esun-interactive-cards__track.is-resizing {
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.esun-interactive-card {
|
||||
position: relative;
|
||||
flex: 0 0 var(--esun-card-width);
|
||||
width: var(--esun-card-width);
|
||||
height: var(--esun-card-height);
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
border-radius: 16px;
|
||||
background: #e5e8e7;
|
||||
cursor: pointer;
|
||||
isolation: isolate;
|
||||
transition:
|
||||
flex-basis 0.48s cubic-bezier(0.22, 0.61, 0.36, 1),
|
||||
width 0.48s cubic-bezier(0.22, 0.61, 0.36, 1),
|
||||
opacity 0.35s ease,
|
||||
filter 0.35s ease,
|
||||
box-shadow 0.35s ease;
|
||||
}
|
||||
|
||||
.esun-interactive-card:focus-visible {
|
||||
outline: 3px solid var(--esun-green);
|
||||
outline-offset: 3px;
|
||||
}
|
||||
|
||||
.esun-interactive-card__picture,
|
||||
.esun-interactive-card__image {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.esun-interactive-card__image {
|
||||
object-fit: cover;
|
||||
object-position: center;
|
||||
transition: transform 0.6s cubic-bezier(0.22, 0.61, 0.36, 1);
|
||||
}
|
||||
|
||||
.esun-interactive-card__shade {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 1;
|
||||
background: rgba(20, 24, 23, 0.48);
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition:
|
||||
opacity 0.35s ease,
|
||||
background 0.35s ease;
|
||||
}
|
||||
|
||||
.esun-interactive-card__content {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 2;
|
||||
color: #fff;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.esun-interactive-card__title {
|
||||
position: absolute;
|
||||
left: 26px;
|
||||
right: 26px;
|
||||
top: 50%;
|
||||
margin: 0;
|
||||
color: #fff;
|
||||
font-size: clamp(15px, 1.15vw, 20px);
|
||||
font-weight: 700;
|
||||
line-height: 1.35;
|
||||
letter-spacing: 0;
|
||||
text-align: center;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transform: translateY(calc(-50% + 18px));
|
||||
transition:
|
||||
opacity 0.35s ease,
|
||||
visibility 0.35s ease,
|
||||
transform 0.42s cubic-bezier(0.22, 0.61, 0.36, 1),
|
||||
inset 0.42s ease;
|
||||
}
|
||||
|
||||
.esun-interactive-card__description {
|
||||
position: absolute;
|
||||
left: 30px;
|
||||
bottom: 28px;
|
||||
width: calc(52% - 44px);
|
||||
max-height: 108px;
|
||||
overflow: hidden;
|
||||
color: #fff;
|
||||
font-size: 14px;
|
||||
line-height: 1.55;
|
||||
letter-spacing: 0;
|
||||
white-space: pre-line;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transform: translateY(16px);
|
||||
transition:
|
||||
opacity 0.35s ease 0.08s,
|
||||
visibility 0.35s ease 0.08s,
|
||||
transform 0.42s ease 0.08s;
|
||||
}
|
||||
|
||||
@media (hover: hover) {
|
||||
.esun-interactive-cards.has-hover:not(.has-active)
|
||||
.esun-interactive-card:hover
|
||||
.esun-interactive-card__shade {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.esun-interactive-cards.has-hover:not(.has-active)
|
||||
.esun-interactive-card:hover
|
||||
.esun-interactive-card__image {
|
||||
transform: scale(1.035);
|
||||
}
|
||||
|
||||
.esun-interactive-cards.has-hover:not(.has-active)
|
||||
.esun-interactive-card:hover
|
||||
.esun-interactive-card__title {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
}
|
||||
|
||||
/* Side-pull applies only to the active carousel window or active grid row. */
|
||||
.esun-interactive-cards.has-active
|
||||
.esun-interactive-card:is(.is-active-window, .is-active-row).is-active {
|
||||
flex-basis: var(--esun-active-width);
|
||||
width: var(--esun-active-width);
|
||||
opacity: 1;
|
||||
filter: none;
|
||||
cursor: default;
|
||||
box-shadow: 0 14px 34px rgba(0, 0, 0, 0.18);
|
||||
}
|
||||
|
||||
.esun-interactive-cards.has-active
|
||||
.esun-interactive-card:is(.is-active-window, .is-active-row):not(
|
||||
.is-active
|
||||
) {
|
||||
flex-basis: var(--esun-side-width);
|
||||
width: var(--esun-side-width);
|
||||
opacity: 0.82;
|
||||
filter: saturate(0.72);
|
||||
}
|
||||
|
||||
.esun-interactive-cards.is-carousel.has-active
|
||||
.esun-interactive-card.is-outside-window {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.esun-interactive-cards.is-carousel.has-active .esun-interactive-cards__track {
|
||||
transform: translate3d(0, 0, 0) !important;
|
||||
}
|
||||
|
||||
.esun-interactive-cards.has-active
|
||||
.esun-interactive-card.is-active
|
||||
.esun-interactive-card__shade {
|
||||
opacity: 1;
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
rgba(13, 18, 16, 0.82) 0%,
|
||||
rgba(13, 18, 16, 0.58) 46%,
|
||||
rgba(13, 18, 16, 0.2) 100%
|
||||
);
|
||||
}
|
||||
|
||||
.esun-interactive-cards.has-active
|
||||
.esun-interactive-card.is-active
|
||||
.esun-interactive-card__content {
|
||||
right: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
width: 52%;
|
||||
padding: 30px;
|
||||
}
|
||||
|
||||
.esun-interactive-cards.has-active
|
||||
.esun-interactive-card.is-active
|
||||
.esun-interactive-card__title {
|
||||
position: static;
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
text-align: left;
|
||||
transform: none;
|
||||
}
|
||||
|
||||
.esun-interactive-cards.has-active
|
||||
.esun-interactive-card.is-active
|
||||
.esun-interactive-card__description {
|
||||
position: static;
|
||||
width: 100%;
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.esun-interactive-cards.has-active
|
||||
.esun-interactive-card.is-active
|
||||
.esun-interactive-card__description
|
||||
> :first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.esun-interactive-cards.has-active
|
||||
.esun-interactive-card.is-active
|
||||
.esun-interactive-card__description
|
||||
> :last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.esun-interactive-card__product {
|
||||
position: absolute;
|
||||
right: 24px;
|
||||
bottom: 24px;
|
||||
z-index: 3;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(90px, 42%) minmax(0, 1fr);
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
width: min(44%, 490px);
|
||||
min-height: 126px;
|
||||
padding: 12px;
|
||||
overflow: hidden;
|
||||
border: 1px solid rgba(25, 173, 97, 0.95);
|
||||
border-radius: 14px;
|
||||
color: #fff;
|
||||
background: rgba(14, 18, 16, 0.68);
|
||||
backdrop-filter: blur(10px);
|
||||
-webkit-backdrop-filter: blur(10px);
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transform: translateX(22px);
|
||||
pointer-events: none;
|
||||
transition:
|
||||
opacity 0.35s ease 0.12s,
|
||||
visibility 0.35s ease 0.12s,
|
||||
transform 0.42s ease 0.12s;
|
||||
}
|
||||
|
||||
.esun-interactive-card__product:empty {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.esun-interactive-cards.has-active
|
||||
.esun-interactive-card.is-active
|
||||
.esun-interactive-card__product:not(:empty) {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
transform: translateX(0);
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.esun-interactive-card__product.is-loading::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
margin: -12px 0 0 -12px;
|
||||
border: 2px solid rgba(255, 255, 255, 0.35);
|
||||
border-top-color: #fff;
|
||||
border-radius: 50%;
|
||||
animation: esun-interactive-spin 0.8s linear infinite;
|
||||
}
|
||||
|
||||
.esun-interactive-product__image {
|
||||
display: block;
|
||||
height: 100px;
|
||||
overflow: hidden;
|
||||
border-radius: 8px;
|
||||
background: #101312;
|
||||
}
|
||||
|
||||
.esun-interactive-product__image img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.esun-interactive-product__details {
|
||||
min-width: 0;
|
||||
padding-right: 40px;
|
||||
}
|
||||
|
||||
.esun-interactive-product__name {
|
||||
display: -webkit-box;
|
||||
overflow: hidden;
|
||||
color: #fff !important;
|
||||
font-size: 14px;
|
||||
line-height: 1.35;
|
||||
text-decoration: none;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
}
|
||||
|
||||
.esun-interactive-product__prices {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
margin-top: 8px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.esun-interactive-product__prices del {
|
||||
color: rgba(255, 255, 255, 0.46);
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.esun-interactive-product__form {
|
||||
position: absolute;
|
||||
right: 12px;
|
||||
bottom: 12px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.esun-interactive-product__cart {
|
||||
display: block;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
min-width: 36px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 50%;
|
||||
background-color: var(--esun-green);
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='20' r='1'/%3E%3Ccircle cx='19' cy='20' r='1'/%3E%3Cpath d='M3 4h2l2.4 10.4a2 2 0 0 0 2 1.6h7.7a2 2 0 0 0 2-1.6L21 8H6'/%3E%3C/svg%3E");
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
transform 0.25s ease,
|
||||
background-color 0.25s ease;
|
||||
}
|
||||
|
||||
.esun-interactive-product__cart--link {
|
||||
position: absolute;
|
||||
right: 12px;
|
||||
bottom: 12px;
|
||||
}
|
||||
|
||||
.esun-interactive-product__cart:hover {
|
||||
background-color: #0b8c4d;
|
||||
transform: scale(1.08);
|
||||
}
|
||||
|
||||
.esun-interactive-card__product.has-error {
|
||||
display: flex;
|
||||
grid-template-columns: none;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: rgba(255, 255, 255, 0.78);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.esun-interactive-cards__controls {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
justify-content: center;
|
||||
gap: 18px;
|
||||
min-height: 42px;
|
||||
margin-top: 28px;
|
||||
}
|
||||
|
||||
.esun-interactive-cards__arrow {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
color: var(--esun-green);
|
||||
background: transparent;
|
||||
font-size: 34px;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.esun-interactive-cards__arrow:disabled {
|
||||
opacity: 0.3;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.esun-interactive-cards__dots {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
min-width: 120px;
|
||||
}
|
||||
|
||||
.esun-interactive-cards__dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
min-width: 8px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 50%;
|
||||
background: #d2e9dc;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
width 0.25s ease,
|
||||
border-radius 0.25s ease,
|
||||
background 0.25s ease;
|
||||
}
|
||||
|
||||
.esun-interactive-cards__dot.is-current {
|
||||
width: 32px;
|
||||
border-radius: 8px;
|
||||
background: var(--esun-green);
|
||||
}
|
||||
|
||||
@keyframes esun-interactive-spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
.esun-interactive-card__description {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.esun-interactive-card__product {
|
||||
width: 45%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.esun-interactive-cards {
|
||||
--esun-card-height: 390px !important;
|
||||
padding: 18px 0;
|
||||
}
|
||||
|
||||
.esun-interactive-cards.has-active
|
||||
.esun-interactive-card:is(.is-active-window, .is-active-row):not(
|
||||
.is-active
|
||||
) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.esun-interactive-cards.has-active
|
||||
.esun-interactive-card:is(.is-active-window, .is-active-row).is-active {
|
||||
flex-basis: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.esun-interactive-cards.has-active
|
||||
.esun-interactive-card.is-active
|
||||
.esun-interactive-card__content {
|
||||
width: 100%;
|
||||
padding: 20px 20px 92px;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.esun-interactive-card__description {
|
||||
max-height: 66px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.esun-interactive-card__product {
|
||||
left: 16px;
|
||||
right: 16px;
|
||||
bottom: 14px;
|
||||
grid-template-columns: 58px minmax(0, 1fr);
|
||||
width: auto;
|
||||
min-height: 66px;
|
||||
padding: 7px;
|
||||
}
|
||||
|
||||
.esun-interactive-product__image {
|
||||
height: 58px;
|
||||
}
|
||||
|
||||
.esun-interactive-product__details {
|
||||
padding-right: 38px;
|
||||
}
|
||||
|
||||
.esun-interactive-product__name {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.esun-interactive-product__form,
|
||||
.esun-interactive-product__cart--link {
|
||||
right: 8px;
|
||||
bottom: 15px;
|
||||
}
|
||||
|
||||
.esun-interactive-cards__controls {
|
||||
margin-top: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.esun-interactive-cards *,
|
||||
.esun-interactive-cards *::before,
|
||||
.esun-interactive-cards *::after {
|
||||
scroll-behavior: auto !important;
|
||||
transition-duration: 0.01ms !important;
|
||||
animation-duration: 0.01ms !important;
|
||||
animation-iteration-count: 1 !important;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
.esun-product-cards {
|
||||
--esun-product-columns: 3;
|
||||
--esun-product-tablet-columns: 2;
|
||||
--esun-product-mobile-columns: 1;
|
||||
--esun-product-gap: 28px;
|
||||
--esun-product-green: #19ad61;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.esun-product-cards *,
|
||||
.esun-product-cards *::before,
|
||||
.esun-product-cards *::after {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.esun-product-cards__grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(var(--esun-product-columns), minmax(0, 1fr));
|
||||
gap: var(--esun-product-gap);
|
||||
}
|
||||
|
||||
.esun-product-cards .esun-product-card {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
min-height: 100%;
|
||||
padding: 24px;
|
||||
overflow: hidden;
|
||||
border: 1px solid #d9ebe1;
|
||||
border-radius: 34px;
|
||||
background: #fff;
|
||||
box-shadow: 0 1px 1px rgba(28, 64, 46, 0.08);
|
||||
}
|
||||
|
||||
.esun-product-card__media {
|
||||
display: block;
|
||||
width: 100%;
|
||||
aspect-ratio: 1.4 / 1;
|
||||
overflow: hidden;
|
||||
border-radius: 28px;
|
||||
}
|
||||
|
||||
.esun-product-card__image {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: contain;
|
||||
transition: transform 0.4s ease;
|
||||
}
|
||||
|
||||
.esun-product-card__body {
|
||||
display: flex;
|
||||
flex: 1 1 auto;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
padding-top: 28px;
|
||||
}
|
||||
|
||||
.esun-product-card__title {
|
||||
color: #161916 !important;
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
line-height: 1.35;
|
||||
letter-spacing: 0;
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
.esun-product-card__tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 9px 10px;
|
||||
width: 100%;
|
||||
margin-top: 14px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.esun-product-card__tags span {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-height: 34px;
|
||||
padding: 5px 16px;
|
||||
border: 1px solid #d9ebe1;
|
||||
border-radius: 18px;
|
||||
color: #3e4540;
|
||||
background: #fff;
|
||||
font-size: 15px;
|
||||
line-height: 1.2;
|
||||
letter-spacing: 0;
|
||||
}
|
||||
|
||||
.esun-product-card__link {
|
||||
align-self: flex-end;
|
||||
min-width: 164px;
|
||||
margin-top: auto;
|
||||
padding: 13px 24px;
|
||||
border-radius: 24px;
|
||||
color: #fff !important;
|
||||
background: var(--esun-product-green);
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
line-height: 1.2;
|
||||
letter-spacing: 2px;
|
||||
text-align: center;
|
||||
text-decoration: none !important;
|
||||
transition:
|
||||
background-color 0.25s ease,
|
||||
transform 0.25s ease;
|
||||
}
|
||||
|
||||
.esun-product-card__status {
|
||||
display: none;
|
||||
padding: 32px 12px;
|
||||
color: #777;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.esun-product-card.is-loading::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 36%;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
margin: -15px 0 0 -15px;
|
||||
border: 3px solid rgba(25, 173, 97, 0.2);
|
||||
border-top-color: var(--esun-product-green);
|
||||
border-radius: 50%;
|
||||
animation: esun-product-card-spin 0.8s linear infinite;
|
||||
}
|
||||
|
||||
.esun-product-card.is-loading .esun-product-card__body,
|
||||
.esun-product-card.is-loading .esun-product-card__image {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.esun-product-card.has-error .esun-product-card__media,
|
||||
.esun-product-card.has-error .esun-product-card__body {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.esun-product-card.has-error .esun-product-card__status {
|
||||
display: block;
|
||||
}
|
||||
|
||||
@media (hover: hover) {
|
||||
.esun-product-card:hover .esun-product-card__image {
|
||||
transform: scale(1.035);
|
||||
}
|
||||
|
||||
.esun-product-card__link:hover {
|
||||
background: #0c914f;
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
.esun-product-cards__grid {
|
||||
grid-template-columns: repeat(
|
||||
var(--esun-product-tablet-columns),
|
||||
minmax(0, 1fr)
|
||||
);
|
||||
}
|
||||
|
||||
.esun-product-card {
|
||||
padding: 18px;
|
||||
border-radius: 26px;
|
||||
}
|
||||
|
||||
.esun-product-card__media {
|
||||
border-radius: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.esun-product-cards__grid {
|
||||
grid-template-columns: repeat(
|
||||
var(--esun-product-mobile-columns),
|
||||
minmax(0, 1fr)
|
||||
);
|
||||
}
|
||||
|
||||
.esun-product-card {
|
||||
padding: 0;
|
||||
border-radius: 20px;
|
||||
}
|
||||
.navigation .esun-product-card a{padding-left: 0;}
|
||||
|
||||
.esun-product-card__media {
|
||||
border-radius: 16px;
|
||||
}
|
||||
|
||||
.esun-product-card__body {
|
||||
padding-top: 18px;
|
||||
}
|
||||
|
||||
.esun-product-card__title {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.esun-product-card__tags {
|
||||
gap: 7px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.esun-product-card__tags span {
|
||||
min-height: 28px;
|
||||
padding: 4px 10px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.esun-product-card__link {
|
||||
align-self: stretch;
|
||||
min-width: 0;
|
||||
margin-top: 18px;
|
||||
padding: 11px 14px;
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes esun-product-card-spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.esun-product-card__image,
|
||||
.esun-product-card__link {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,378 @@
|
||||
define([
|
||||
'jquery',
|
||||
'mage/translate',
|
||||
'mage/url',
|
||||
'mage/cookies',
|
||||
'Magento_Catalog/js/catalog-add-to-cart'
|
||||
], function ($, $t, urlBuilder) {
|
||||
'use strict';
|
||||
|
||||
function boolValue(value, fallback) {
|
||||
if (value === undefined || value === null || value === '') {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
return String(value) === 'true' || String(value) === '1';
|
||||
}
|
||||
|
||||
function numberValue(value, fallback) {
|
||||
var parsed = parseInt(value, 10);
|
||||
|
||||
return Number.isFinite(parsed) ? parsed : fallback;
|
||||
}
|
||||
|
||||
function initialize(config, element) {
|
||||
var $root = $(element);
|
||||
var $viewport = $root.find('.esun-interactive-cards__viewport').first();
|
||||
var $track = $root.find('.esun-interactive-cards__track').first();
|
||||
var $cards = $track.children('.esun-interactive-card');
|
||||
var $controls = $root.find('.esun-interactive-cards__controls').first();
|
||||
var $prev = $controls.find('.esun-interactive-cards__arrow--prev');
|
||||
var $next = $controls.find('.esun-interactive-cards__arrow--next');
|
||||
var $dots = $controls.find('.esun-interactive-cards__dots');
|
||||
var desktopColumns = numberValue($root.attr('data-desktop-columns'), 3);
|
||||
var tabletColumns = numberValue($root.attr('data-tablet-columns'), 2);
|
||||
var gap = Math.max(0, numberValue($root.attr('data-card-gap'), 16));
|
||||
var cardHeight = Math.max(220, numberValue($root.attr('data-card-height'), 400));
|
||||
var carouselEnabled = boolValue($root.attr('data-enable-carousel'), true);
|
||||
var hoverEnabled = boolValue($root.attr('data-enable-hover'), true);
|
||||
var sidePullEnabled = boolValue($root.attr('data-enable-side-pull'), true);
|
||||
var showArrows = boolValue($root.attr('data-show-arrows'), true);
|
||||
var showDots = boolValue($root.attr('data-show-dots'), true);
|
||||
var autoplay = boolValue($root.attr('data-autoplay'), false);
|
||||
var autoplaySpeed = Math.max(1500, numberValue($root.attr('data-autoplay-speed'), 5000));
|
||||
var currentIndex = 0;
|
||||
var resizeTimer;
|
||||
var autoplayTimer;
|
||||
var touchStartX = 0;
|
||||
|
||||
if (!$cards.length || $root.data('esun-interactive-ready')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$root.data('esun-interactive-ready', true);
|
||||
$root.toggleClass('has-hover', hoverEnabled);
|
||||
$root.toggleClass('has-side-pull', sidePullEnabled);
|
||||
$root.toggleClass('is-carousel', carouselEnabled);
|
||||
$root.toggleClass('is-grid', !carouselEnabled);
|
||||
$root.css({
|
||||
'--esun-card-gap': gap + 'px',
|
||||
'--esun-card-height': cardHeight + 'px'
|
||||
});
|
||||
|
||||
function perView() {
|
||||
if (window.matchMedia('(max-width: 767px)').matches) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (window.matchMedia('(max-width: 1024px)').matches) {
|
||||
return Math.max(1, Math.min(3, tabletColumns));
|
||||
}
|
||||
|
||||
return Math.max(2, Math.min(4, desktopColumns));
|
||||
}
|
||||
|
||||
function maximumIndex() {
|
||||
return Math.max(0, $cards.length - perView());
|
||||
}
|
||||
|
||||
function setCardWidths() {
|
||||
var columns = perView();
|
||||
var viewportWidth = $viewport.innerWidth();
|
||||
var availableWidth = viewportWidth - gap * (columns - 1);
|
||||
var normalWidth = availableWidth / columns;
|
||||
var activeRatio = columns === 2 ? 0.7 : (columns === 3 ? 0.6 : 0.55);
|
||||
var activeWidth = availableWidth * activeRatio;
|
||||
var sideWidth = columns > 1
|
||||
? (availableWidth - activeWidth) / (columns - 1)
|
||||
: availableWidth;
|
||||
|
||||
$root.css({
|
||||
'--esun-card-width': normalWidth + 'px',
|
||||
'--esun-active-width': activeWidth + 'px',
|
||||
'--esun-side-width': sideWidth + 'px'
|
||||
});
|
||||
|
||||
return normalWidth;
|
||||
}
|
||||
|
||||
function clearCardState() {
|
||||
$root.removeClass('has-active');
|
||||
$cards
|
||||
.removeClass('is-active is-active-row is-active-window is-outside-window')
|
||||
.attr('aria-expanded', 'false');
|
||||
}
|
||||
|
||||
function getWindowStart(activeIndex) {
|
||||
var columns = perView();
|
||||
|
||||
if (carouselEnabled) {
|
||||
return Math.min(currentIndex, Math.max(0, $cards.length - columns));
|
||||
}
|
||||
|
||||
return Math.floor(activeIndex / columns) * columns;
|
||||
}
|
||||
|
||||
function openCard($card) {
|
||||
var activeIndex = $cards.index($card);
|
||||
var columns = perView();
|
||||
var start = getWindowStart(activeIndex);
|
||||
var end = Math.min(start + columns, $cards.length);
|
||||
|
||||
clearCardState();
|
||||
$root.addClass('has-active');
|
||||
$card.addClass('is-active').attr('aria-expanded', 'true');
|
||||
|
||||
$cards.each(function (index) {
|
||||
var inWindow = index >= start && index < end;
|
||||
|
||||
$(this)
|
||||
.toggleClass(carouselEnabled ? 'is-active-window' : 'is-active-row', inWindow)
|
||||
.toggleClass('is-outside-window', carouselEnabled && !inWindow);
|
||||
});
|
||||
|
||||
stopAutoplay();
|
||||
loadProduct($card);
|
||||
}
|
||||
|
||||
function renderProduct($panel, product) {
|
||||
var $imageLink = $('<a>', {
|
||||
class: 'esun-interactive-product__image',
|
||||
href: product.url,
|
||||
'aria-label': product.name
|
||||
}).append($('<img>', {src: product.image, alt: product.name}));
|
||||
var $details = $('<div>', {class: 'esun-interactive-product__details'});
|
||||
var $name = $('<a>', {
|
||||
class: 'esun-interactive-product__name',
|
||||
href: product.url,
|
||||
text: product.name
|
||||
});
|
||||
var $prices = $('<div>', {class: 'esun-interactive-product__prices'})
|
||||
.append($('<strong>', {text: product.price}));
|
||||
|
||||
if (product.old_price) {
|
||||
$prices.append($('<del>', {text: product.old_price}));
|
||||
}
|
||||
|
||||
$details.append($name, $prices);
|
||||
|
||||
if (product.can_add_to_cart) {
|
||||
var $form = $('<form>', {
|
||||
class: 'esun-interactive-product__form',
|
||||
action: product.add_url,
|
||||
method: 'post'
|
||||
});
|
||||
|
||||
$form.append(
|
||||
$('<input>', {type: 'hidden', name: 'product', value: product.id}),
|
||||
$('<input>', {
|
||||
type: 'hidden',
|
||||
name: 'form_key',
|
||||
value: $.mage.cookies.get('form_key')
|
||||
}),
|
||||
$('<button>', {
|
||||
type: 'submit',
|
||||
class: 'esun-interactive-product__cart',
|
||||
'aria-label': $t('Add %1 to cart').replace('%1', product.name)
|
||||
})
|
||||
);
|
||||
$panel.append($form);
|
||||
$form.catalogAddToCart();
|
||||
} else {
|
||||
$panel.append($('<a>', {
|
||||
class: 'esun-interactive-product__cart esun-interactive-product__cart--link',
|
||||
href: product.url,
|
||||
'aria-label': $t('View %1').replace('%1', product.name)
|
||||
}));
|
||||
}
|
||||
|
||||
$panel.prepend($imageLink, $details).addClass('is-loaded');
|
||||
}
|
||||
|
||||
function loadProduct($card) {
|
||||
var sku = $.trim($card.attr('data-product-sku') || '');
|
||||
var $panel = $card.find('.esun-interactive-card__product').first();
|
||||
|
||||
if (!sku || $panel.data('loaded') || $panel.data('loading')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$panel.data('loading', true).addClass('is-loading');
|
||||
|
||||
$.getJSON(urlBuilder.build('esuninteractivecards/product/view'), {sku: sku})
|
||||
.done(function (response) {
|
||||
if (response.success && response.product) {
|
||||
renderProduct($panel.empty(), response.product);
|
||||
$panel.data('loaded', true);
|
||||
} else {
|
||||
$panel.addClass('has-error').text(response.message || $t('Product unavailable.'));
|
||||
}
|
||||
})
|
||||
.fail(function () {
|
||||
$panel.addClass('has-error').text($t('Product unavailable.'));
|
||||
})
|
||||
.always(function () {
|
||||
$panel.data('loading', false).removeClass('is-loading');
|
||||
});
|
||||
}
|
||||
|
||||
function buildDots() {
|
||||
var count = maximumIndex() + 1;
|
||||
|
||||
$dots.empty();
|
||||
|
||||
if (!carouselEnabled || !showDots || count <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var index = 0; index < count; index++) {
|
||||
$('<button>', {
|
||||
type: 'button',
|
||||
class: 'esun-interactive-cards__dot',
|
||||
'data-index': index,
|
||||
'aria-label': $t('Go to card group %1').replace('%1', index + 1)
|
||||
}).appendTo($dots);
|
||||
}
|
||||
}
|
||||
|
||||
function renderCarousel(animate) {
|
||||
var normalWidth;
|
||||
var maximumOffset;
|
||||
var offset;
|
||||
|
||||
normalWidth = setCardWidths();
|
||||
|
||||
if (!carouselEnabled) {
|
||||
$track.css('transform', '');
|
||||
return;
|
||||
}
|
||||
|
||||
currentIndex = Math.max(0, Math.min(currentIndex, maximumIndex()));
|
||||
maximumOffset = maximumIndex() * (normalWidth + gap);
|
||||
offset = Math.min(currentIndex * (normalWidth + gap), maximumOffset);
|
||||
|
||||
if (!animate) {
|
||||
$track.addClass('is-resizing');
|
||||
}
|
||||
|
||||
$track.css('transform', 'translate3d(' + (-offset) + 'px,0,0)');
|
||||
$prev.prop('disabled', currentIndex === 0);
|
||||
$next.prop('disabled', currentIndex === maximumIndex());
|
||||
$dots.children().removeClass('is-current').eq(currentIndex).addClass('is-current');
|
||||
|
||||
if (!animate) {
|
||||
window.requestAnimationFrame(function () {
|
||||
$track.removeClass('is-resizing');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function goTo(index) {
|
||||
clearCardState();
|
||||
currentIndex = Math.max(0, Math.min(index, maximumIndex()));
|
||||
renderCarousel(true);
|
||||
startAutoplay();
|
||||
}
|
||||
|
||||
function stopAutoplay() {
|
||||
window.clearInterval(autoplayTimer);
|
||||
}
|
||||
|
||||
function startAutoplay() {
|
||||
stopAutoplay();
|
||||
|
||||
if (!carouselEnabled || !autoplay || maximumIndex() === 0 || $root.hasClass('has-active')) {
|
||||
return;
|
||||
}
|
||||
|
||||
autoplayTimer = window.setInterval(function () {
|
||||
goTo(currentIndex >= maximumIndex() ? 0 : currentIndex + 1);
|
||||
}, autoplaySpeed);
|
||||
}
|
||||
|
||||
$cards.on('click.esunInteractiveCards', function (event) {
|
||||
var $card = $(this);
|
||||
|
||||
if ($(event.target).closest('a, button, form').length) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sidePullEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($card.hasClass('is-active')) {
|
||||
clearCardState();
|
||||
renderCarousel(true);
|
||||
startAutoplay();
|
||||
} else {
|
||||
openCard($card);
|
||||
}
|
||||
});
|
||||
|
||||
$cards.on('keydown.esunInteractiveCards', function (event) {
|
||||
if (event.key !== 'Enter' && event.key !== ' ') {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
$(this).trigger('click');
|
||||
});
|
||||
|
||||
$prev.on('click.esunInteractiveCards', function () {
|
||||
goTo(currentIndex - 1);
|
||||
});
|
||||
|
||||
$next.on('click.esunInteractiveCards', function () {
|
||||
goTo(currentIndex + 1);
|
||||
});
|
||||
|
||||
$dots.on('click.esunInteractiveCards', '.esun-interactive-cards__dot', function () {
|
||||
goTo(numberValue($(this).attr('data-index'), 0));
|
||||
});
|
||||
|
||||
$viewport.on('touchstart.esunInteractiveCards', function (event) {
|
||||
touchStartX = event.originalEvent.touches[0].clientX;
|
||||
});
|
||||
|
||||
$viewport.on('touchend.esunInteractiveCards', function (event) {
|
||||
var endX = event.originalEvent.changedTouches[0].clientX;
|
||||
var delta = endX - touchStartX;
|
||||
|
||||
if (!carouselEnabled || Math.abs(delta) < 45) {
|
||||
return;
|
||||
}
|
||||
|
||||
goTo(delta < 0 ? currentIndex + 1 : currentIndex - 1);
|
||||
});
|
||||
|
||||
$(document).on('keydown.esunInteractiveCards-' + Math.random(), function (event) {
|
||||
if (event.key === 'Escape' && $root.hasClass('has-active')) {
|
||||
clearCardState();
|
||||
renderCarousel(true);
|
||||
startAutoplay();
|
||||
}
|
||||
});
|
||||
|
||||
$(window).on('resize.esunInteractiveCards-' + Math.random(), function () {
|
||||
window.clearTimeout(resizeTimer);
|
||||
resizeTimer = window.setTimeout(function () {
|
||||
clearCardState();
|
||||
currentIndex = Math.min(currentIndex, maximumIndex());
|
||||
buildDots();
|
||||
renderCarousel(false);
|
||||
}, 120);
|
||||
});
|
||||
|
||||
$root.on('mouseenter.esunInteractiveCards', stopAutoplay);
|
||||
$root.on('mouseleave.esunInteractiveCards', startAutoplay);
|
||||
|
||||
$controls.toggle(carouselEnabled && (showArrows || showDots));
|
||||
$prev.add($next).toggle(showArrows);
|
||||
buildDots();
|
||||
renderCarousel(false);
|
||||
startAutoplay();
|
||||
}
|
||||
|
||||
return initialize;
|
||||
});
|
||||
@@ -0,0 +1,92 @@
|
||||
define([
|
||||
'jquery',
|
||||
'mage/translate',
|
||||
'mage/url'
|
||||
], function ($, $t, urlBuilder) {
|
||||
'use strict';
|
||||
|
||||
function numberValue(value, fallback) {
|
||||
var parsed = parseInt(value, 10);
|
||||
|
||||
return Number.isFinite(parsed) ? parsed : fallback;
|
||||
}
|
||||
|
||||
function renderTags($container, value) {
|
||||
String(value || '')
|
||||
.split(/[\n,]+/)
|
||||
.map(function (tag) {
|
||||
return $.trim(tag);
|
||||
})
|
||||
.filter(Boolean)
|
||||
.forEach(function (tag) {
|
||||
$('<span>', {text: tag}).appendTo($container);
|
||||
});
|
||||
}
|
||||
|
||||
function initialize(config, element) {
|
||||
var $root = $(element);
|
||||
var desktopColumns = Math.max(2, Math.min(4, numberValue($root.attr('data-desktop-columns'), 3)));
|
||||
var tabletColumns = Math.max(1, Math.min(3, numberValue($root.attr('data-tablet-columns'), 2)));
|
||||
var mobileColumns = Math.max(1, Math.min(2, numberValue($root.attr('data-mobile-columns'), 1)));
|
||||
var gap = Math.max(0, numberValue($root.attr('data-card-gap'), 28));
|
||||
|
||||
if ($root.data('esun-product-cards-ready')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$root.data('esun-product-cards-ready', true).css({
|
||||
'--esun-product-columns': desktopColumns,
|
||||
'--esun-product-tablet-columns': tabletColumns,
|
||||
'--esun-product-mobile-columns': mobileColumns,
|
||||
'--esun-product-gap': gap + 'px'
|
||||
});
|
||||
|
||||
$root.find('.esun-product-card').each(function () {
|
||||
var $card = $(this);
|
||||
var sku = $.trim($card.attr('data-product-sku') || '');
|
||||
var tags = $card.attr('data-product-tags') || '';
|
||||
var $media = $card.find('.esun-product-card__media');
|
||||
var $image = $card.find('.esun-product-card__image');
|
||||
var $title = $card.find('.esun-product-card__title');
|
||||
var $link = $card.find('.esun-product-card__link');
|
||||
var $status = $card.find('.esun-product-card__status');
|
||||
|
||||
renderTags($card.find('.esun-product-card__tags'), tags);
|
||||
|
||||
if (!sku) {
|
||||
$card.addClass('has-error');
|
||||
$status.text($t('Product SKU is required.'));
|
||||
return;
|
||||
}
|
||||
|
||||
$card.addClass('is-loading');
|
||||
|
||||
$.getJSON(urlBuilder.build('esuninteractivecards/product/view'), {sku: sku})
|
||||
.done(function (response) {
|
||||
var product;
|
||||
|
||||
if (!response.success || !response.product) {
|
||||
$card.addClass('has-error');
|
||||
$status.text(response.message || $t('Product unavailable.'));
|
||||
return;
|
||||
}
|
||||
|
||||
product = response.product;
|
||||
$media.attr({href: product.url, tabindex: '0', 'aria-label': product.name});
|
||||
$image.attr({src: product.image, alt: product.name});
|
||||
$title.attr('href', product.url).text(product.name);
|
||||
$link.attr('href', product.url);
|
||||
$card.addClass('is-loaded');
|
||||
})
|
||||
.fail(function () {
|
||||
$card.addClass('has-error');
|
||||
$status.text($t('Product unavailable.'));
|
||||
})
|
||||
.always(function () {
|
||||
$card.removeClass('is-loading');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return initialize;
|
||||
});
|
||||
Reference in New Issue
Block a user