@thefittingroom/shop-ui 0.0.1
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/.env.dev +3 -0
- package/.env.example +3 -0
- package/.env.prod +3 -0
- package/README.md +75 -0
- package/dist/esm/components/Modals/ErrorModal.d.ts +7 -0
- package/dist/esm/components/Modals/ForgotPasswordModal.d.ts +3 -0
- package/dist/esm/components/Modals/LoadingAvatarModal.d.ts +3 -0
- package/dist/esm/components/Modals/LoggedOutModal.d.ts +3 -0
- package/dist/esm/components/Modals/ModalManager.d.ts +8 -0
- package/dist/esm/components/Modals/NoAvatarModal.d.ts +3 -0
- package/dist/esm/components/Modals/ResetLinkModal.d.ts +3 -0
- package/dist/esm/components/Modals/ScanCodeModal.d.ts +3 -0
- package/dist/esm/components/Modals/SignInModal.d.ts +3 -0
- package/dist/esm/components/Modals/SizeErrorModal.d.ts +3 -0
- package/dist/esm/components/Modals/TryOnModal.d.ts +3 -0
- package/dist/esm/components/index.d.ts +14 -0
- package/dist/esm/components/locale.d.ts +57 -0
- package/dist/esm/components/slider.d.ts +4 -0
- package/dist/esm/components/uiError.d.ts +6 -0
- package/dist/esm/helpers/telephone.d.ts +1 -0
- package/dist/esm/helpers/validations.d.ts +2 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +36258 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/index.min.js +3171 -0
- package/dist/esm/init.d.ts +2 -0
- package/dist/esm/styles/index.d.ts +7 -0
- package/dist/esm/tfr-nav.d.ts +23 -0
- package/dist/esm/tfr.d.ts +29 -0
- package/dist/esm/types/index.d.ts +145 -0
- package/index.html +126 -0
- package/package.json +35 -0
package/.env.dev
ADDED
package/.env.example
ADDED
package/.env.prod
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# The Fitting Room - Shop SDK
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
LANGUAGE_URL=https://assets.dev.thefittingroom.xyz/shop-sdk/4200127/languages
|
|
7
|
+
ASSETS_URL=https://assets.dev.thefittingroom.xyz/shop-sdk/assets
|
|
8
|
+
|
|
9
|
+
# build everytime changes are detected
|
|
10
|
+
npm run dev:rollup
|
|
11
|
+
# run a live server on localhost:3030 and disable cors
|
|
12
|
+
npx live-server --host=localhost --port=3030 --cors
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The sdk gets transpiled from typescript a javascript ESM module located at `dist/esm/main(.min).js`
|
|
16
|
+
|
|
17
|
+
You can develop locally and reference it in your html like this:
|
|
18
|
+
`import {InitFittingRoom, comps, InitLocale} from "http://localhost:3030/dist/cjs/main.js"`
|
|
19
|
+
|
|
20
|
+
## Merges on main branch
|
|
21
|
+
|
|
22
|
+
When a pull request gets merged into main, a development build gets published to S3.
|
|
23
|
+
You can access the development builds by using a commit sha on main like this:
|
|
24
|
+
|
|
25
|
+
`import {InitFittingRoom, comps, InitLocale} from "https://assets.dev.thefittingroom.xyz/shop-sdk/<COMMIT_SHA>/main.js"`
|
|
26
|
+
|
|
27
|
+
## Overriding library functions
|
|
28
|
+
|
|
29
|
+
The sdk works out of the box with modals and does not require any overriding.
|
|
30
|
+
All methods on the `tfr` object are overridable.
|
|
31
|
+
View the [FittingRoom](https://github.com/TheFittingRoom/shop-sdk/blob/96d59558bdbec6cc1e899cac297838a4810de5d4/src/types/index.ts#L63) interface to see all of the overridable function signatures.
|
|
32
|
+
The main implementation can be found in `init.ts`
|
|
33
|
+
|
|
34
|
+
```javascript
|
|
35
|
+
// use the language code in the get url (ex. ?lang=en)
|
|
36
|
+
InitLocale()
|
|
37
|
+
|
|
38
|
+
// define a modal div in the html to attach the fitting room to
|
|
39
|
+
let tfr = InitFittingRoom(1, 'tfr-tryon-modal')
|
|
40
|
+
|
|
41
|
+
// add an optional sign out button
|
|
42
|
+
let signout = document.getElementById('signout')
|
|
43
|
+
signout.addEventListener('click', () => {
|
|
44
|
+
// pass an empty sku to the onSignout since its not being used in a modal
|
|
45
|
+
// call the onSignout function wrapper to return a promise
|
|
46
|
+
// wait for the promise
|
|
47
|
+
// shows signed out modal by default
|
|
48
|
+
tfr
|
|
49
|
+
.onSignout('')()
|
|
50
|
+
.then(() => {
|
|
51
|
+
// do something after signing out of the fitting room
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
// call TryOn with a colorway_size_asset sku
|
|
56
|
+
document.getElementById('tryon').addEventListener('click', (e) => {
|
|
57
|
+
tfr.TryOn('5003-007-08')
|
|
58
|
+
})
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Localization
|
|
62
|
+
|
|
63
|
+
You can call `SetLocale` to change the language of the sdk without using url searchParams.
|
|
64
|
+
|
|
65
|
+
```javascript
|
|
66
|
+
SetLocale('en')
|
|
67
|
+
.then(() => {
|
|
68
|
+
// do something after setting the locale
|
|
69
|
+
})
|
|
70
|
+
.catch((err) => {
|
|
71
|
+
// handle error
|
|
72
|
+
})
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Warnings will be generated in the console for any missing locale definitions.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ModalContent } from '../../types';
|
|
2
|
+
interface ModalManager {
|
|
3
|
+
open(content: ModalContent): void;
|
|
4
|
+
close(): void;
|
|
5
|
+
Content(): ModalContent;
|
|
6
|
+
}
|
|
7
|
+
declare const InitModalManager: (elementID: string) => ModalManager;
|
|
8
|
+
export { InitModalManager, ModalManager };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import '../styles';
|
|
2
|
+
import ErrorModal from './Modals/ErrorModal';
|
|
3
|
+
import ForgotPasswordModal from './Modals/ForgotPasswordModal';
|
|
4
|
+
import LoadingAvatarModal from './Modals/LoadingAvatarModal';
|
|
5
|
+
import LoggedOutModal from './Modals/LoggedOutModal';
|
|
6
|
+
import { InitModalManager, ModalManager } from './Modals/ModalManager';
|
|
7
|
+
import NoAvatarModal from './Modals/NoAvatarModal';
|
|
8
|
+
import ResetLinkModal from './Modals/ResetLinkModal';
|
|
9
|
+
import ScanCodeModal from './Modals/ScanCodeModal';
|
|
10
|
+
import SignInModal from './Modals/SignInModal';
|
|
11
|
+
import SizeErrorModal from './Modals/SizeErrorModal';
|
|
12
|
+
import TryOnModal from './Modals/TryOnModal';
|
|
13
|
+
import InitImageSlider from './slider';
|
|
14
|
+
export { SignInModal, ForgotPasswordModal, ScanCodeModal, ErrorModal, LoadingAvatarModal, InitModalManager, ModalManager, NoAvatarModal, LoggedOutModal, SizeErrorModal, ResetLinkModal, InitImageSlider, TryOnModal, };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
declare var L: {
|
|
2
|
+
AssociatedEmail: string;
|
|
3
|
+
BackToSignIn: string;
|
|
4
|
+
CreateAvatarSc: string;
|
|
5
|
+
DontHaveAcc: string;
|
|
6
|
+
DontHaveAvatar: string;
|
|
7
|
+
EmailAddress: string;
|
|
8
|
+
EmailError: string;
|
|
9
|
+
EnterEmailAddress: string;
|
|
10
|
+
EnterPhoneNumber: string;
|
|
11
|
+
FailedToLoadLocale: string;
|
|
12
|
+
ForgotPassword: string;
|
|
13
|
+
ForgotPasswordWithSymbol: string;
|
|
14
|
+
GetRecommendedSizesErrorText: string;
|
|
15
|
+
GetVirtualTryOnFramesErrorText: string;
|
|
16
|
+
HaveAcc: string;
|
|
17
|
+
HowItWorks: string;
|
|
18
|
+
HowItWorksText: string;
|
|
19
|
+
Loading: string;
|
|
20
|
+
LoadingAvatar: string;
|
|
21
|
+
ModalTitle: string;
|
|
22
|
+
NoSizeAvailable: string;
|
|
23
|
+
Or: string;
|
|
24
|
+
OrSize: string;
|
|
25
|
+
Password: string;
|
|
26
|
+
PasswordError: string;
|
|
27
|
+
PhoneNumber: string;
|
|
28
|
+
ReturnToCatalogPage: string;
|
|
29
|
+
ReturnToProductPage: string;
|
|
30
|
+
ReturnToSignIn: string;
|
|
31
|
+
ReturnToSite: string;
|
|
32
|
+
ReturnToTfr: string;
|
|
33
|
+
Send: string;
|
|
34
|
+
SendPasswordResetEmailErrorText: string;
|
|
35
|
+
SignBackIn: string;
|
|
36
|
+
SignIn: string;
|
|
37
|
+
SignOut: string;
|
|
38
|
+
SignOutErrorText: string;
|
|
39
|
+
SignUp: string;
|
|
40
|
+
SimplyScan: string;
|
|
41
|
+
SimplyScanText: string;
|
|
42
|
+
SomethingIsWrongWithThisUser: string;
|
|
43
|
+
SomethingWentWrong: string;
|
|
44
|
+
StyleNotReadyForVTO: string;
|
|
45
|
+
SuccessfullyLoggedOut: string;
|
|
46
|
+
TheFittingRoom: string;
|
|
47
|
+
TryOn: string;
|
|
48
|
+
TryOnText: string;
|
|
49
|
+
TrySize: string;
|
|
50
|
+
UsernameOrPasswordEmpty: string;
|
|
51
|
+
UsernameOrPasswordIncorrect: string;
|
|
52
|
+
VirtualTryOnWith: string;
|
|
53
|
+
WeRecommendSize: string;
|
|
54
|
+
};
|
|
55
|
+
declare function SetLocale(locale: string): Promise<void>;
|
|
56
|
+
declare const InitLocale: () => Promise<string>;
|
|
57
|
+
export { InitLocale, L, SetLocale };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const initTel: (selector: string) => void;
|