@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 ADDED
@@ -0,0 +1,3 @@
1
+ NODE_ENV=dev
2
+ LANGUAGE_URL=https://assets.dev.thefittingroom.xyz/shop-sdk/${GITHUB_SHA_7}/languages
3
+ ASSETS_URL=https://assets.dev.thefittingroom.xyz/shop-sdk/assets
package/.env.example ADDED
@@ -0,0 +1,3 @@
1
+ NODE_ENV
2
+ LANGUAGE_URL
3
+ ASSETS_URL
package/.env.prod ADDED
@@ -0,0 +1,3 @@
1
+ NODE_ENV=prod
2
+ LANGUAGE_URL=https://assets.p.thefittingroom.xyz/shop-sdk/${GITHUB_REF}/languages
3
+ ASSETS_URL=https://assets.p.thefittingroom.xyz/shop-sdk/assets
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,7 @@
1
+ import { ErrorModalProps } from '../../types';
2
+ declare const ErrorModal: (props: ErrorModalProps) => {
3
+ Hook: () => void;
4
+ Unhook: () => void;
5
+ Body: () => string;
6
+ };
7
+ export default ErrorModal;
@@ -0,0 +1,3 @@
1
+ import { ForgotPasswordModalProps, ModalContent } from '../../types';
2
+ declare const ForgotPasswordModal: (props: ForgotPasswordModalProps) => ModalContent;
3
+ export default ForgotPasswordModal;
@@ -0,0 +1,3 @@
1
+ import { LoadingAvatarModalProps, ModalContent } from '../../types';
2
+ declare const LoadingAvatarModal: (props: LoadingAvatarModalProps) => ModalContent;
3
+ export default LoadingAvatarModal;
@@ -0,0 +1,3 @@
1
+ import { LoggedOutModalProps, ModalContent } from '../../types';
2
+ declare const LoggedOutModal: (props: LoggedOutModalProps) => ModalContent;
3
+ export default LoggedOutModal;
@@ -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,3 @@
1
+ import { ModalContent } from '../../types';
2
+ declare const NoAvatarModal: () => ModalContent;
3
+ export default NoAvatarModal;
@@ -0,0 +1,3 @@
1
+ import { ModalContent, ResetLinkModalProps } from '../../types';
2
+ declare const ResetLinkModal: (props: ResetLinkModalProps) => ModalContent;
3
+ export default ResetLinkModal;
@@ -0,0 +1,3 @@
1
+ import { ModalContent, ScanCodeModalProps } from '../../types';
2
+ declare const ScanCodeModal: (props: ScanCodeModalProps) => ModalContent;
3
+ export default ScanCodeModal;
@@ -0,0 +1,3 @@
1
+ import { ModalContent, SignInModalProps } from '../../types';
2
+ declare const SignInModal: (props: SignInModalProps) => ModalContent;
3
+ export default SignInModal;
@@ -0,0 +1,3 @@
1
+ import { ModalContent, SizeErrorModalProps } from '../../types';
2
+ declare const SizeErrorModal: (props: SizeErrorModalProps) => ModalContent;
3
+ export default SizeErrorModal;
@@ -0,0 +1,3 @@
1
+ import { ModalContent, TryOnModalProps } from '../../types';
2
+ declare const TryOnModal: (props: TryOnModalProps) => ModalContent;
3
+ export default TryOnModal;
@@ -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,4 @@
1
+ declare const InitImageSlider: (sliderID: string, onChange: (slider: HTMLInputElement, imageUrl: string) => void) => {
2
+ Load(imageURLs: string[]): Error | (() => void);
3
+ };
4
+ export default InitImageSlider;
@@ -0,0 +1,6 @@
1
+ interface UIError {
2
+ userMessage: string;
3
+ error: Error;
4
+ }
5
+ declare function createUIError(message: string, error?: Error): UIError;
6
+ export { createUIError, UIError };
@@ -0,0 +1 @@
1
+ export declare const initTel: (selector: string) => void;
@@ -0,0 +1,2 @@
1
+ export declare const validateEmail: (email: string) => boolean;
2
+ export declare const validatePassword: (password: string) => boolean;
@@ -0,0 +1,3 @@
1
+ export { VTO_TIMEOUT_MS } from '@thefittingroom/sdk';
2
+ export { initFittingRoom } from './init';
3
+ export type { FittingRoom } from './tfr';