@thefittingroom/shop-ui 1.1.6 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/components/SizeRec.d.ts +5 -4
- package/dist/esm/index.js +40 -19
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +176 -176
- package/package.json +2 -2
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { TfrShop } from '@thefittingroom/sdk';
|
|
2
1
|
export type RecommendedSize = {
|
|
3
2
|
recommended: string;
|
|
4
3
|
sizes: {
|
|
@@ -10,10 +9,12 @@ export type RecommendedSize = {
|
|
|
10
9
|
}[];
|
|
11
10
|
};
|
|
12
11
|
export declare class SizeRecComponent {
|
|
13
|
-
private readonly tfrShop;
|
|
14
12
|
private readonly onSignInClick;
|
|
15
13
|
private readonly onSignOutClick;
|
|
16
14
|
private _sku;
|
|
15
|
+
private isLoggedIn;
|
|
16
|
+
private tfrSizeRecTitle;
|
|
17
|
+
private tfrSizeRecSubtitle;
|
|
17
18
|
private tfrSizeRecActionLogin;
|
|
18
19
|
private tfrSizeRecActionLogout;
|
|
19
20
|
private tfrSizeRecLoading;
|
|
@@ -23,14 +24,14 @@ export declare class SizeRecComponent {
|
|
|
23
24
|
private tfrSizeRecSize;
|
|
24
25
|
private tfrSizeRecTable;
|
|
25
26
|
private redraw;
|
|
26
|
-
constructor(sizeRecMainDivId: string,
|
|
27
|
+
constructor(sizeRecMainDivId: string, onSignInClick: () => void, onSignOutClick: () => void);
|
|
27
28
|
get sku(): string;
|
|
28
29
|
setSku(sku: string): void;
|
|
29
30
|
setIsLoggedIn(isLoggedIn: boolean): void;
|
|
30
31
|
setLoading(isLoading: boolean): void;
|
|
31
32
|
setGarmentLocations(locations: string[]): void;
|
|
32
33
|
setRecommendedSize({ recommended, sizes }: RecommendedSize): void;
|
|
33
|
-
setError(
|
|
34
|
+
setError(): void;
|
|
34
35
|
private init;
|
|
35
36
|
private setElements;
|
|
36
37
|
private bindEvents;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* thefittingroom v1.1.
|
|
2
|
+
* thefittingroom v1.1.8 (2024-05-16T03:17:08.880Z)
|
|
3
3
|
* Copyright 2022-present, TheFittingRoom, Inc. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
function loadImageRecursive(imageURL, imageURLs) {
|
|
@@ -47,7 +47,7 @@ const InitImageSlider = (sliderID, onChange) => {
|
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
/*!
|
|
50
|
-
* thefittingroom v1.1.
|
|
50
|
+
* thefittingroom v1.1.5 (2024-05-16T02:24:56.143Z)
|
|
51
51
|
* Copyright 2022-present, TheFittingRoom, Inc. All rights reserved.
|
|
52
52
|
*/
|
|
53
53
|
|
|
@@ -23504,7 +23504,7 @@ n(css$5,{});
|
|
|
23504
23504
|
var css$4 = "@media screen and (max-width:702px){.tfr-modal-title-logo-container{display:flex;flex-direction:column}}@media screen and (min-width:600px){.tfr-modal-content-container{border-radius:10px;height:auto}}@media screen and (max-width:599px){.tfr-mobile-hidden{display:none}.tfr-modal-content-container{min-height:100vh}.trf-logo-title{margin-bottom:10px}.tfr-modal-content-flex{height:calc(100vh - 76px)}}@media screen and (max-width:500px){.tfr-fieldset{width:90%}.tfr-how-it-works-item{flex-direction:column}.tfr-try-on-content{margin-left:0;margin-top:20px}}";
|
|
23505
23505
|
n(css$4,{});
|
|
23506
23506
|
|
|
23507
|
-
var css$3 = "#tfr-size-recommendations{border:1px solid hsla(0,0%,7%,.55);color:#121212;display:flex;padding:14px 20px;width:440px}#tfr-size-recommendations,#tfr-size-recommendations-container{align-items:center;flex-direction:column;justify-content:center}#tfr-size-recommendations-container{display:none;width:100%}#tfr-size-rec-login-svg{display:none}#tfr-size-rec-title{align-items:center;display:flex;margin-bottom:8px}#tfr-size-rec-subtitle{margin-bottom:6px}#tfr-size-rec-subtitle,#tfr-size-rec-title{font-size:16px;font-weight:700}#tfr-size-rec-table{display:flex;flex-direction:column;font-size:12px;width:100%}.tfr-size-rec-table-row:first-of-type{border-top-width:2px}.tfr-size-rec-table-row{align-items:center;border-top:1px solid hsla(0,0%,7%,.55);display:flex;height:40px;justify-content:center}.tfr-size-rec-table-cell-left,.tfr-size-rec-table-cell-right{flex:1 1 0px}.tfr-size-rec-table-cell-left{font-weight:700;margin-right:70px;text-align:right}.tfr-size-rec-table-cell-right{margin-left:16px}.tfr-size-rec-table-cell-right.perfect{color:#209da7}#tfr-size-rec-size>.tfr-size-rec-login-cta{font-weight:500;margin-left:10px}.tfr-size-rec-login-cta,.tfr-size-rec-table-cell-right{font-size:12px}.tfr-size-rec-login-cta{color:#a7a7a7;display:flex}#tfr-size-rec-action-login,#tfr-size-rec-action-logout{display:none}#tfr-size-rec-action{cursor:pointer;font-size:16px;margin-top:14px;text-decoration:underline}#tfr-size-rec-select{background-color:#878787;border-radius:8px;box-shadow:0 4px 4px 0 rgba(0,0,0,.3);color:#fff;display:none;font-size:14px;margin-bottom:20px;margin-top:10px}#tfr-size-rec-select,.tfr-size-rec-select-button{align-items:center;height:35px;justify-content:center}.tfr-size-rec-select-button{cursor:pointer;display:flex;transition:all .15s ease-in;width:80px}.tfr-size-rec-select-button:hover:not(.active){background-color:hsla(0,0%,100%,.3);opacity:.7}.tfr-size-rec-select-button.active{background-color:#212121;height:45px}.tfr-size-rec-select-button.active,.tfr-size-rec-select-button:first-of-type{border-bottom-left-radius:8px;border-top-left-radius:8px}.tfr-size-rec-select-button.active,.tfr-size-rec-select-button:last-of-type{border-bottom-right-radius:8px;border-top-right-radius:8px}.tfr-powered-by{align-items:center;display:flex;font-size:10px;margin-top:10px}.tfr-powered-by-logo{margin:0 4px}.tfr-powered-by-logo,.tfr-powered-by-logo img{height:24px}.tfr-powered-by-text-bold{font-weight:700}";
|
|
23507
|
+
var css$3 = "#tfr-size-recommendations{border:1px solid hsla(0,0%,7%,.55);color:#121212;display:flex;padding:14px 20px;width:440px}#tfr-size-recommendations,#tfr-size-recommendations-container{align-items:center;flex-direction:column;justify-content:center}#tfr-size-recommendations-container{display:none;width:100%}#tfr-size-rec-login-svg{display:none}#tfr-size-rec-title{align-items:center;display:flex;margin-bottom:8px}#tfr-size-rec-subtitle{margin-bottom:6px}#tfr-size-rec-subtitle,#tfr-size-rec-title{font-size:16px;font-weight:700}#tfr-size-rec-table{display:flex;flex-direction:column;font-size:12px;width:100%}.tfr-size-rec-table-row:first-of-type{border-top-width:2px}.tfr-size-rec-table-row{align-items:center;border-top:1px solid hsla(0,0%,7%,.55);display:flex;height:40px;justify-content:center}.tfr-size-rec-table-cell-left,.tfr-size-rec-table-cell-right{flex:1 1 0px}.tfr-size-rec-table-cell-left{font-weight:700;margin-right:70px;text-align:right}.tfr-size-rec-table-cell-right{margin-left:16px}.tfr-size-rec-table-cell-right.perfect{color:#209da7}#tfr-size-rec-size{display:inline-block}#tfr-size-rec-size>.tfr-size-rec-login-cta{font-weight:500;margin-left:10px}.tfr-size-rec-login-cta,.tfr-size-rec-table-cell-right{font-size:12px}.tfr-size-rec-login-cta{color:#a7a7a7;display:flex}#tfr-size-rec-action-login,#tfr-size-rec-action-logout{display:none}#tfr-size-rec-action{cursor:pointer;font-size:16px;margin-top:14px;text-decoration:underline}#tfr-size-rec-select{background-color:#878787;border-radius:8px;box-shadow:0 4px 4px 0 rgba(0,0,0,.3);color:#fff;display:none;font-size:14px;margin-bottom:20px;margin-top:10px}#tfr-size-rec-select,.tfr-size-rec-select-button{align-items:center;height:35px;justify-content:center}.tfr-size-rec-select-button{cursor:pointer;display:flex;transition:all .15s ease-in;width:80px}.tfr-size-rec-select-button:hover:not(.active){background-color:hsla(0,0%,100%,.3);opacity:.7}.tfr-size-rec-select-button.active{background-color:#212121;height:45px}.tfr-size-rec-select-button.active,.tfr-size-rec-select-button:first-of-type{border-bottom-left-radius:8px;border-top-left-radius:8px}.tfr-size-rec-select-button.active,.tfr-size-rec-select-button:last-of-type{border-bottom-right-radius:8px;border-top-right-radius:8px}.tfr-powered-by{align-items:center;display:flex;font-size:10px;margin-top:10px}.tfr-powered-by-logo{margin:0 4px}.tfr-powered-by-logo,.tfr-powered-by-logo img{height:24px}.tfr-powered-by-text-bold{font-weight:700}#tfr-size-recommendation-error{color:#8d0000;display:none}";
|
|
23508
23508
|
n(css$3,{});
|
|
23509
23509
|
|
|
23510
23510
|
var css$2 = ".tfr-mt-10{margin-top:10px}.tfr-mt-20{margin-top:20px}.tfr-mt-15{margin-top:15px}.tfr-mt-30{margin-top:30px}.mt-40{margin-top:40px}.tfr-mb-40{margin-bottom:40px}.tfr-mb-20{margin-bottom:20px}.tfr-mr-10{margin-right:10px}.tfr-mr-15{margin-right:15px}.tfr-mt-50{margin-top:50px}.tfr-mt-60{margin-top:60px}.tfr-mb-60{margin-bottom:60px}.tfr-mr-20{margin-right:20px}.tfr-mt-15-p{margin-top:15%}.tfr-mb-13-p{margin-bottom:13%}.tfr-m-h-auto{margin-left:auto;margin-right:auto}.tfr-pt-20{padding-top:20px}.tfr-pb-50{padding-bottom:50px}.tfr-p-20{padding:20px}.tfr-pr-20{padding-right:20px}.tfr-pl-20{padding-left:20px}.tfr-pb-7-p{padding-bottom:7%}";
|
|
@@ -36435,11 +36435,11 @@ class TfrModal {
|
|
|
36435
36435
|
const loginIconSrc = 'https://assets.dev.thefittingroom.xyz/shop-sdk/assets/login-icon.svg';
|
|
36436
36436
|
const doorLogoSrc = 'https://assets.dev.thefittingroom.xyz/shop-sdk/assets/tfr-door-brand.svg';
|
|
36437
36437
|
class SizeRecComponent {
|
|
36438
|
-
constructor(sizeRecMainDivId,
|
|
36439
|
-
this.tfrShop = tfrShop;
|
|
36438
|
+
constructor(sizeRecMainDivId, onSignInClick, onSignOutClick) {
|
|
36440
36439
|
this.onSignInClick = onSignInClick;
|
|
36441
36440
|
this.onSignOutClick = onSignOutClick;
|
|
36442
36441
|
this._sku = '';
|
|
36442
|
+
this.isLoggedIn = false;
|
|
36443
36443
|
this.redraw = null;
|
|
36444
36444
|
this.init(sizeRecMainDivId);
|
|
36445
36445
|
}
|
|
@@ -36450,9 +36450,12 @@ class SizeRecComponent {
|
|
|
36450
36450
|
this._sku = sku;
|
|
36451
36451
|
}
|
|
36452
36452
|
setIsLoggedIn(isLoggedIn) {
|
|
36453
|
+
this.isLoggedIn = isLoggedIn;
|
|
36453
36454
|
if (isLoggedIn) {
|
|
36454
36455
|
this.tfrSizeRecActionLogin.style.display = 'none';
|
|
36455
36456
|
this.tfrSizeRecActionLogout.style.display = 'block';
|
|
36457
|
+
this.tfrSizeRecTitle.style.display = 'block';
|
|
36458
|
+
this.tfrSizeRecSubtitle.style.display = 'block';
|
|
36456
36459
|
}
|
|
36457
36460
|
else {
|
|
36458
36461
|
this.tfrSizeRecActionLogin.style.display = 'block';
|
|
@@ -36470,6 +36473,11 @@ class SizeRecComponent {
|
|
|
36470
36473
|
}
|
|
36471
36474
|
}
|
|
36472
36475
|
setGarmentLocations(locations) {
|
|
36476
|
+
if (!locations || !locations.length) {
|
|
36477
|
+
this.tfrSizeRecTitle.style.display = 'none';
|
|
36478
|
+
this.tfrSizeRecSubtitle.style.display = 'none';
|
|
36479
|
+
return;
|
|
36480
|
+
}
|
|
36473
36481
|
this.renderGarmentLocations(locations);
|
|
36474
36482
|
this.tfrSizeRecSelect.style.display = 'none';
|
|
36475
36483
|
}
|
|
@@ -36477,8 +36485,13 @@ class SizeRecComponent {
|
|
|
36477
36485
|
this.renderSizeRec(recommended, sizes);
|
|
36478
36486
|
this.tfrSizeRecSelect.style.display = 'flex';
|
|
36479
36487
|
}
|
|
36480
|
-
setError(
|
|
36481
|
-
this.
|
|
36488
|
+
setError() {
|
|
36489
|
+
this.tfrSizeRecTitle.style.display = 'none';
|
|
36490
|
+
this.tfrSizeRecSubtitle.style.display = 'none';
|
|
36491
|
+
if (!this.isLoggedIn)
|
|
36492
|
+
return;
|
|
36493
|
+
this.tfrSizeRecommendationError.style.display = 'block';
|
|
36494
|
+
this.tfrSizeRecommendationError.innerHTML = 'No recommended size found.';
|
|
36482
36495
|
}
|
|
36483
36496
|
init(sizeRecMainDivId) {
|
|
36484
36497
|
const sizeRecMainDiv = document.getElementById(sizeRecMainDivId);
|
|
@@ -36489,6 +36502,8 @@ class SizeRecComponent {
|
|
|
36489
36502
|
this.bindEvents();
|
|
36490
36503
|
}
|
|
36491
36504
|
setElements() {
|
|
36505
|
+
this.tfrSizeRecTitle = document.getElementById('tfr-size-rec-title');
|
|
36506
|
+
this.tfrSizeRecSubtitle = document.getElementById('tfr-size-rec-subtitle');
|
|
36492
36507
|
this.tfrSizeRecActionLogin = document.getElementById('tfr-size-rec-action-login');
|
|
36493
36508
|
this.tfrSizeRecActionLogout = document.getElementById('tfr-size-rec-action-logout');
|
|
36494
36509
|
this.tfrSizeRecTable = document.getElementById('tfr-size-rec-table');
|
|
@@ -36568,12 +36583,12 @@ class SizeRecComponent {
|
|
|
36568
36583
|
</div>
|
|
36569
36584
|
</div>
|
|
36570
36585
|
<div id="tfr-size-recommendations-container">
|
|
36571
|
-
<img id="tfr-size-rec-login-svg" src="{
|
|
36586
|
+
<img id="tfr-size-rec-login-svg" src="${loginIconSrc}" />
|
|
36572
36587
|
<div id="tfr-size-rec-title">
|
|
36573
36588
|
Recommended Size:
|
|
36574
36589
|
<div id="tfr-size-rec-size">
|
|
36575
36590
|
<div class="tfr-size-rec-login-cta">
|
|
36576
|
-
<img src="{
|
|
36591
|
+
<img src="${loginIconSrc}" /> Login to view
|
|
36577
36592
|
</div>
|
|
36578
36593
|
</div>
|
|
36579
36594
|
</div>
|
|
@@ -36595,7 +36610,8 @@ class SizeRecComponent {
|
|
|
36595
36610
|
<div class="tfr-powered-by-text-bold">The Fitting Room</div>
|
|
36596
36611
|
</div>
|
|
36597
36612
|
</div>
|
|
36598
|
-
</div
|
|
36613
|
+
</div>
|
|
36614
|
+
<div id="tfr-size-recommendation-error"></div>`;
|
|
36599
36615
|
sizeRecMainDiv.innerHTML = body;
|
|
36600
36616
|
}
|
|
36601
36617
|
}
|
|
@@ -36605,7 +36621,7 @@ class TfrSizeRec {
|
|
|
36605
36621
|
this.tfrShop = tfrShop;
|
|
36606
36622
|
this.onSignInClick = onSignInClick;
|
|
36607
36623
|
this.onSignOutClick = onSignOutClick;
|
|
36608
|
-
this.sizeRecComponent = new SizeRecComponent(sizeRecMainDivId, this.
|
|
36624
|
+
this.sizeRecComponent = new SizeRecComponent(sizeRecMainDivId, this.onSignInClick, this.onSignOutClick);
|
|
36609
36625
|
}
|
|
36610
36626
|
get sku() {
|
|
36611
36627
|
return this.sizeRecComponent.sku;
|
|
@@ -36619,16 +36635,19 @@ class TfrSizeRec {
|
|
|
36619
36635
|
async setGarmentLocations() {
|
|
36620
36636
|
this.sizeRecComponent.setLoading(true);
|
|
36621
36637
|
const locations = await this.getGarmentLocations();
|
|
36622
|
-
|
|
36623
|
-
|
|
36624
|
-
this.sizeRecComponent.setGarmentLocations(locations);
|
|
36638
|
+
console.debug('locations', locations);
|
|
36639
|
+
this.sizeRecComponent.setGarmentLocations(locations || []);
|
|
36625
36640
|
this.sizeRecComponent.setLoading(false);
|
|
36626
36641
|
}
|
|
36627
36642
|
async setRecommendedSize() {
|
|
36628
36643
|
this.sizeRecComponent.setLoading(true);
|
|
36629
36644
|
const sizes = await this.getRecommenedSize();
|
|
36630
|
-
if (!sizes)
|
|
36645
|
+
if (!sizes) {
|
|
36646
|
+
console.error('No sizes found for sku');
|
|
36647
|
+
this.sizeRecComponent.setLoading(false);
|
|
36648
|
+
this.sizeRecComponent.setError();
|
|
36631
36649
|
return;
|
|
36650
|
+
}
|
|
36632
36651
|
this.sizeRecComponent.setRecommendedSize(sizes);
|
|
36633
36652
|
this.sizeRecComponent.setLoading(false);
|
|
36634
36653
|
}
|
|
@@ -36638,7 +36657,8 @@ class TfrSizeRec {
|
|
|
36638
36657
|
return locations;
|
|
36639
36658
|
}
|
|
36640
36659
|
catch (error) {
|
|
36641
|
-
|
|
36660
|
+
console.error(error);
|
|
36661
|
+
this.sizeRecComponent.setError();
|
|
36642
36662
|
return null;
|
|
36643
36663
|
}
|
|
36644
36664
|
}
|
|
@@ -36649,7 +36669,8 @@ class TfrSizeRec {
|
|
|
36649
36669
|
return sizes;
|
|
36650
36670
|
}
|
|
36651
36671
|
catch (error) {
|
|
36652
|
-
|
|
36672
|
+
console.error(error);
|
|
36673
|
+
this.sizeRecComponent.setError();
|
|
36653
36674
|
return null;
|
|
36654
36675
|
}
|
|
36655
36676
|
}
|
|
@@ -36658,10 +36679,10 @@ class TfrSizeRec {
|
|
|
36658
36679
|
if (!sizeRec)
|
|
36659
36680
|
return null;
|
|
36660
36681
|
return {
|
|
36661
|
-
recommended: sizeRec.recommended_size.
|
|
36682
|
+
recommended: sizeRec.recommended_size.label,
|
|
36662
36683
|
sizes: sizeRec.fits.map((fit) => {
|
|
36663
36684
|
return {
|
|
36664
|
-
size: sizeRec.available_sizes.find((size) => size.id === fit.size_id).
|
|
36685
|
+
size: sizeRec.available_sizes.find((size) => size.id === fit.size_id).label,
|
|
36665
36686
|
locations: fit.measurement_location_fits.map((locationFit) => {
|
|
36666
36687
|
return {
|
|
36667
36688
|
fit: index.FitNames[locationFit.fit],
|