Skip to content

Commit 3b9145b

Browse files
authored
Merge pull request #199 from moderntribe/release/3.13.0
packaged version 3.13.0
2 parents a9607d7 + 01f739b commit 3b9145b

29 files changed

+1624
-809
lines changed

CHANGELOG.md

+21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
# Changelog
22

3+
## [3.13.0]
4+
5+
### Added
6+
7+
- Added category and product view limitations to customers that are members of a
8+
group with product category visibility limitations.
9+
- Added a filter to modify the cache time of user group category visibility.
10+
`bigcommerce/product_category/group_filter_terms_user_cache_time` accepts a value,
11+
in seconds, for how long to cache the local list of terms by user.
12+
- Added a new tab to the Resources section in the plugin admin area. The
13+
new section, Tutorials, contains video tutorial links from BigCommerce's YouTube channel.
14+
15+
### Changed
16+
17+
- Added a feature that scrolls the browser to the top of the embedded checkout iframe
18+
upon completion of the order. This resolves an issue on smaller screens where
19+
the window would be stuck at the bottom of the page.
20+
21+
### Fixed
22+
23+
324
## [3.12.0]
425

526
### Added

assets/css/bc-admin.css

+185-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/css/bc-admin.min.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/dist/admin/scripts.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/dist/admin/scripts.min.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/dist/scripts.js

+635-635
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/dist/scripts.min.js

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/dist/vendor.js

+111-111
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/dist/vendor.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/src/admin/resources/resources.js

+49-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import delegate from 'delegate';
77
import _ from 'lodash';
88
import * as tools from '../../utils/tools';
9-
import { resourceCard, tabButton, tabCardsContent, tabContentContainer, paginationLink, noDataAvailable } from '../templates/resources';
9+
import { resourceCard, resourceVideoCard, tabButton, tabCardsContent, tabVideoCardsContent, tabContentContainer, paginationLink, noDataAvailable, videoPlaylist } from '../templates/resources';
1010
import { ADMIN_IMAGES } from '../config/wp-settings';
1111
import { on, trigger } from '../../utils/events';
1212
import scrollTo from '../../utils/dom/scroll-to';
@@ -20,6 +20,7 @@ const el = {
2020
const tabInstances = {
2121
tabs: [],
2222
cards: [],
23+
videos: [],
2324
cards_per_page: 12,
2425
};
2526

@@ -58,6 +59,41 @@ const createCards = (cards, label) => {
5859
});
5960
};
6061

62+
/**
63+
* @function createVideoCards
64+
* @description Build the HTML elements for each video card data available in the bigcommerce_resources_json JSON.
65+
* @param videos
66+
* @param label
67+
* @param playlistLabel
68+
*/
69+
const createVideoCards = (videos = {}, label = '', playlistLabel = '') => {
70+
Object.values(videos).forEach((card) => {
71+
const smallThumb = _.get(card, 'thumbnail.small');
72+
const largeThumb = _.get(card, 'thumbnail.large');
73+
// If we have images, use them. Otherwise, we'll use the BigCommerce logo thumbnail placeholder.
74+
const image1 = smallThumb ? `${smallThumb} 1x,` : `${ADMIN_IMAGES}bigcommerce-resource-thumbnail.png 1x,`;
75+
const image2 = largeThumb ? `${largeThumb} 2x,` : `${ADMIN_IMAGES}bigcommerce-resource-thumbnail-2x.png 2x`;
76+
// Create a card and push it as a new indexed item in the cards array.
77+
tabInstances.videos[playlistLabel].push(resourceVideoCard(image1, image2, card.name, card.video_length, card.description, card.url));
78+
});
79+
};
80+
81+
/**
82+
* @function createVideoPlaylists
83+
* @description Creates an array of playlists with completed markup.
84+
* @param playlists
85+
* @param label
86+
*/
87+
const createVideoPlaylists = (playlists = {}, label = '') => {
88+
Object.values(playlists).forEach((playlist) => {
89+
const playlistLabel = playlist.playlist_label;
90+
tabInstances.videos[playlistLabel] = [];
91+
92+
tabInstances.videos[playlistLabel].push(createVideoCards(playlist.videos, label, playlistLabel));
93+
tabInstances.cards[label].push(videoPlaylist(playlistLabel, playlist.playlist, tabInstances.videos[playlistLabel].join(''), tabInstances.videos[playlistLabel].length - 1));
94+
});
95+
};
96+
6197
/**
6298
* @function createTabs
6399
* @description Create a new tab button for each available tabInstances.tabs;
@@ -104,7 +140,6 @@ const createTabContentContainers = () => {
104140
// Create a wrapper element to attach the containers to.
105141
const contentWrapper = document.createElement('div');
106142
tools.addClass(contentWrapper, 'bc-resources-tabs__content');
107-
tools.addClass(contentWrapper, 'bc-resources-tabs__max-width');
108143
el.contentContainer.appendChild(contentWrapper);
109144

110145
// Loop through the available keys and create the parent container tied to the tab button.
@@ -223,7 +258,12 @@ const getPaginatedItems = (e, cardKey = '', currentPage = 1) => {
223258
const offset = (currentPage - 1) * tabInstances.cards_per_page;
224259
const paginatedItems = tabInstances.cards[key].slice(offset, offset + tabInstances.cards_per_page);
225260

226-
cardPageWrapper.insertAdjacentHTML('beforeend', tabCardsContent(key, paginatedItems.join(''), currentPage));
261+
if (key === 'Tutorials') {
262+
cardPageWrapper.insertAdjacentHTML('beforeend', tabVideoCardsContent(key, paginatedItems.join(''), currentPage));
263+
} else {
264+
cardPageWrapper.insertAdjacentHTML('beforeend', tabCardsContent(key, paginatedItems.join(''), currentPage));
265+
}
266+
227267
focusFirstPagedCard(key, currentPage);
228268
};
229269

@@ -274,7 +314,12 @@ const initResourceCards = () => {
274314

275315
tabInstances.tabs.push(tabButton(section.label));
276316
tabInstances.cards[section.label] = [];
277-
createCards(section.resources, section.label);
317+
318+
if (section.label === 'Tutorials') {
319+
createVideoPlaylists(section.resources, section.label);
320+
} else {
321+
createCards(section.resources, section.label);
322+
}
278323
});
279324

280325
createTabs();

assets/js/src/admin/templates/resources.js

+52-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { I18N } from '../config/i18n';
22

3+
const { _n, sprintf } = wp.i18n;
4+
35
export const noDataAvailable = (
46
`
57
<div class="bc-resources-no-data">
@@ -18,20 +20,42 @@ export const tabButton = tabName => (
1820

1921
export const tabContentContainer = tabName => (
2022
`
21-
<div class="bc-resources-tabs__tab-content-container" data-js="bc-resource-tab-content" data-tab-name="${tabName}" aria-hidden="true">
23+
<div class="bc-resources-tabs__tab-content-container bc-resources-container-${tabName.toLowerCase()}" data-js="bc-resource-tab-content" data-tab-name="${tabName}" aria-hidden="true">
2224
<div class="bc-resources-pagination-wrapper" role="navigation" aria-label="${tabName} Pagination Navigation"></div>
2325
</div>
2426
`
2527
);
2628

2729
export const tabCardsContent = (tabName, cards, pageNumber) => (
2830
`
29-
<div class="bc-resources-tabs__paged-cards bc-cards-page-active" data-js="bc-resource-tab-cards" data-resource-page-name="${tabName}" data-resource-page-number="${pageNumber}" aria-hidden="false">
31+
<div class="bc-resources-tabs__paged-cards bc-resources-tabs__max-width bc-cards-page-active" data-js="bc-resource-tab-cards" data-resource-page-name="${tabName}" data-resource-page-number="${pageNumber}" aria-hidden="false">
3032
${cards}
3133
</div>
3234
`
3335
);
3436

37+
export const videoPlaylist = (playlistName, playlistNumber, cards, videoCount) => (
38+
`
39+
<div class="bc-resource-tab-playlist bc-resource-tab-playlist--${playlistNumber}">
40+
<h3 class="bc-resources-tabs__max-width bc-resource-tab-playlist-name">
41+
${playlistNumber !== '00' ? `<strong>${playlistNumber}</strong> ` : ''}${playlistName}
42+
<span class="bc-playlist-count">${sprintf(_n('%s Video', '%s Videos', videoCount, 'bigcommerce'), videoCount)}</span>
43+
</h3>
44+
<div class="bc-resource-tab-playlist-cards">
45+
${cards}
46+
</div>
47+
</div>
48+
`
49+
);
50+
51+
export const tabVideoCardsContent = (tabName, playlists, pageNumber) => (
52+
`
53+
<div class="bc-resources-tabs__paged-cards bc-resources-content-${tabName.toLowerCase()} bc-cards-page-active" data-js="bc-resource-tab-cards" data-resource-page-name="${tabName}" data-resource-page-number="${pageNumber}" aria-hidden="false">
54+
${playlists}
55+
</div>
56+
`
57+
);
58+
3559
export const resourceCard = (image, image2x, title, description, link) => (
3660
`
3761
<div class="bc-resource-card" data-js="bc-resource-card">
@@ -52,6 +76,32 @@ export const resourceCard = (image, image2x, title, description, link) => (
5276
`
5377
);
5478

79+
export const resourceVideoCard = (image, image2x, title, length, description, link) => (
80+
`
81+
<div class="bc-resource-card--video" data-js="bc-resource-card">
82+
<a href="${link}" class="bc-resource-card__video-link" target="_blank" rel="noopener" title="${title}" tabindex="699">
83+
<div class="bc-resource-card__image">
84+
<div class="bc-resource-card__img-overlay"></div>
85+
<img
86+
srcset="${image}${image2x}"
87+
alt="${title} ${description}"
88+
>
89+
</div>
90+
</a>
91+
<div class="bc-resource-card__content">
92+
<h4 class="bc-resource-card__title">
93+
<a href="${link}" class="bc-resource-card__video-link" target="_blank" rel="noopener" title="${title}" tabindex="699">${title}</a>
94+
</h4>
95+
<span class="bc-resource-card__video-length">${length}</span>
96+
${description.length > 0 ?
97+
`<p class="bc-resource-card__video-description">${description}</p>`
98+
:
99+
''}
100+
</div>
101+
</div>
102+
`
103+
);
104+
55105
export const paginationLink = (pageNumber, pageName) => (
56106
`
57107
<button

assets/js/src/public/checkout/embedded-checkout.js

+28-5
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
*/
55

66
import Cookie from 'js-cookie';
7+
import _ from 'lodash';
78
import { embedCheckout } from '@bigcommerce/checkout-sdk';
89
import * as tools from 'utils/tools';
10+
import scrollTo from 'utils/dom/scroll-to';
911
import { CART_ID_COOKIE_NAME, CART_ITEM_COUNT_COOKIE } from 'bcConstants/cookies';
1012
import { cartEmpty } from '../cart/cart-templates';
1113

@@ -23,11 +25,31 @@ const clearCartData = () => {
2325
return;
2426
}
2527

26-
const cartMenuCount = tools.getNodes('.bigcommerce-cart__item-count', false, document, true)[0];
27-
Cookie.remove(CART_ITEM_COUNT_COOKIE);
28-
tools.removeClass(cartMenuCount, 'full');
29-
cartMenuCount.textContent = '';
30-
Cookie.remove(CART_ID_COOKIE_NAME);
28+
const cartMenuCount = tools.getNodes('.bigcommerce-cart__item-count', true, document, true);
29+
30+
_.delay(() => {
31+
Cookie.remove(CART_ITEM_COUNT_COOKIE);
32+
Cookie.remove(CART_ID_COOKIE_NAME);
33+
34+
cartMenuCount.forEach((menuItem) => {
35+
tools.removeClass(menuItem, 'full');
36+
menuItem.textContent = '';
37+
});
38+
}, 250);
39+
};
40+
41+
/**
42+
* @function scrollIframe
43+
* @description After completing the checkout process, ensure the top of the embedded checkout is visible using scrollTo.
44+
*/
45+
const scrollIframe = () => {
46+
const options = {
47+
offset: -80,
48+
duration: 750,
49+
$target: jQuery(el.container),
50+
};
51+
52+
_.delay(() => scrollTo(options), 1000);
3153
};
3254

3355
/**
@@ -46,6 +68,7 @@ const loadEmbeddedCheckout = () => {
4668

4769
// Set the onComplete callback to use the clearCartData function.
4870
config.onComplete = clearCartData;
71+
config.onComplete = scrollIframe;
4972

5073
// Embed the checkout.
5174
embedCheckout(config);

assets/pcss/admin/bc-admin.pcss

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
@import './pages/settings/plugin-complete';
3636
@import './pages/resources/tabs';
3737
@import './pages/resources/cards';
38+
@import './pages/resources/tutorials';
3839

3940
/* Admin UI Styles */
4041
@import './shortcode-ui/dialog-ui';

assets/pcss/admin/pages/resources/_tabs.pcss

+12-6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
margin-top: 86px;
1010
}
1111
}
12+
13+
#wpcontent {
14+
padding-left: 0;
15+
}
1216
}
1317

1418
.bc-resources-content {
@@ -17,11 +21,11 @@
1721
}
1822

1923
.bc-resources {
20-
margin: 10px 20px 10px 10px;
24+
margin: 10px 0;
2125
font-size: 16px;
2226

23-
@media (--viewport-wpadmin) {
24-
margin: 10px 20px 0 0;
27+
@media (--viewport-xlarge) {
28+
margin: 10px 0 0;
2529
}
2630
}
2731

@@ -33,8 +37,10 @@
3337

3438
.bc-resources-header {
3539
position: relative;
40+
box-sizing: border-box;
3641
min-height: 276px;
37-
margin-top: 0;
42+
margin: 0 20px;
43+
width: calc(100% - 40px);
3844
display: flex;
3945
flex-direction: row;
4046

@@ -157,13 +163,13 @@
157163
position: absolute;
158164
top: 0;
159165
left: 0;
160-
width: 100%;
166+
width: calc(100% - 40px);
161167
height: 100%;
162168
opacity: 0;
163169
z-index: 0;
164170
background-color: var(--color-white);
165171
transition: var(--transition-opacity);
166-
padding-top: 58px;
172+
padding: 58px 20px 0;
167173
display: flex;
168174
flex-direction: column;
169175
justify-content: flex-start;

0 commit comments

Comments
 (0)