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

Fix collection filtering UX #268

Merged
merged 42 commits into from
Aug 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
a53694c
Add setting to enable filtering drawer on larger devices. Adjust butt…
KaichenWang Jul 22, 2021
530342f
Update styling. Tighten spacing
KaichenWang Jul 26, 2021
dbe6059
Update from Shopify for theme dawn/fix-collection-filtering-ux
shopify[bot] Jul 26, 2021
adfd047
Update from Shopify for theme dawn/fix-collection-filtering-ux
shopify[bot] Jul 27, 2021
448e7c3
Update from Shopify for theme dawn/fix-collection-filtering-ux
shopify[bot] Jul 27, 2021
ebd55fe
Update from Shopify for theme dawn/fix-collection-filtering-ux
shopify[bot] Jul 28, 2021
5a9907b
Merge branch 'main' of https://github.com/Shopify/dawn into fix-colle…
KaichenWang Jul 28, 2021
162eaf3
Update styles and spacing for filters
KaichenWang Jul 29, 2021
3dcf91c
Adjust font sizes for filters
KaichenWang Jul 29, 2021
22f6306
Adjust alignment and spacing
KaichenWang Jul 29, 2021
93eb5c9
Update from Shopify for theme dawn/fix-collection-filtering-ux
shopify[bot] Jul 29, 2021
7915432
Update from Shopify for theme dawn/fix-collection-filtering-ux
shopify[bot] Jul 29, 2021
be307cd
Update link style for clear
KaichenWang Jul 29, 2021
76d7b51
Update from Shopify for theme dawn/fix-collection-filtering-ux
shopify[bot] Aug 2, 2021
2c9be9c
Merge branch 'fix-collection-filtering-ux' of https://github.com/Shop…
KaichenWang Aug 2, 2021
d788172
Merge branch 'main' of https://github.com/Shopify/dawn into fix-colle…
KaichenWang Aug 2, 2021
dc88f7b
Address design feedback
KaichenWang Aug 2, 2021
160e2b0
Merge branch 'main' of https://github.com/Shopify/dawn into fix-colle…
KaichenWang Aug 3, 2021
a1dd53a
Update locales
KaichenWang Aug 3, 2021
4091959
Merge branch 'main' of https://github.com/Shopify/dawn into fix-colle…
KaichenWang Aug 3, 2021
561c858
Merge branch 'main' of https://github.com/Shopify/dawn into fix-colle…
KaichenWang Aug 3, 2021
8062e64
Update locales/cs.schema.json
translation-platform Aug 4, 2021
50c7a29
Update locales/da.schema.json
translation-platform Aug 4, 2021
7b0515a
Update locales/de.schema.json
translation-platform Aug 4, 2021
7c3fa8b
Update locales/es.schema.json
translation-platform Aug 4, 2021
62d1774
Update locales/fi.schema.json
translation-platform Aug 4, 2021
e415666
Update locales/fr.schema.json
translation-platform Aug 4, 2021
1a90c93
Update locales/it.schema.json
translation-platform Aug 4, 2021
9b6a215
Update locales/ja.schema.json
translation-platform Aug 4, 2021
f7ce79b
Update locales/ko.schema.json
translation-platform Aug 4, 2021
1c01ba0
Update locales/nb.schema.json
translation-platform Aug 4, 2021
d5b31e4
Update locales/nl.schema.json
translation-platform Aug 4, 2021
dac1ee9
Update locales/pl.schema.json
translation-platform Aug 4, 2021
63bc3aa
Update locales/pt-BR.schema.json
translation-platform Aug 4, 2021
3f796ea
Update locales/pt-PT.schema.json
translation-platform Aug 4, 2021
c08219e
Update locales/sv.schema.json
translation-platform Aug 4, 2021
6f46969
Update locales/th.schema.json
translation-platform Aug 4, 2021
28a3682
Update locales/tr.schema.json
translation-platform Aug 4, 2021
8779bfb
Update locales/vi.schema.json
translation-platform Aug 4, 2021
c422df0
Update locales/zh-CN.schema.json
translation-platform Aug 4, 2021
212e99a
Update locales/zh-TW.schema.json
translation-platform Aug 4, 2021
efd9d52
Remove bubble for price filtering
KaichenWang Aug 4, 2021
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
16 changes: 12 additions & 4 deletions assets/collection-filters-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,28 @@ class CollectionFiltersForm extends HTMLElement {
this.filterData = [...this.filterData, { html, url }];
this.renderFilters(html, event);
this.renderProductGrid(html);
this.renderProductCount(html);
});
}

renderSectionFromCache(filterDataUrl, event) {
const html = this.filterData.find(filterDataUrl).html;
this.renderFilters(html, event);
this.renderProductGrid(html);
this.renderProductCount(html);
}

renderProductGrid(html) {
const innerHTML = new DOMParser()
.parseFromString(html, 'text/html')
.getElementById('CollectionProductGrid').innerHTML;
document.getElementById('CollectionProductGrid').innerHTML = new DOMParser().parseFromString(html, 'text/html').getElementById('CollectionProductGrid').innerHTML;
}

document.getElementById('CollectionProductGrid').innerHTML = innerHTML;
renderProductCount(html) {
const count = new DOMParser().parseFromString(html, 'text/html').getElementById('CollectionProductCount').innerHTML
const containerDesktop = document.getElementById('CollectionProductCountDesktop');
document.getElementById('CollectionProductCount').innerHTML = count;
if (containerDesktop) {
containerDesktop.innerHTML = count;
}
Comment on lines +82 to +84
Copy link
Contributor

Choose a reason for hiding this comment

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

Small nitpick: does it work if we use optional chaining?

document.getElementById('CollectionProductCountDesktop')?.innerHTML = count;

Copy link
Contributor

Choose a reason for hiding this comment

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

It's actually an interesting case - you can't use optional chaining for the left side of an assignment.

You can see the discussion on the proposal here:

tc39/proposal-optional-chaining#18

}

renderFilters(html, event) {
Expand Down Expand Up @@ -112,6 +119,7 @@ class CollectionFiltersForm extends HTMLElement {
const mobileElementSelectors = ['.mobile-facets__open', '.mobile-facets__count', '.sorting'];

mobileElementSelectors.forEach((selector) => {
if (!html.querySelector(selector)) return;
document.querySelector(selector).innerHTML = html.querySelector(selector).innerHTML;
});

Expand Down
Loading