@amityco/ulta-ui-kit 1.0.0-alpha.28 → 1.0.0-alpha.29
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/index.css +1 -1
- package/dist/esm/index.js +1079 -1058
- package/dist/index.css +1 -1
- package/dist/index.js +1157 -1136
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +1 -1
- package/readme.md +29 -16
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
The AmityUIKit provides a comprehensive user interface toolkit to quickly integrate Amity Social features into new or existing websites. This toolkit simplifies the incorporation of social interactions within your projects through an iframe-based integration.
|
|
6
6
|
|
|
7
7
|
### Prerequisites
|
|
8
|
+
|
|
8
9
|
Before you begin, ensure you have the following installed:
|
|
9
10
|
|
|
10
|
-
•
|
|
11
|
-
•
|
|
11
|
+
• Node.js (>= 20.x)
|
|
12
|
+
• React.js (>= 18.x)
|
|
12
13
|
|
|
13
14
|
### Installation
|
|
14
15
|
|
|
@@ -17,9 +18,12 @@ With npm: `npm install --save @amityco/ulta-ui-kit`
|
|
|
17
18
|
With yarn: `yarn add @amityco/ulta-ui-kit`
|
|
18
19
|
|
|
19
20
|
### Basic Usage
|
|
21
|
+
|
|
20
22
|
```sh
|
|
21
23
|
import { AmityUiKitProvider, AmityUiKitSocial } from "@amityco/ulta-ui-kit";
|
|
22
24
|
|
|
25
|
+
import "@amityco/ulta-ui-kit/dist/index.css";
|
|
26
|
+
|
|
23
27
|
export default function App() {
|
|
24
28
|
// Retrieve userId from query parameters
|
|
25
29
|
const urlParams = new URLSearchParams(window.location.search);
|
|
@@ -42,9 +46,10 @@ export default function App() {
|
|
|
42
46
|
```
|
|
43
47
|
|
|
44
48
|
### Iframe Post Message Integration
|
|
49
|
+
|
|
45
50
|
In React, the component’s state dictates the behavior and rendering of the component. When the state changes, React automatically triggers a re-render of the component, updating the DOM where necessary. In your application, the userId is stored in the component’s state using the useState hook. This state determines the URL of the iframe where the Amity UIKit is loaded. When the userId state changes, React recognizes this change and re-renders the component, including the iframe, with the updated URL.
|
|
46
51
|
|
|
47
|
-
When an anonymous user exceeds three clicks, the UIKit will emit a ‘
|
|
52
|
+
When an anonymous user exceeds three clicks, the UIKit will emit a ‘anonymousNeedsLogin’ postMessage event. Below is a code example demonstrating how to receive this postMessage event from the UIKit Iframe:
|
|
48
53
|
|
|
49
54
|
```sh
|
|
50
55
|
import React, { useState, useEffect } from 'react';
|
|
@@ -56,7 +61,7 @@ export default function App() {
|
|
|
56
61
|
// Handle the postMessage event from the iframe
|
|
57
62
|
useEffect(() => {
|
|
58
63
|
const handleIframeMessage = event => {
|
|
59
|
-
if (event.data === '
|
|
64
|
+
if (event.data === 'anonymousNeedsLogin') {
|
|
60
65
|
// Prompt user to log in
|
|
61
66
|
// Logic to display login dialog should be implemented here
|
|
62
67
|
}
|
|
@@ -99,30 +104,38 @@ export default function App() {
|
|
|
99
104
|
```
|
|
100
105
|
|
|
101
106
|
### Anonymous User Flow
|
|
107
|
+
|
|
102
108
|
**Authenticated Users**
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
109
|
+
|
|
110
|
+
1. Access and Authentication:
|
|
111
|
+
|
|
112
|
+
- Users enter Ulta Web and navigate to the community tab.
|
|
113
|
+
- Ulta Web contacts Ulta Authentication Service to verify if the user is logged in.
|
|
114
|
+
|
|
115
|
+
2. Token Handling:
|
|
116
|
+
|
|
107
117
|
- If authenticated, Ulta Web requests an Amity authentication token from Ulta Server.
|
|
108
118
|
- Ulta Server forwards this request to Amity Server, which returns the token.
|
|
109
|
-
|
|
110
|
-
3.
|
|
119
|
+
|
|
120
|
+
3. UIKit Initialization:
|
|
121
|
+
|
|
111
122
|
- Ulta Web instructs Ulta Iframe to initialize Amity UIKit using the authenticated Ulta User ID and token.
|
|
112
123
|
- Amity UIKit is then presented to the user, allowing continued interaction under their Ulta ID.
|
|
113
124
|
|
|
114
125
|
**Anonymous Users**
|
|
126
|
+
|
|
115
127
|
1. Access as Anonymous:
|
|
128
|
+
|
|
116
129
|
- If not logged in, the same token request is made to handle session management.
|
|
117
130
|
- Amity UIKit is initialized as ‘anonymous’, allowing limited interaction.
|
|
118
|
-
2. Exceeded Interaction Limit:
|
|
119
|
-
- If anonymous interactions exceed limits, Amity UIKit informs Ulta Iframe, triggering a notification to Ulta Web.
|
|
120
|
-
- A login dialogue is presented to the user.
|
|
121
|
-
3. Login Decision:
|
|
122
|
-
- If the user logs in, Ulta Authentication Service authenticates the user, and the token process repeats to reinitialize Amity UIKit with the Ulta User ID.
|
|
123
131
|
|
|
132
|
+
2. Exceeded Interaction Limit:
|
|
124
133
|
|
|
134
|
+
- If anonymous interactions exceed limits, Amity UIKit informs Ulta Iframe, triggering a notification to Ulta Web.
|
|
135
|
+
- A login dialogue is presented to the user.
|
|
125
136
|
|
|
126
|
-
|
|
137
|
+
3. Login Decision:
|
|
127
138
|
|
|
139
|
+
- If the user logs in, Ulta Authentication Service authenticates the user, and the token process repeats to reinitialize Amity UIKit with the Ulta User ID.
|
|
128
140
|
|
|
141
|
+

|