From c128fc1b1edca101b1628a72ef586f044cdcd10f Mon Sep 17 00:00:00 2001 From: martibelegu Date: Tue, 9 Jan 2024 18:57:40 +0100 Subject: [PATCH 01/11] XCORNER-8 widget hero slider --- widget-templates/.env | 5 + widget-templates/Hero Slider/config.json | 55 ++++++++ widget-templates/Hero Slider/schema.json | 157 +++++++++++++++++++++++ widget-templates/Hero Slider/widget.html | 73 +++++++++++ widget-templates/Hero Slider/widget.yml | 1 + 5 files changed, 291 insertions(+) create mode 100644 widget-templates/.env create mode 100644 widget-templates/Hero Slider/config.json create mode 100644 widget-templates/Hero Slider/schema.json create mode 100644 widget-templates/Hero Slider/widget.html create mode 100644 widget-templates/Hero Slider/widget.yml diff --git a/widget-templates/.env b/widget-templates/.env new file mode 100644 index 00000000..9cf42803 --- /dev/null +++ b/widget-templates/.env @@ -0,0 +1,5 @@ + +WIDGET_BUILDER_AUTH_ID=af664i3xzysy0w15y3wodgqeas3cmcm +WIDGET_BUILDER_AUTH_TOKEN=e04hhncadvybxky4kh7fg277letuzcf +WIDGET_BUILDER_CHANNEL_ID=1 +WIDGET_BUILDER_API_GATEWAY_BASE=https://api.bigcommerce.com/stores/b18lv7d9ff/v3 diff --git a/widget-templates/Hero Slider/config.json b/widget-templates/Hero Slider/config.json new file mode 100644 index 00000000..1ab3c448 --- /dev/null +++ b/widget-templates/Hero Slider/config.json @@ -0,0 +1,55 @@ +{ + "desktop_margin": { + "top": { + "value": "0", + "type": "px" + }, + "right": { + "value": "0", + "type": "px" + }, + "bottom": { + "value": "0", + "type": "px" + }, + "left": { + "value": "0", + "type": "px" + } + }, + "mobile_margin": { + "top": { + "value": "0", + "type": "px" + }, + "right": { + "value": "0", + "type": "px" + }, + "bottom": { + "value": "0", + "type": "px" + }, + "left": { + "value": "0", + "type": "px" + } + }, + "slides": [ + { + "title": "Slide Title", + "subtext": "Slide Sub Text", + "price": "Price", + "main_button": { + "visibility": "show" + }, + "secondary_button": { + "visibility": "show" + }, + "image": { + "src": "", + "type": "IMAGE_MANAGER" + } + } + ] +} \ No newline at end of file diff --git a/widget-templates/Hero Slider/schema.json b/widget-templates/Hero Slider/schema.json new file mode 100644 index 00000000..e8f058a1 --- /dev/null +++ b/widget-templates/Hero Slider/schema.json @@ -0,0 +1,157 @@ +[ + { + "type": "tab", + "label": "Settings", + "sections": [ + { + "label": "Content", + "settings": [ + { + "type": "boxModel", + "label": "Desktop Margin", + "id": "desktop_margin", + "default": { + "top": { + "value": "0", + "type": "px" + }, + "right": { + "value": "0", + "type": "px" + }, + "bottom": { + "value": "0", + "type": "px" + }, + "left": { + "value": "0", + "type": "px" + } + } + }, + { + "type": "boxModel", + "label": "Mobile Margin", + "id": "mobile_margin", + "default": { + "top": { + "value": "0", + "type": "px" + }, + "right": { + "value": "0", + "type": "px" + }, + "bottom": { + "value": "0", + "type": "px" + }, + "left": { + "value": "0", + "type": "px" + } + } + } + ] + } + ] + }, + { + "type": "array", + "label": "Slides", + "id": "slides", + "defaultCount": 1, + "entryLabel": "Slide", + "schema": [ + { + "type": "tab", + "label": "Slide", + "sections": [ + { + "settings": [ + { + "type": "input", + "label": "Title", + "id": "title", + "default": "Slide Title" + }, + { + "type": "input", + "label": "Subtext", + "id": "subtext", + "default": "Slide Sub Text" + }, + { + "type": "input", + "label": "Price", + "id": "price", + "default": "Price" + }, + { + "type": "element", + "label": "Main Button", + "id": "main_button", + "typeMeta": { + "controls": { + "visibility": { + "default": "show" + }, + "advanced": { + "settings": [ + { + "type": "input", + "label": "Button Text", + "id": "text" + }, + { + "type": "input", + "label": "Button URL", + "id": "url" + } + ] + } + } + } + }, + { + "type": "element", + "label": "Secondary Button", + "id": "secondary_button", + "typeMeta": { + "controls": { + "visibility": { + "default": "show" + }, + "advanced": { + "settings": [ + { + "type": "input", + "label": "Button Text", + "id": "text" + }, + { + "type": "input", + "label": "Button URL", + "id": "url" + } + ] + } + } + } + }, + { + "type": "imageManager", + "label": "Image", + "id": "image", + "default": { + "src": "", + "type": "IMAGE_MANAGER" + } + } + ] + } + ] + } + ] +} +] \ No newline at end of file diff --git a/widget-templates/Hero Slider/widget.html b/widget-templates/Hero Slider/widget.html new file mode 100644 index 00000000..2cced142 --- /dev/null +++ b/widget-templates/Hero Slider/widget.html @@ -0,0 +1,73 @@ + + + + + + \ No newline at end of file diff --git a/widget-templates/Hero Slider/widget.yml b/widget-templates/Hero Slider/widget.yml new file mode 100644 index 00000000..88df99ee --- /dev/null +++ b/widget-templates/Hero Slider/widget.yml @@ -0,0 +1 @@ +4ec450d7-c3d3-4315-9aaf-d55e1028f8d8 \ No newline at end of file From a925c1d977c61618e5b563a1b1fffcbdd7148745 Mon Sep 17 00:00:00 2001 From: martibelegu Date: Tue, 9 Jan 2024 18:57:50 +0100 Subject: [PATCH 02/11] XCORNER-8 hero slider implementation --- assets/js/theme/common/carousel.js | 9 +- assets/scss/widgets/hero-slider.scss | 162 +++++++++++++++++++++++++++ assets/scss/widgets/widgets.scss | 1 + 3 files changed, 170 insertions(+), 2 deletions(-) create mode 100644 assets/scss/widgets/hero-slider.scss create mode 100644 assets/scss/widgets/widgets.scss diff --git a/assets/js/theme/common/carousel.js b/assets/js/theme/common/carousel.js index 7e356700..dca4253e 100644 --- a/assets/js/theme/common/carousel.js +++ b/assets/js/theme/common/carousel.js @@ -1,16 +1,17 @@ -import Swiper, { Navigation } from 'swiper' +import Swiper, { Navigation, Pagination } from 'swiper' import q$ from '../global/selector' /* eslint-disable import/no-unresolved, import/extensions */ import 'swiper/scss' import 'swiper/scss/navigation' +import 'swiper/css/pagination' /* eslint-enable import/no-unresolved, import/extensions */ export default function startSwiper(context) { if (q$('.js-home-swiper') !== null) { const homeCarouselParams = { direction: 'horizontal', - modules: [Navigation], + modules: [Navigation, Pagination], allowSlideNext: true, allowSlidePrev: true, slidesPerView: 1, @@ -23,6 +24,10 @@ export default function startSwiper(context) { nextEl: '.js-swiper-btn-next', prevEl: '.js-swiper-btn-prev', }, + pagination: { + el: '.js-swiper-pagination', + clickable: true, + }, } /* eslint-disable no-new */ diff --git a/assets/scss/widgets/hero-slider.scss b/assets/scss/widgets/hero-slider.scss new file mode 100644 index 00000000..2219e8c1 --- /dev/null +++ b/assets/scss/widgets/hero-slider.scss @@ -0,0 +1,162 @@ +$swiper-arrow-right: "data:image/svg+xml;base64,CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSI+CjxnIGlkPSJhcnJvdy1yaWdodCI+CjxwYXRoIGlkPSJWZWN0b3IiIGQ9Ik01IDEySDE5TTE5IDEyTDEyIDVNMTkgMTJMMTIgMTkiIHN0cm9rZT0id2hpdGUiIHN0cm9rZS13aWR0aD0iMS41IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPC9nPgo8L3N2Zz4K"; +$swiper-arrow-left: "data:image/svg+xml;base64,CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSI+CjxtYXNrIGlkPSJtYXNrMF8zMDQxXzMyMDEzIiBzdHlsZT0ibWFzay10eXBlOmFscGhhIiBtYXNrVW5pdHM9InVzZXJTcGFjZU9uVXNlIiB4PSIwIiB5PSIwIiB3aWR0aD0iMjQiIGhlaWdodD0iMjQiPgo8cGF0aCBkPSJNMTkgMTJINU01IDEyTDEyIDE5TTUgMTJMMTIgNSIgc3Ryb2tlPSJibGFjayIgc3Ryb2tlLXdpZHRoPSIxLjUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8L21hc2s+CjxnIG1hc2s9InVybCgjbWFzazBfMzA0MV8zMjAxMykiPgo8cmVjdCB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIGZpbGw9IndoaXRlIi8+CjwvZz4KPC9zdmc+Cg=="; + +.slide-image { + aspect-ratio: 342/424; + width: 100%; + height: auto; + object-fit: cover; + + @include bp(medium) { + aspect-ratio: 738/484; + } + + @include bp(large) { + aspect-ratio: 1280/640; + } +} + +.slide-information { + position: relative; + background-color: $color-white; + display: flex; + flex-direction: column; + gap: 12px; + padding: 24px; + border-radius: 4px; + align-items: center; + max-width: 852px; + margin: -96px 24px 0; + + @include bp(medium) { + margin: -96px 127px 0; + padding: 48px; + gap: 24px; + } + + @include bp(large) { + margin: -96px auto 0; + } +} + +.slide-title { + color: $color-black; + text-align: center; + font-family: $font-regular; + font-size: 32px; + font-style: normal; + font-weight: 600; + line-height: 1.25; + margin: 0; + + @include bp(medium) { + font-size: 42px; + line-height: 1.33; + } +} + +.slide-subtext { + color: $color-neutrals-500; + text-align: center; + font-family: $font-regular; + font-size: 18px; + font-style: normal; + font-weight: 400; + line-height: 1.33; + margin: 0; +} + +.slide-price { + color: $color-neutrals-300; + text-align: center; + font-family: $font-regular; + font-size: 24px; + font-style: normal; + font-weight: 400; + line-height: 1.33; + margin: 0; + + span { + color: $color-black; + text-align: center; + font-family: $font-regular; + font-size: 32px; + font-style: normal; + font-weight: 600; + line-height: 1.25; + } +} + +.slide-buttons { + display: flex; + flex-direction: column; + gap: 12px; + + @include bp(medium) { + flex-direction: row; + } +} + +.slide-navigation { + position: absolute; + bottom: 60%; + z-index: 2; + left: 0; + margin-left: 50%; + transform: translateX(-50%); + display: flex; + justify-content: center; + align-items: center; + gap: 24px; + + @include bp(small) { + bottom: 50%; + } + + @include bp(medium) { + bottom: 50%; + } + + @include bp(large) { + bottom: 400px; + } + + .js-swiper-btn-next, + .js-swiper-btn-prev { + width: 24px; + height: 24px; + border: 0 !important; + background-repeat: no-repeat; + background-position: center; + background-size: contain; + } + + .js-swiper-btn-next { + background-image: url($swiper-arrow-right); + } + + .js-swiper-btn-prev { + background-image: url($swiper-arrow-left); + } + + .js-swiper-pagination { + border: 0 !important; + padding: 0 !important; + display: flex; + justify-content: space-between; + gap: 24px; + + .swiper-pagination-bullet { + background-color: transparent; + opacity: 1; + border: 2px solid $color-white; + width: 12px; + height: 12px; + margin: 0 !important; + + &-active { + background-color: $color-white; + } + } + } +} \ No newline at end of file diff --git a/assets/scss/widgets/widgets.scss b/assets/scss/widgets/widgets.scss new file mode 100644 index 00000000..e35cbd0f --- /dev/null +++ b/assets/scss/widgets/widgets.scss @@ -0,0 +1 @@ +@import './hero-slider'; \ No newline at end of file From 66deb41019484e0c660f6c7a83dbdab806c5dca6 Mon Sep 17 00:00:00 2001 From: martibelegu Date: Tue, 9 Jan 2024 18:58:16 +0100 Subject: [PATCH 03/11] XCORNER-8 update homepage --- templates/pages/home.html | 3 --- 1 file changed, 3 deletions(-) diff --git a/templates/pages/home.html b/templates/pages/home.html index 3962aaa4..e58586d5 100644 --- a/templates/pages/home.html +++ b/templates/pages/home.html @@ -13,9 +13,6 @@ --- {{#partial "hero"}} {{{region name="home_below_menu"}}} - {{#and carousel carousel.slides.length}} - {{> components/carousel/carousel arrows=theme_settings.homepage_show_carousel_arrows play_pause_button=theme_settings.homepage_show_carousel_play_pause_button}} - {{/and}} {{{region name="home_below_carousel"}}} {{/partial}} From 8fc2c82d2cae3ee5742dfc4a68162c7e6bad691e Mon Sep 17 00:00:00 2001 From: martibelegu Date: Thu, 1 Feb 2024 11:22:12 +0100 Subject: [PATCH 04/11] XCORNER-8 code refactor --- assets/scss/widgets/hero-slider.scss | 38 ++++++++++++------------ widget-templates/Hero Slider/widget.html | 24 +++++++-------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/assets/scss/widgets/hero-slider.scss b/assets/scss/widgets/hero-slider.scss index 2219e8c1..541b3354 100644 --- a/assets/scss/widgets/hero-slider.scss +++ b/assets/scss/widgets/hero-slider.scss @@ -1,7 +1,7 @@ -$swiper-arrow-right: "data:image/svg+xml;base64,CjxzdmcgeG1sbnM9Imh0dHA6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pZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSI+CjxnIGlkPSJhcnJvdy1yaWdodCI+CjxwYXRoIGlkPSJWZWN0b3IiIGQ9Ik01IDEySDE5TTE5IDEyTDEyIDVNMTkgMTJMMTIgMTkiIHN0cm9rZT0id2hpdGUiIHN0cm9rZS13aWR0aD0iMS41IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPC9nPgo8L3N2Zz4K'; +$swiper-arrow-left: 'data:image/svg+xml;base64,CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSI+CjxtYXNrIGlkPSJtYXNrMF8zMDQxXzMyMDEzIiBzdHlsZT0ibWFzay10eXBlOmFscGhhIiBtYXNrVW5pdHM9InVzZXJTcGFjZU9uVXNlIiB4PSIwIiB5PSIwIiB3aWR0aD0iMjQiIGhlaWdodD0iMjQiPgo8cGF0aCBkPSJNMTkgMTJINU01IDEyTDEyIDE5TTUgMTJMMTIgNSIgc3Ryb2tlPSJibGFjayIgc3Ryb2tlLXdpZHRoPSIxLjUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8L21hc2s+CjxnIG1hc2s9InVybCgjbWFzazBfMzA0MV8zMjAxMykiPgo8cmVjdCB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIGZpbGw9IndoaXRlIi8+CjwvZz4KPC9zdmc+Cg=='; -.slide-image { +.c-hero-slider__image { aspect-ratio: 342/424; width: 100%; height: auto; @@ -16,7 +16,7 @@ $swiper-arrow-left: "data:image/svg+xml;base64,CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cud } } -.slide-information { +.c-hero-slider__information { position: relative; background-color: $color-white; display: flex; @@ -39,7 +39,7 @@ $swiper-arrow-left: "data:image/svg+xml;base64,CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cud } } -.slide-title { +.c-hero-slider__title { color: $color-black; text-align: center; font-family: $font-regular; @@ -55,7 +55,7 @@ $swiper-arrow-left: "data:image/svg+xml;base64,CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cud } } -.slide-subtext { +.c-hero-slider__subtext { color: $color-neutrals-500; text-align: center; font-family: $font-regular; @@ -66,7 +66,7 @@ $swiper-arrow-left: "data:image/svg+xml;base64,CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cud margin: 0; } -.slide-price { +.c-hero-slider__price-container { color: $color-neutrals-300; text-align: center; font-family: $font-regular; @@ -75,19 +75,19 @@ $swiper-arrow-left: "data:image/svg+xml;base64,CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cud font-weight: 400; line-height: 1.33; margin: 0; +} - span { - color: $color-black; - text-align: center; - font-family: $font-regular; - font-size: 32px; - font-style: normal; - font-weight: 600; - line-height: 1.25; - } +.c-hero-slider__price { + color: $color-black; + text-align: center; + font-family: $font-regular; + font-size: 32px; + font-style: normal; + font-weight: 600; + line-height: 1.25; } -.slide-buttons { +.c-hero-slider__buttons { display: flex; flex-direction: column; gap: 12px; @@ -97,7 +97,7 @@ $swiper-arrow-left: "data:image/svg+xml;base64,CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cud } } -.slide-navigation { +.c-hero-slider__navigation { position: absolute; bottom: 60%; z-index: 2; @@ -159,4 +159,4 @@ $swiper-arrow-left: "data:image/svg+xml;base64,CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cud } } } -} \ No newline at end of file +} diff --git a/widget-templates/Hero Slider/widget.html b/widget-templates/Hero Slider/widget.html index 2cced142..bb3f95e8 100644 --- a/widget-templates/Hero Slider/widget.html +++ b/widget-templates/Hero Slider/widget.html @@ -1,31 +1,31 @@ -