You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+116Lines changed: 116 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -95,6 +95,122 @@ module.exports = {
95
95
96
96
This will ensure your application includes all the necessary styles for PeekAppSDK components.
97
97
98
+
## JavaScript Integration
99
+
100
+
To use PeekAppSDK's JavaScript hooks in your Phoenix LiveView application, add this to your `assets/js/app.js` file:
101
+
102
+
```javascript
103
+
// Import PeekAppSDK hooks
104
+
importPeekAppSDKHooksfrom"peek_app_sdk"
105
+
106
+
// If you don't have any other hooks:
107
+
let liveSocket =newLiveSocket("/live", Socket, {
108
+
longPollFallbackMs:2500,
109
+
params: {_csrf_token: csrfToken},
110
+
hooks: PeekAppSDKHooks
111
+
})
112
+
113
+
// If you have other hooks, merge them:
114
+
let Hooks = {
115
+
...PeekAppSDKHooks,
116
+
// your other hooks here
117
+
}
118
+
119
+
let liveSocket =newLiveSocket("/live", Socket, {
120
+
longPollFallbackMs:2500,
121
+
params: {_csrf_token: csrfToken},
122
+
hooks: Hooks
123
+
})
124
+
```
125
+
126
+
The import works because PeekAppSDK includes a `package.json` file that tells Node.js where to find the JavaScript hooks.
127
+
128
+
## Odyssey UI Components Integration
129
+
130
+
PeekAppSDK includes Odyssey UI components that provide rich interactive elements for your Phoenix LiveView applications. To integrate these components:
131
+
132
+
### 1. Add the Odyssey UI Components Import
133
+
134
+
In your Phoenix web module (e.g., `lib/your_app_web.ex`), add the import to both the `html` and `live_view` functions:
135
+
136
+
```elixir
137
+
defhtmldo
138
+
quotedo
139
+
usePhoenix.Component
140
+
importPeekAppSDK.UI.Odyssey# Add this line
141
+
importYourAppWeb.CoreComponents
142
+
# ... other imports
143
+
end
144
+
end
145
+
146
+
deflive_viewdo
147
+
quotedo
148
+
usePhoenix.LiveView,
149
+
layout: {YourAppWeb.Layouts, :app}
150
+
151
+
importPeekAppSDK.UI.Odyssey# Add this line
152
+
importYourAppWeb.CoreComponents
153
+
# ... other imports
154
+
end
155
+
end
156
+
```
157
+
158
+
### 2. Include Odyssey Web Components JavaScript
159
+
160
+
In your `assets/js/app.js` file, add the Odyssey web components:
161
+
162
+
```javascript
163
+
// Import Odyssey web components (required for UI components to work)
In your `assets/css/app.css` file, add the Odyssey assets to your Tailwind sources:
183
+
184
+
```css
185
+
@import"tailwindcss/base";
186
+
@import"tailwindcss/components";
187
+
@import"tailwindcss/utilities";
188
+
189
+
@source "../css";
190
+
@source "../js";
191
+
@source "../../lib/your_app_web";
192
+
@source "../../deps/peek_app_sdk/assets"; /* Add this line */
193
+
```
194
+
195
+
### 4. Using Odyssey Components
196
+
197
+
Once integrated, you can use Odyssey components in your LiveView templates:
198
+
199
+
```heex
200
+
<.form for={@form} phx-change="activity_changed">
201
+
<.odyssey_activity_picker
202
+
install_id={@app_installation_id}
203
+
field={@form[:activity_id]}
204
+
/>
205
+
</.form>
206
+
```
207
+
208
+
The activity picker component will automatically handle activity selection and update the form field when activities are chosen.
209
+
210
+
### Updating Odyssey Components
211
+
212
+
Simply update odyssey_web_components.js and odyssey_web_components.css in your assets folder and run `mix assets.deploy` and get merged into main. When upstream apps run a mix deps.update peek_app_sdk they'll get the updated odyssey assets.
213
+
98
214
# PeekAppSDK Metrics
99
215
100
216
This document describes how to use the metrics functionality in the PeekAppSDK.
0 commit comments