0.1.286-prod • Published 9 months ago

zakeke-configurator-react v0.1.286-prod

Weekly downloads
422
License
-
Repository
-
Last release
9 months ago

🌐 Zakeke Configurator for React 🚀

This library allows you to build a custom UI for the Zakeke 3D configurator tool. Create your own unique and immersive 3D experience with ease!

🔧 Prerequisites 🛠️

Before you can use this project, you will need to install Node.js, a JavaScript runtime built on Chrome's V8 JavaScript engine. Here's how to do it:

  1. Download the latest version of Node.js from the official Node.js website.

  2. Run the installation file and follow the prompts in the Node.js Setup Wizard.

  3. To confirm that Node.js was installed correctly, open your command prompt and run the following command:

node -v

You should see your installed version of Node.js displayed in the command prompt.

🛠️ Installation and Running a Basic Example 🏃‍♂️

To get started with this project, follow these steps:

  1. Clone the project repository using the following command:
git clone https://github.com/UpCommerce/zakeke-configurator-react-example.git
  1. Install the necessary dependencies:
npm install
  1. Start the project:
npm run start

After running the example, a blank page will open on localhost:3000. This is because Zakeke requires some parameters to know what product to load. Let's get these parameters!

🎯 Getting the Parameters 🌐

Follow these steps to get all the parameters:

  1. Go to the Zakeke configurator backoffice.

  2. Add or edit a new product.

  3. Navigate to the Shopping Preview page.

  4. Right-click on the page -> inspect element.

  5. Find the Zakeke <iframe> src attribute and copy all query string parameters.

  6. Paste the parameters in the localhost page.

Your URL should look something like this:

http://localhost:3000?modelCode=XXX&culture=XX&token=XXXXXX....

With these parameters, you should see the product loading in a basic UI interface. Start customizing it to your needs!

📚 References 📖

The library exposes four key elements:

  • ZakekeEnvironment: A class that contains the state of the current scene.

  • ZakekeProvider: A React component that should wrap your application.

  • ZakekeViewer: A React component that will render the 3D scene.

  • useZakeke: An effect to retrieve data and execute methods.

Here is how a basic Zakeke theme would look like:

const zakekeEnvironment = new ZakekeEnvironment();

<ZakekeProvider environment={zakekeEnvironment}>
	<div>
		<ZakekeViewer />
	</div>
</ZakekeProvider>

📚 Documentation Reference 📚

useZakeke exposes the following values:

    price: number;
	isOutOfStock: boolean;
	culture: string;
	currency: string;
	isSceneLoading: boolean;
	isAddToCartLoading: boolean;
	isInfoPointContentVisible: boolean;
	isViewerReady: boolean;
	fonts: FontFamily[];
	disableTextColors: boolean;
	defaultColor: string;
	textColors: RestrictionColor[];
	groups: Group[];
	templates: Template[];
	loadedComposition: { templateName: string; attributesOptions: Map<number, number>; selectedCategoryID: number | null } | null;
	currentTemplate: Template | null;
	items: Item[];
	productName: string;
	productCode: string;
	product: Product | null;
	cameras: Camera[];
	sellerSettings: SellerSettings | null;
	quantityRule: ProductQuantityRule | null;
	eventMessages: EventMessage[] | null;
	personalizedMessages: EventMessage[] | null;
	visibleEventMessages: VisibleEventMessage[];
	isAssetsLoading: boolean;
	draftCompositions: ThemeCompositions[] | null;
	additionalCustomProperties: { name: string; value: number; label: string; formatString: string }[] | null;
	currentAttributesSelection: object | null;
	currentCompositionInfo: { compositionId: string | null; compositionName: string | null; compositionTags: string[] | null } | null;
	translations: Translations | null;
	nftSettings: NftSettings | null;
	useLegacyScreenshot: boolean;
	isAIEnabled: boolean;
	uiConfig: UIConfig | null;
	backgroundColor: string;
	removeBackground: boolean;
	setMouseWheelZoomEnabled: (enabled: boolean) => void;
	selectOption: (optionId: number) => void;
	/**
	 * @internal
	 */
	internalAppendViewer: (container: HTMLElement) => void;
	getPrintingMethodsRestrictions: () => PrintingMethodsRestrictions;
	designUpdate: () => void;
	createQuote: (formData: any) => Promise<any>;
	setTemplate: (templateId: number) => Promise<void>;
	isAreaVisible: (areaId: number) => boolean;
	quantity: number;
	saveTemplate: (templateName: string, selectedCategoryID: number | null, attributesOptions: Map<number, number>) => Promise<void>;
	addToCart: (
		additionalProperties: Record<string, any>,
		OnBeforeSendDataToParent?: (data: OnBeforeSendDataToParent) => Promise<Record<string, any>>,
		legacyScreenshot?: boolean,
		nftForm?: NftForm
	) => Promise<void>;
	/**
	 * Create a PDF of the current configuration
	 * @returns The URL of the PDF
	 */
	getPDF: () => Promise<string>;
	getOnlineScreenshot: (
		width: number,
		height: number,
		legacyScreenshot?: boolean,
		backgroundColor?: string,
		padding?: number
	) => Promise<{ originalUrl: string; rewrittenUrl: string }>;

	setCamera: (id: string, onlyAngleOfView?: boolean, animate?: boolean) => void;
	setCameraByName: (name: string, onlyAngleOfView?: boolean, animate?: boolean) => void;
	setCameraZoomEnabled: (enabled: boolean) => void;
	resetCameraPivot: () => void;

	setCameraPivot: (meshId: string) => void;
	fullyLoadFont: (fontFamily: string | FontFamily) => Promise<FontFamily>;
	sanitizeString: (family: FontFamily, text: string) => string;
	getSanitationText: (family: FontFamily, text: string) => TextSanitationResult;
	getImages: (categoryId: number) => Promise<ZakekeImage[]>;
	getMacroCategories: () => Promise<ImageMacroCategory[]>;

	previewOnly__setItemImageFromBase64: (guid: string, base64: string) => void;
	setItemImageFromFile: (guid: string, file: File) => Promise<void>;
	addItemImage: (id: number, areaId: number) => Promise<void>;
	/**
	 * Upload an image and get the uploaded image
	 * @param file The file to upload
	 * @param progress A callback to get the upload progress
	 * @returns The uploaded image
	 */
	createImage: (file: File, progress?: (percentage: number) => void) => Promise<ZakekeImage>;
	createImageFromUrl: (url: string) => Promise<ZakekeImage>;
	setItemImage: (guid: string, imageId: number) => Promise<void>;
	setItemFontFamily: (guid: string, fontFamily: string) => void;
	setItemColor: (guid: string, color: string) => void;
	setItemBold: (guid: string, bold: boolean) => void;
	setItemItalic: (guid: string, italic: boolean) => void;
	setItemTextOnPath: (guid: string, areaId: number, value: boolean) => void;
	setItemText: (guid: string, text: string) => void;
	addItemText: (settings: { text: string; fontFamily: string }, areaId: number) => Promise<void>;
	/**
	 * Remove an item from the customization
	 * @param guid The guid of the item to remove
	 */
	removeItem: (guid: string) => Promise<void>;
	setQuantity: (quantity: number) => void;
	getShareCompositionUrl: () => Promise<string>;
	saveComposition: (customPreviewSize?: CustomPreviewSize) => Promise<void>;
	loadComposition: (id: string) => Promise<void>;
	switchFullscreen: () => void;
	openSecondScreen: () => void;
	isFullscreenMode: boolean;
	zoomIn: () => void;
	zoomOut: () => void;
	updateView: (adjustCamera?: boolean) => void;
	setHighlightSettings: (settings: { color: string; size: number }) => void;

	hasExplodedMode: () => boolean;
	isExplodedMode: boolean;
	setExplodedMode: (exploded: boolean) => void;

	// Scene manipulation
	getMeshIDbyName: (name: string) => string | undefined | null;
	hideMeshAndSaveState: (meshId: string) => void;
	restoreMeshVisibility: (meshId: string) => void;
	setMeshDesignVisibility: (meshId: string, visible: boolean) => void;

	// Events
	clearListeners: () => void;
	addFocusAttributesListener: (listenerFunction: FocusAttributesEventListener) => void;
	focusAttribute: (attributeId: number) => void;

	// Highlight
	highlightGroup: (groupId: number) => void;
	highlightAttribute: (attributeId: number) => void;
	// AR
	getQrCodeArUrl: (device: 'iOS' | 'Android') => Promise<string>;
	getMobileArUrl: (onFlyArUrl?: string) => Promise<Blob | string | null>;
	openArMobile: (url: string) => void;
	isSceneArEnabled: () => boolean;
	isArDeviceCompliant: () => boolean;
	IS_ANDROID: boolean;
	IS_IOS: boolean;

	setBackgroundColor: (color: string, alpha: number) => void;
	getTryOnUrl: (tryOnUrl?: string) => Promise<string>;
	isSceneTryOnEnabled: () => boolean;
	setCameraLocked: (isBlocked: boolean) => void;
	getTemplateUploadRestrictictions: (templateId: number, areaId: number) => TemplateUploadRestrictictions;
	saveDraftsComposition: (name: string, tags: string[], isCopy?: boolean) => Promise<void>;
	loadSavedComposition: (docID: string) => Promise<void>;
	deleteSavedComposition: (docId: string) => Promise<void>;
	exportSceneToGlb: () => Promise<string | Blob | null>;
	// reset, undo, redo
	reset: () => Promise<void>;
	undo: () => Promise<void>;
	redo: () => Promise<void>;

	// copyright checkbox
	getCopyrightMessageAccepted: () => boolean;
	setCopyrightMessageAccepted: (copyrightMandatoryCheckbox: boolean) => void;

	validationNFTEmail: (email: string) => boolean;
	validationNFTWalletAddress: (walletAddress: string) => boolean;

	templateMacroCategories: TemplateMacroCategory[] | null;
	applyTemplate: (templateGroupCompositionId: number) => Promise<void>;

	configureByAI: (text: string) => Promise<void>;
	hasVTryOnEnabled: boolean;
	canUseTryOn: boolean;
	canUsePD: boolean;
	getTryOnSettings: () => Zakeke.TryOnSettings | undefined;
	isTryOnMeshVisible: boolean;
	isMandatoryPD: boolean;
	isVisibleMeshShownForTryOn: boolean;
	setPDDistance: (distance: number) => void;
	pdDistance: () => number;
	exportTryOnMeshToGlb: () => Promise<string | Blob | null>;

You can find a full and updated list of the values exposed by useZakeke in the source code (the definitions files) of the library. Please refer to the source code comments for a detailed understanding of each value and their usage.

Note: Always ensure to handle these values appropriately in your React components to ensure a smooth user experience.

0.1.285-prod

9 months ago

0.1.286-prod

9 months ago

0.1.284-prod

9 months ago

0.1.283-prod

9 months ago

0.1.277-prod

10 months ago

0.1.281-prod

10 months ago

0.1.276-prod

10 months ago

0.1.278-prod

10 months ago

0.1.280-prod

10 months ago

0.1.279-prod

10 months ago

0.1.282-prod

10 months ago

0.1.257

1 year ago

0.1.256

1 year ago

0.1.259

1 year ago

0.1.258

1 year ago

0.1.255

1 year ago

0.1.254

1 year ago

0.1.268

12 months ago

0.1.267

12 months ago

0.1.269

12 months ago

0.1.264

1 year ago

0.1.263

1 year ago

0.1.266

1 year ago

0.1.265

1 year ago

0.1.260

1 year ago

0.1.262

1 year ago

0.1.261

1 year ago

0.1.275-prod

11 months ago

0.1.273-prod

11 months ago

0.1.274-prod

11 months ago

0.1.271

12 months ago

0.1.270

12 months ago

0.1.273

12 months ago

0.1.272

12 months ago

0.1.253

1 year ago

0.1.252

1 year ago

0.1.251

1 year ago

0.1.250

1 year ago

0.1.249

1 year ago

0.1.246

1 year ago

0.1.245

1 year ago

0.1.248

1 year ago

0.1.247

1 year ago

0.1.244

1 year ago

0.1.243

1 year ago

0.1.242

1 year ago

0.1.241

1 year ago

0.1.240

1 year ago

0.1.239

1 year ago

0.1.238

1 year ago

0.1.235

1 year ago

0.1.234

1 year ago

0.1.237

1 year ago

0.1.236

1 year ago

0.1.233

2 years ago

0.1.232

2 years ago

0.1.231

2 years ago

0.0.231

2 years ago

0.0.230

2 years ago

0.0.229

2 years ago

0.0.228

2 years ago

0.0.227

2 years ago

0.0.226

2 years ago

0.0.209

2 years ago

0.0.216

2 years ago

0.0.215

2 years ago

0.0.214

2 years ago

0.0.213

2 years ago

0.0.219

2 years ago

0.0.218

2 years ago

0.0.217

2 years ago

0.0.212

2 years ago

0.0.211

2 years ago

0.0.210

2 years ago

0.0.225

2 years ago

0.0.224

2 years ago

0.0.223

2 years ago

0.0.222

2 years ago

0.0.221

2 years ago

0.0.220

2 years ago

0.0.205

2 years ago

0.0.204

2 years ago

0.0.203

2 years ago

0.0.202

2 years ago

0.0.208

2 years ago

0.0.207

2 years ago

0.0.206

2 years ago

0.0.201

2 years ago

0.0.200

2 years ago

0.0.197

2 years ago

0.0.196

2 years ago

0.0.195

2 years ago

0.0.194

2 years ago

0.0.199

2 years ago

0.0.198

2 years ago

0.0.193

2 years ago

0.0.192

2 years ago

0.0.191

2 years ago

0.0.190

2 years ago

0.0.169

2 years ago

0.0.164

2 years ago

0.0.163

2 years ago

0.0.162

2 years ago

0.0.168

2 years ago

0.0.167

2 years ago

0.0.166

2 years ago

0.0.165

2 years ago

0.0.175

2 years ago

0.0.174

2 years ago

0.0.173

2 years ago

0.0.172

2 years ago

0.0.179

2 years ago

0.0.178

2 years ago

0.0.177

2 years ago

0.0.176

2 years ago

0.0.171

2 years ago

0.0.170

2 years ago

0.0.186

2 years ago

0.0.185

2 years ago

0.0.184

2 years ago

0.0.183

2 years ago

0.0.189

2 years ago

0.0.188

2 years ago

0.0.187

2 years ago

0.0.182

2 years ago

0.0.181

2 years ago

0.0.180

2 years ago

0.0.159

2 years ago

0.0.158

2 years ago

0.0.153

2 years ago

0.0.152

2 years ago

0.0.151

2 years ago

0.0.150

2 years ago

0.0.157

2 years ago

0.0.156

2 years ago

0.0.155

2 years ago

0.0.154

2 years ago

0.0.161

2 years ago

0.0.160

2 years ago

0.0.128

2 years ago

0.0.127

2 years ago

0.0.126

2 years ago

0.0.125

2 years ago

0.0.129

2 years ago

0.0.139

2 years ago

0.0.138

2 years ago

0.0.137

2 years ago

0.0.136

2 years ago

0.0.131

2 years ago

0.0.130

2 years ago

0.0.135

2 years ago

0.0.134

2 years ago

0.0.133

2 years ago

0.0.132

2 years ago

0.0.164-nft

2 years ago

0.0.148

2 years ago

0.0.147

2 years ago

0.0.142

2 years ago

0.0.141

2 years ago

0.0.140

2 years ago

0.0.146

2 years ago

0.0.145

2 years ago

0.0.144

2 years ago

0.0.143

2 years ago

0.0.117

3 years ago

0.0.119

3 years ago

0.0.118

3 years ago

0.0.120

3 years ago

0.0.124

3 years ago

0.0.123

3 years ago

0.0.122

3 years ago

0.0.116

3 years ago

0.0.115

3 years ago

0.0.114

3 years ago

0.0.113

3 years ago

0.0.112

3 years ago

0.0.111

3 years ago

0.0.110

3 years ago

0.0.106

3 years ago

0.0.109

3 years ago

0.0.108

3 years ago

0.0.107

3 years ago

0.0.105

3 years ago

0.0.84

3 years ago

0.0.85

3 years ago

0.0.86

3 years ago

0.0.87

3 years ago

0.0.88

3 years ago

0.0.89

3 years ago

0.0.81

3 years ago

0.0.82

3 years ago

0.0.83

3 years ago

0.0.104

3 years ago

0.0.103

3 years ago

0.0.102

3 years ago

0.0.101

3 years ago

0.0.100

3 years ago

0.0.95

3 years ago

0.0.96

3 years ago

0.0.97

3 years ago

0.0.98

3 years ago

0.0.99

3 years ago

0.0.90

3 years ago

0.0.91

3 years ago

0.0.92

3 years ago

0.0.93

3 years ago

0.0.94

3 years ago

0.0.80

3 years ago

0.0.73

3 years ago

0.0.74

3 years ago

0.0.75

3 years ago

0.0.76

3 years ago

0.0.77

3 years ago

0.0.78

3 years ago

0.0.79

3 years ago

0.0.70

3 years ago

0.0.71

3 years ago

0.0.72

3 years ago

0.0.62

3 years ago

0.0.63

3 years ago

0.0.64

3 years ago

0.0.65

3 years ago

0.0.66

3 years ago

0.0.67

3 years ago

0.0.68

3 years ago

0.0.69

3 years ago

0.0.60

3 years ago

0.0.61

3 years ago

0.0.59

3 years ago

0.0.52

3 years ago

0.0.53

3 years ago

0.0.54

3 years ago

0.0.55

3 years ago

0.0.56

3 years ago

0.0.57

3 years ago

0.0.58

3 years ago

0.0.51

4 years ago

0.0.47

4 years ago

0.0.50

4 years ago

0.0.48

4 years ago

0.0.49

4 years ago

0.0.46

4 years ago

0.0.45

4 years ago

0.0.44

4 years ago

0.0.43

4 years ago

0.0.42

4 years ago

0.0.41

4 years ago

0.0.40

4 years ago

0.0.39

4 years ago

0.0.38

4 years ago

0.0.37

4 years ago

0.0.36

4 years ago

0.0.35

4 years ago

0.0.33

4 years ago

0.0.34

4 years ago

0.0.32

4 years ago

0.0.30

4 years ago

0.0.31

4 years ago

0.0.28

4 years ago

0.0.29

4 years ago

0.0.27

4 years ago

0.0.26

4 years ago

0.0.25

5 years ago

0.0.24

5 years ago

0.0.23

5 years ago

0.0.22

5 years ago

0.0.21

5 years ago

0.0.20

5 years ago

0.0.19

5 years ago

0.0.17

5 years ago

0.0.18

5 years ago

0.0.16

5 years ago

0.0.14

5 years ago

0.0.15

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.4-0

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago