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

Quick Add #1388

Merged
merged 65 commits into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
96ea720
Initial work
LucasLacerdaUX Feb 1, 2022
6501740
Add success message. Add modal prevention for cart-notification.
LucasLacerdaUX Feb 9, 2022
e542ab0
Improve success message.
LucasLacerdaUX Feb 10, 2022
c3da03d
Add setting. Fix translations
LucasLacerdaUX Feb 10, 2022
4d1f385
Add loading spinner to modal.
LucasLacerdaUX Feb 10, 2022
61423c6
Add modal. Separate modal styles. Add view details.
LucasLacerdaUX Feb 10, 2022
f97322c
Fix Dynamic Checkout. Fix script tags. Remove Sold Out messages. Remo…
LucasLacerdaUX Feb 21, 2022
bc3dec9
Fix variant switching
LucasLacerdaUX Feb 21, 2022
64dd9c5
CSS adjustments
LucasLacerdaUX Feb 22, 2022
4d7ab44
Refactor ProductModal into a separate file. Update selector to use a …
LucasLacerdaUX Feb 22, 2022
c0d4825
Refactor button message removal
LucasLacerdaUX Feb 23, 2022
10edf40
Update card heading
LucasLacerdaUX Feb 23, 2022
895fbb3
Update locale
LucasLacerdaUX Feb 23, 2022
0d43153
Cleaning code
LucasLacerdaUX Feb 24, 2022
6d0ad87
Add aria-disabled to success-message
LucasLacerdaUX Feb 24, 2022
a81452b
Fix issue with variant changing
LucasLacerdaUX Feb 24, 2022
08cc34d
Update 3 translation files
translation-platform[bot] Feb 25, 2022
d73d750
Update 8 translation files
translation-platform[bot] Feb 25, 2022
0e5fdfa
Update 16 translation files
translation-platform[bot] Feb 25, 2022
86a88da
Update 11 translation files
translation-platform[bot] Feb 25, 2022
19142ba
Fix setting position on collection list
LucasLacerdaUX Feb 25, 2022
e424868
Update 6 translation files
translation-platform[bot] Feb 26, 2022
45e7ad2
Update 5 translation files
translation-platform[bot] Feb 26, 2022
4808d01
Auto hide modal
LucasLacerdaUX Feb 28, 2022
5c2ffe7
Fix focus after closing cart notification
LucasLacerdaUX Feb 28, 2022
32dc2bb
Remove success message
LucasLacerdaUX Feb 28, 2022
bc5ce68
Fix a11y issues: focus when closing modal, touch target fix for close…
LucasLacerdaUX Feb 28, 2022
23ef105
Gallery list semantic
LucasLacerdaUX Feb 28, 2022
76f9455
Mobile layout adjustments
LucasLacerdaUX Feb 28, 2022
3eeef6f
Use aria-labelledby
LucasLacerdaUX Feb 28, 2022
813efa1
Update 1 translation file
translation-platform[bot] Feb 28, 2022
e320dc0
Update 21 translation files
translation-platform[bot] Mar 1, 2022
c5ff873
Update 1 translation file
translation-platform[bot] Mar 1, 2022
5f36f38
Update 5 translation files
translation-platform[bot] Mar 2, 2022
0e73cc0
Update 2 translation files
translation-platform[bot] Mar 2, 2022
1b61935
Update 1 translation file
translation-platform[bot] Mar 3, 2022
ab03bcb
Reviewer suggestions
LucasLacerdaUX Mar 14, 2022
affc0a9
Rename quick-buy to quick-add
LucasLacerdaUX Mar 14, 2022
6043668
Remove DOMElements before inserting in modal
LucasLacerdaUX Mar 14, 2022
ea0c8ee
Theme check automated fixes
LucasLacerdaUX Mar 14, 2022
d395c08
Remove default link
LucasLacerdaUX Mar 14, 2022
f839b6b
UX updates: spacing. Fixes XR button and broken variant switching.
LucasLacerdaUX Mar 15, 2022
31a9a7e
Bottom
LucasLacerdaUX Mar 15, 2022
15a09f7
Rename labels back.
LucasLacerdaUX Mar 15, 2022
109f598
Merge branch 'main' into quick-buy
Mar 15, 2022
98ce306
Update modal styling
LucasLacerdaUX Mar 17, 2022
3b8a639
Update spacing
LucasLacerdaUX Mar 17, 2022
a2d55cd
Bottom align Quick Add button. Fix Sold Out linking to the product pa…
LucasLacerdaUX Mar 17, 2022
be71de3
Fix focus trap on close button
LucasLacerdaUX Mar 17, 2022
a723ab1
Hiding parent instead of thumbnail-list + buttons
LucasLacerdaUX Mar 17, 2022
3f20764
Fix margin bottom
LucasLacerdaUX Mar 17, 2022
9c7de38
Update spacing
LucasLacerdaUX Mar 17, 2022
1e935c3
Fix XR button
LucasLacerdaUX Mar 17, 2022
ae83742
Merge branch 'main' into quick-buy
Mar 18, 2022
a1974fd
Set to max-height
LucasLacerdaUX Mar 21, 2022
ca15639
Reviewer feedback
LucasLacerdaUX Mar 22, 2022
54254a7
Fix issues with scroll content
LucasLacerdaUX Mar 23, 2022
d5bf4d4
Fix duplicate IDs - fix quick add on product page
LucasLacerdaUX Mar 23, 2022
f5ce17d
Revert to max-height
LucasLacerdaUX Mar 23, 2022
fa8807f
Fix spacing when thick border
LucasLacerdaUX Mar 23, 2022
baadd21
Address design suggestions. Fix bug with featured collection on the p…
LucasLacerdaUX Mar 24, 2022
5234881
Fix spacing issues
LucasLacerdaUX Mar 24, 2022
e23ff7c
Align X button
LucasLacerdaUX Mar 24, 2022
1bb8fb4
Address reviewer feedback
LucasLacerdaUX Mar 24, 2022
15f1ae2
Revert decision to hide dynamic checkout buttons.
LucasLacerdaUX Mar 25, 2022
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
4 changes: 4 additions & 0 deletions assets/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,10 @@ button.shopify-payment-button__button--unbranded {
display: flex;
LucasLacerdaUX marked this conversation as resolved.
Show resolved Hide resolved
}
LucasLacerdaUX marked this conversation as resolved.
Show resolved Hide resolved
LucasLacerdaUX marked this conversation as resolved.
Show resolved Hide resolved
LucasLacerdaUX marked this conversation as resolved.
Show resolved Hide resolved
LucasLacerdaUX marked this conversation as resolved.
Show resolved Hide resolved
LucasLacerdaUX marked this conversation as resolved.
Show resolved Hide resolved
LucasLacerdaUX marked this conversation as resolved.
Show resolved Hide resolved
ludoboludo marked this conversation as resolved.
Show resolved Hide resolved
LucasLacerdaUX marked this conversation as resolved.
Show resolved Hide resolved
ludoboludo marked this conversation as resolved.
Show resolved Hide resolved
LucasLacerdaUX marked this conversation as resolved.
Show resolved Hide resolved
LucasLacerdaUX marked this conversation as resolved.
Show resolved Hide resolved

.button.loading > .loading-overlay__spinner .path {
stroke: rgb(var(--color-button-text));
}

/* Button - social share */

.share-button {
Expand Down
16 changes: 16 additions & 0 deletions assets/component-card.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
text-decoration: none;
}

.card:not(.ratio) {
display: flex;
flex-direction: column;
height: 100%;
}

.card--card {
height: 100%;
}
Expand Down Expand Up @@ -89,6 +95,7 @@
grid-template-rows: minmax(0,1fr) max-content minmax(0,1fr);
padding: 1rem;
width: 100%;
flex-grow: 1;
}

.card__content--auto-margins {
Expand All @@ -100,6 +107,10 @@
padding: 1.3rem 1rem;
}

.card:not(.ratio) > .card__content {
grid-template-rows: max-content minmax(0,1fr) max-content auto;
}

@media screen and (min-width: 750px) {
.card__information {
padding-bottom: 1.7rem;
Expand All @@ -122,6 +133,10 @@
justify-self: flex-end;
}

.card > .card__content > .card__badge {
margin: 1.3rem;
}

.card__media .media img {
height: 100%;
object-fit: cover;
Expand All @@ -135,6 +150,7 @@

.card__heading {
margin-top: 0;
margin-bottom: 0;
}

.card__heading:last-child {
Expand Down
19 changes: 9 additions & 10 deletions assets/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ class ModalDialog extends HTMLElement {
super();
this.querySelector('[id^="ModalClose-"]').addEventListener(
'click',
this.hide.bind(this)
this.hide.bind(this, false)
);
this.addEventListener('keyup', (event) => {
if (event.code.toUpperCase() === 'ESCAPE') this.hide();
Expand All @@ -443,7 +443,7 @@ class ModalDialog extends HTMLElement {
});
} else {
this.addEventListener('click', (event) => {
if (event.target.nodeName === 'MODAL-DIALOG') this.hide();
if (event.target === this) this.hide();
});
}
}
Expand All @@ -466,6 +466,7 @@ class ModalDialog extends HTMLElement {

hide() {
document.body.classList.remove('overflow-hidden');
document.body.dispatchEvent(new CustomEvent('modalClosed'));
this.removeAttribute('open');
removeTrapFocus(this.openedBy);
window.pauseAllMedia();
Expand Down Expand Up @@ -780,6 +781,7 @@ class VariantSelects extends HTMLElement {
mediaGallery.setActiveMedia(`${this.dataset.section}-${this.currentVariant.featured_media.id}`, true);

const modalContent = document.querySelector(`#ProductModal-${this.dataset.section} .product-media-modal__content`);
if (!modalContent) return;
const newMediaModal = modalContent.querySelector( `[data-media-id="${this.currentVariant.featured_media.id}"]`);
modalContent.prepend(newMediaModal);
}
Expand All @@ -791,12 +793,12 @@ class VariantSelects extends HTMLElement {

updateShareUrl() {
const shareButton = document.getElementById(`Share-${this.dataset.section}`);
if (!shareButton) return;
if (!shareButton || !shareButton.updateUrl) return;
shareButton.updateUrl(`${window.shopUrl}${this.dataset.url}?variant=${this.currentVariant.id}`);
}

updateVariantInput() {
const productForms = document.querySelectorAll(`#product-form-${this.dataset.section}, #product-form-installment`);
const productForms = document.querySelectorAll(`#product-form-${this.dataset.section}, #product-form-installment-${this.dataset.section}`);
productForms.forEach((productForm) => {
const input = productForm.querySelector('input[name="id"]');
input.value = this.currentVariant.id;
Expand Down Expand Up @@ -825,14 +827,12 @@ class VariantSelects extends HTMLElement {
}

renderProductInfo() {
fetch(`${this.dataset.url}?variant=${this.currentVariant.id}&section_id=${this.dataset.section}`)
fetch(`${this.dataset.url}?variant=${this.currentVariant.id}&section_id=${this.dataset.originalSection ? this.dataset.originalSection : this.dataset.section}`)
.then((response) => response.text())
.then((responseText) => {
const id = `price-${this.dataset.section}`;
const html = new DOMParser().parseFromString(responseText, 'text/html')
const destination = document.getElementById(id);
const source = html.getElementById(id);

const destination = document.getElementById(`price-${this.dataset.section}`);
const source = html.getElementById(`price-${this.dataset.originalSection ? this.dataset.originalSection : this.dataset.section}`);
if (source && destination) destination.innerHTML = source.innerHTML;

const price = document.getElementById(`price-${this.dataset.section}`);
Expand All @@ -847,7 +847,6 @@ class VariantSelects extends HTMLElement {
if (!productForm) return;
const addButton = productForm.querySelector('[name="add"]');
const addButtonText = productForm.querySelector('[name="add"] > span');

if (!addButton) return;

if (disable) {
Expand Down
31 changes: 24 additions & 7 deletions assets/product-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ if (!customElements.get('product-form')) {
this.form.querySelector('[name=id]').disabled = false;
this.form.addEventListener('submit', this.onSubmitHandler.bind(this));
this.cartNotification = document.querySelector('cart-notification');
this.submitButton = this.querySelector('[type="submit"]');
}

onSubmitHandler(evt) {
evt.preventDefault();
const submitButton = this.querySelector('[type="submit"]');
if (submitButton.classList.contains('loading')) return;
if (this.submitButton.getAttribute('aria-disabled') === 'true') return;

this.handleErrorMessage();
this.cartNotification.setActiveElement(document.activeElement);

submitButton.setAttribute('aria-disabled', true);
submitButton.classList.add('loading');
this.submitButton.setAttribute('aria-disabled', true);
this.submitButton.classList.add('loading');
this.querySelector('.loading-overlay__spinner').classList.remove('hidden');

const config = fetchConfig('javascript');
Expand All @@ -35,23 +35,40 @@ if (!customElements.get('product-form')) {
.then((response) => {
if (response.status) {
this.handleErrorMessage(response.description);

const soldOutMessage = this.submitButton.querySelector('.sold-out-message');
if (!soldOutMessage) return;
this.submitButton.setAttribute('aria-disabled', true);
this.submitButton.querySelector('span').classList.add('hidden');
soldOutMessage.classList.remove('hidden');
this.error = true;
return;
}

this.cartNotification.renderContents(response);
this.error = false;
const quickAddModal = this.closest('quick-add-modal');
if (quickAddModal) {
document.body.addEventListener('modalClosed', () => {
setTimeout(() => { this.cartNotification.renderContents(response) });
}, { once: true });
quickAddModal.hide(true);
} else {
this.cartNotification.renderContents(response);
}
})
.catch((e) => {
console.error(e);
})
.finally(() => {
submitButton.classList.remove('loading');
submitButton.removeAttribute('aria-disabled');
this.submitButton.classList.remove('loading');
if (!this.error) this.submitButton.removeAttribute('aria-disabled');
this.querySelector('.loading-overlay__spinner').classList.add('hidden');
});
}

handleErrorMessage(errorMessage = false) {
this.errorMessageWrapper = this.errorMessageWrapper || this.querySelector('.product-form__error-message-wrapper');
if (!this.errorMessageWrapper) return;
this.errorMessage = this.errorMessage || this.errorMessageWrapper.querySelector('.product-form__error-message');

this.errorMessageWrapper.toggleAttribute('hidden', !errorMessage);
Expand Down
34 changes: 34 additions & 0 deletions assets/product-modal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
if (!customElements.get('product-modal')) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing changed on this file. Just moved it from featured-product and main-product.

customElements.define('product-modal', class ProductModal extends ModalDialog {
constructor() {
super();
}

hide() {
super.hide();
}

show(opener) {
super.show(opener);
this.showActiveMedia();
}

showActiveMedia() {
this.querySelectorAll(`[data-media-id]:not([data-media-id="${this.openedBy.getAttribute("data-media-id")}"])`).forEach((element) => {
element.classList.remove('active');
}
)
const activeMedia = this.querySelector(`[data-media-id="${this.openedBy.getAttribute("data-media-id")}"]`);
const activeMediaTemplate = activeMedia.querySelector('template');
const activeMediaContent = activeMediaTemplate ? activeMediaTemplate.content : null;
activeMedia.classList.add('active');
activeMedia.scrollIntoView();

const container = this.querySelector('[role="document"]');
container.scrollLeft = (activeMedia.width - container.clientWidth) / 2;

if (activeMedia.nodeName == 'DEFERRED-MEDIA' && activeMediaContent && activeMediaContent.querySelector('.js-youtube'))
activeMedia.loadContent();
}
});
}
Loading