Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(RSS-ECOMM-5_95): promo code banner #359

Merged
merged 4 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed public/img/png/promo-slider-1.png
Binary file not shown.
Binary file removed public/img/png/promo-slider-2.png
Binary file not shown.
Binary file removed public/img/png/promo-slider-3.png
Binary file not shown.
Binary file added public/img/webp/promo-slider-1_2.webp
Binary file not shown.
Binary file added public/img/webp/promo-slider-2_1.webp
Binary file not shown.
Binary file added public/img/webp/promo-slider-2_2.webp
Binary file not shown.
Binary file added public/img/webp/promo-slider-3_1.webp
Binary file not shown.
Binary file added public/img/webp/promo-slider-3_2.webp
Binary file not shown.
1 change: 1 addition & 0 deletions src/app/styles/variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
--extra-bold-font: 700 2.1875rem 'Cerapro', sans-serif; // 35px
--black-font: 900 2.1875rem 'Cerapro', sans-serif; // 35px
--extra-black-font: 900 2.5rem 'Cerapro', sans-serif; // 40px
--super-large-font: 900 4.4rem 'Cerapro', sans-serif; // 70px

body.light {
// colors
Expand Down
24 changes: 7 additions & 17 deletions src/entities/PromocodeSlider/view/PromoCodeSliderView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,24 +126,23 @@ class PromoCodeSliderView {
return this.slider;
}

private async createSliderSlideContent(index: number, slideWrapper: HTMLDivElement): Promise<HTMLDivElement> {
private async createSliderSlideContent(index: number): Promise<HTMLDivElement> {
const slide = createBaseElement({
cssClasses: [styles.sliderContent],
tag: 'div',
});

const { description, img, title } = this.createSliderSlideInfo(index);
slide.classList.add(styles[PROMO_SLIDER_CONTENT[index][getStore().getState().currentLanguage].style]);
const { description, title } = this.createSliderSlideInfo(index);

slide.append(
title,
description,
this.createPromoCodeSpan(PROMO_SLIDER_CONTENT[index][getStore().getState().currentLanguage].promoCode),
);
slideWrapper.append(img);

observeStore(selectCurrentLanguage, () => {
title.textContent = PROMO_SLIDER_CONTENT[index][getStore().getState().currentLanguage].title;
description.textContent = PROMO_SLIDER_CONTENT[index][getStore().getState().currentLanguage].description;
title.innerHTML = PROMO_SLIDER_CONTENT[index][getStore().getState().currentLanguage].title;
description.innerHTML = PROMO_SLIDER_CONTENT[index][getStore().getState().currentLanguage].description;
});

if (PROMO_SLIDER_CONTENT[index].en.date.end === null && getStore().getState().isUserLoggedIn) {
Expand All @@ -160,17 +159,8 @@ class PromoCodeSliderView {

private createSliderSlideInfo(index: number): {
description: HTMLParagraphElement;
img: HTMLImageElement;
title: HTMLHeadingElement;
} {
const img = createBaseElement({
attributes: {
src: PROMO_SLIDER_CONTENT[index][getStore().getState().currentLanguage].img,
},
cssClasses: [styles.sliderImage],
tag: 'img',
});

const title = createBaseElement({
cssClasses: [styles.sliderTitle],
innerContent: PROMO_SLIDER_CONTENT[index][getStore().getState().currentLanguage].title,
Expand All @@ -183,7 +173,7 @@ class PromoCodeSliderView {
tag: 'p',
});

return { description, img, title };
return { description, title };
}

private createSliderWrapper(): HTMLDivElement {
Expand All @@ -197,7 +187,7 @@ class PromoCodeSliderView {
cssClasses: ['swiper-slide', styles.sliderSlide],
tag: 'div',
});
this.createSliderSlideContent(index, slideWrapper)
this.createSliderSlideContent(index)
.then((slide) => slideWrapper.append(slide))
.catch(showErrorMessage);

Expand Down
89 changes: 69 additions & 20 deletions src/entities/PromocodeSlider/view/promoCodeSliderView.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,24 @@

.sliderTitle {
margin-bottom: var(--tiny-offset);
max-width: 55%;
font: var(--extra-black-font);
max-width: 80%;
font: var(--super-large-font);
letter-spacing: var(--one);
color: var(--steam-green-800);

@media (max-width: 768px) {
max-width: 100%;
font: var(--black-font);
}
}

.sliderImage {
position: absolute;
right: var(--medium-offset);
top: 55%;
width: 40%;
height: auto;
transform: translateY(-45%);

@media (max-width: 950px) {
width: 35%;
}

@media (max-width: 768px) {
display: none;
@media (max-width: 600px) {
font: var(--black-font);
}
}

.sliderDescription {
margin-bottom: var(--extra-small-offset);
max-width: 55%;
font: var(--black-font);
font: var(--medium-font);
letter-spacing: var(--one);
color: var(--noble-gray-800);

Expand Down Expand Up @@ -78,12 +64,14 @@
.currentPromoCode {
font: var(--medium-font);
letter-spacing: var(--one);
color: var(--steam-green-400);
color: var(--steam-green-800);
background-color: transparent;
pointer-events: none;
}

.paginationWrapper {
position: absolute;
right: 0;
z-index: 2;
display: flex;
margin: 0 auto;
Expand Down Expand Up @@ -124,3 +112,64 @@
letter-spacing: var(--one);
color: var(--noble-gray-800);
}

.birthday {
height: 100%;
background-image: linear-gradient(to right, var(--white) 0%, var(--white) 20%, transparent 100%),
url('/img/webp/promo-slider-2_1.webp');
background-position: right center;
background-size: auto 100%;
background-repeat: no-repeat;

@media (max-width: 768px) {
background-image: linear-gradient(to right, var(--white) 0%, var(--white) 50%, transparent 100%),
url('/img/webp/promo-slider-2_2.webp');
}
}

.succulent {
height: 100%;
background-image: linear-gradient(to right, var(--white) 0%, var(--white) 20%, transparent 100%),
url('/img/webp/promo-slider-3_1.webp');
background-position: right center;
background-size: auto 100%;
background-repeat: no-repeat;

@media (max-width: 768px) {
background-image: linear-gradient(to right, var(--white) 0%, var(--white) 50%, transparent 100%),
url('/img/webp/promo-slider-3_2.webp');
}
}

.garden {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
background-image: radial-gradient(circle at center, var(--white) 40%, transparent 40.1%),
url('/img/webp/promo-slider-1_2.webp');
background-position:
center center,
right center;
background-size: cover, cover;
background-repeat: no-repeat;

h3,
p {
text-align: center;
}

input {
width: 11rem;
}

@media (max-width: 768px) {
background-image: radial-gradient(circle at center, var(--white) 55%, transparent 55.1%),
url('/img/webp/promo-slider-1_2.webp');
}
}

.sliderSlide {
height: auto;
}
36 changes: 18 additions & 18 deletions src/shared/constants/promo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ const PROMO_SLIDER_CONTENT = [
end: '2024-06-30',
start: '2024-06-01',
},
description: 'Everything for garden and vegetable garden with 10% discount',
img: './img/png/promo-slider-1.png',
description: `<span style="color: var(--black)">Everything for garden and<br> plants care with 10% discount</span>`,
promoCode: 'SUMMER-SALE-10',
title: 'Summer sale!',
style: 'garden',
title: `<span style="color: var(--steam-green-800);">SUMMER</span><br> <span style="color: var(--black);">SALE</span>`,
},
ru: {
date: {
end: '2024-06-30',
start: '2024-06-01',
},
description: 'Все для сада и огорода со скидкой в 10%',
img: './img/png/promo-slider-1.png',
description: `<span style="color: var(--black)">Все для сада и ухода за<br> растениями со скидкой в 10%</span>`,
promoCode: 'SUMMER-SALE-10',
title: 'Летняя распродажа!',
style: 'garden',
title: `<span style="color: var(--steam-green-800);">ЛЕТНЯЯ</span><br> <span style="color: var(--black);">АКЦИЯ</span>`,
},
},
{
Expand All @@ -27,20 +27,20 @@ const PROMO_SLIDER_CONTENT = [
end: null,
start: 'The promotion is valid 3 days before and 3 days after your birthday',
},
description: 'For your birthday 10% discount off the entire cart',
img: './img/png/promo-slider-2.png',
description: 'For your birthday 10% discount<br> off the entire cart',
promoCode: 'HAPPY-BIRTHDAY-10',
title: 'Happy birthday!',
style: 'birthday',
title: `<span style="color: var(--black);">BIRTHDAY</span><br> <span style="color: #46a358;">PRESENT</span>`,
},
ru: {
date: {
end: null,
start: 'Акция действует 3 дня до и 3 дня после дня рождения',
},
description: 'В честь вашего дня рождения скидка 10% от общей суммы товаров',
img: './img/png/promo-slider-2.png',
description: 'В честь вашего дня рождения скидка 10%<br> от общей суммы товаров',
promoCode: 'HAPPY-BIRTHDAY-10',
title: 'С днем рождения!',
style: 'birthday',
title: `<span style="color: var(--steam-green-800);">ПОДАРОК</span><br> <span style="color: var(--black);">ИМЕНИННИКУ</span>`,
},
},
{
Expand All @@ -49,20 +49,20 @@ const PROMO_SLIDER_CONTENT = [
end: '2024-06-15',
start: '2024-06-01',
},
description: 'For all products from the Succulents category',
img: './img/png/promo-slider-3.png',
description: 'For all products from the<br> Succulents category',
promoCode: 'SUCCULENT-SALE-15',
title: 'Succulents for everyone!',
style: 'succulent',
title: `<span style="color: var(--steam-green-800);">SUCCULENTS</span><br> <span style="color: var(--black);">FOR EVERYONE!</span>`,
},
ru: {
date: {
end: '2024-06-15',
start: '2024-06-01',
},
description: 'На все товары из категории Суккуленты',
img: './img/png/promo-slider-3.png',
description: 'На все товары из<br> категории Суккуленты',
promoCode: 'SUCCULENT-SALE-15',
title: 'Каждому по суккуленту!',
style: 'succulent',
title: `<span style="color: var(--black);">КАЖДОМУ ПО</span><br> <span style="color: var(--steam-green-800);">СУККУЛЕНТУ!</span>`,
},
},
];
Expand Down
4 changes: 4 additions & 0 deletions src/widgets/Blog/view/blogWidgetView.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
@media (max-width: 768px) {
display: flex;
flex-direction: column;

div {
height: auto;
}
}
}

Expand Down