fansunited-frontend-components 0.0.1-RC10 → 0.0.1-RC12

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/README.md ADDED
@@ -0,0 +1,330 @@
1
+ # Fans United Frontend Components
2
+
3
+ A collection of components for Fans United widgets providing interactive experiences and engagement tools.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install fansunited-frontend-components fansunited-frontend-core
9
+ ```
10
+
11
+ ```bash
12
+ yarn add fansunited-frontend-components fansunited-frontend-core
13
+ ```
14
+
15
+ > **Note**: Both packages are required. `fansunited-frontend-core` provides the types and core utilities, while `fansunited-frontend-components` provides the components.
16
+
17
+ ## Quick Start
18
+
19
+ ```tsx
20
+ import React from "react";
21
+ import { ClassicQuizPlay } from "fansunited-frontend-components";
22
+ import { ClassicQuizPlayProps, WidgetTemplate } from "fansunited-frontend-core";
23
+
24
+ const App: React.FC = () => {
25
+ const props: ClassicQuizPlayProps = {
26
+ entityId: "your-quiz-id",
27
+ sdk: yourSDKInstance,
28
+ template: WidgetTemplate.STANDARD, // Also SPLIT and OVERLAY templates are available
29
+ language: "en", // "bg" | "en" | "ro" | "pt" | "sr" | "fr" | "de" | "it" | "fr-be" | "fr" | "pl" | "pt" | "pt-br"
30
+ };
31
+
32
+ return (
33
+ <div>
34
+ <h1>My App</h1>
35
+ <ClassicQuizPlay {...props} />
36
+ </div>
37
+ );
38
+ };
39
+
40
+ export default App;
41
+ ```
42
+
43
+ ## Classic Quiz Component
44
+
45
+ An interactive quiz component that supports multiple templates and customization options.
46
+
47
+ ### Props
48
+
49
+ All props are defined in `fansunited-frontend-core`.
50
+
51
+ ```tsx
52
+ import {
53
+ ClassicQuizPlayProps,
54
+ WidgetTemplate,
55
+ LanguageType,
56
+ CustomThemeOptions,
57
+ LeadsOptions,
58
+ } from "fansunited-frontend-core";
59
+ ```
60
+
61
+ ### Required Props
62
+
63
+ | Prop | Type | Description |
64
+ | ---------- | -------------------- | ------------------------------ |
65
+ | `entityId` | `string` | Unique identifier for the quiz |
66
+ | `sdk` | `FansUnitedSDKModel` | FansUnited SDK instance |
67
+ | `template` | `WidgetTemplate` | Widget template type |
68
+ | `language` | `LanguageType` | Display language |
69
+
70
+ ### Optional Props
71
+
72
+ | Prop | Type | Description |
73
+ | ------------------------ | -------------------- | -------------------------------------------------------------- |
74
+ | `themeOptions` | `CustomThemeOptions` | Custom theme configuration |
75
+ | `showAnswerExplanations` | `boolean` | Show explanations tab after answers finishing the Classic Quiz |
76
+ | `leads` | `LeadsOptions` | Lead collection configuration |
77
+ | `imagePosition` | `"left" \| "right"` | Image position (STANDARD template only) |
78
+
79
+ ### Templates
80
+
81
+ ```tsx
82
+ import { WidgetTemplate } from "fansunited-frontend-core";
83
+
84
+ // Standard template with optional image positioning
85
+ const standardProps: ClassicQuizPlayProps = {
86
+ template: WidgetTemplate.STANDARD,
87
+ imagePosition: "left", // or 'right'
88
+ // ... other props
89
+ };
90
+
91
+ // Other templates
92
+ const overlayProps: ClassicQuizPlayProps = {
93
+ template: WidgetTemplate.OVERLAY, // WidgetTemplate.SPLIT
94
+ // imagePosition not available for non-standard templates
95
+ // ... other props
96
+ };
97
+ ```
98
+
99
+ ### Theming
100
+
101
+ Customize the appearance using theme options:
102
+
103
+ ```tsx
104
+ import { CustomThemeOptions } from "fansunited-frontend-core";
105
+
106
+ // Default theme options
107
+ const themeOptions: CustomThemeOptions = {
108
+ mode: "light", // or 'dark'
109
+ colorSchemes: {
110
+ light: {
111
+ palette: {
112
+ success: {
113
+ plainColor: "#4CAF50",
114
+ outlinedBorder: "#4CAF50",
115
+ },
116
+ danger: {
117
+ softBg: "#FEE4E2",
118
+ plainColor: "#F44336",
119
+ outlinedBorder: "#F44336",
120
+ },
121
+ primary: {
122
+ plainColor: "#1A77D2",
123
+ outlinedBorder: "#1A77D2",
124
+ onPrimary: "#FAFAFA",
125
+ primaryContainer: "#2397F3",
126
+ },
127
+ warning: {
128
+ softBg: "#FEF0C7",
129
+ plainColor: "#DC6803",
130
+ },
131
+ },
132
+ textPrimary: "#212121",
133
+ textSecondary: "#212121",
134
+ textColor: "#212121",
135
+ textDisabled: "#212121",
136
+ surface: "#FFFFFF",
137
+ onSurface: "#F5F5F5",
138
+ surfaceVariant: "#EEEEEE",
139
+ surfaceTintDim: "#212121",
140
+ surfaceInverse: "#F5F5F5",
141
+ outlineEnabledBorder: "#E0E0E0",
142
+ secondaryContainer: "#BDBDBD",
143
+ },
144
+ dark: {
145
+ palette: {
146
+ primary: {
147
+ plainColor: "#1A77D2",
148
+ outlinedBorder: "#1A77D2",
149
+ onPrimary: "#FAFAFA",
150
+ primaryContainer: "#2397F3",
151
+ },
152
+ success: {
153
+ plainColor: "#4CAF50",
154
+ outlinedBorder: "#4CAF50",
155
+ },
156
+ danger: {
157
+ softBg: "#FEE4E2",
158
+ plainColor: "#F44336",
159
+ outlinedBorder: "#F44336",
160
+ },
161
+ warning: {
162
+ softBg: "#FEF0C7",
163
+ plainColor: "#DC6803",
164
+ },
165
+ },
166
+ textPrimary: "#FAFAFA",
167
+ textSecondary: "#FAFAFA",
168
+ textColor: "#FAFAFA",
169
+ textDisabled: "#FAFAFA",
170
+ surface: "#424242",
171
+ onSurface: "#212121",
172
+ surfaceVariant: "#616161",
173
+ surfaceTintDim: "#FAFAFA",
174
+ surfaceInverse: "#FAFAFA",
175
+ outlineEnabledBorder: "#757575",
176
+ secondaryContainer: "#757575",
177
+ },
178
+ },
179
+ breakpoints: {
180
+ values: {
181
+ xs: 0,
182
+ sm: 444,
183
+ md: 600,
184
+ lg: 900,
185
+ xl: 1200,
186
+ xxl: 1536,
187
+ },
188
+ },
189
+ spacingScale: {
190
+ "3xs": "2px",
191
+ "2xs": "4px",
192
+ xs: "8px",
193
+ sm: "12px",
194
+ md: "16px",
195
+ lg: "24px",
196
+ xl: "32px",
197
+ "2xl": "40px",
198
+ "3xl": "48px",
199
+ },
200
+ customFontFamily: {
201
+ light: {
202
+ primary: "Ubuntu, sans-serif",
203
+ secondary: "Roboto, sans-serif",
204
+ },
205
+ dark: {
206
+ primary: "Ubuntu, sans-serif",
207
+ secondary: "Roboto, sans-serif",
208
+ },
209
+ },
210
+ customRadius: {
211
+ light: {
212
+ none: "0px",
213
+ "2xs": "2px",
214
+ xs: "4px",
215
+ sm: "8px",
216
+ md: "12px",
217
+ lg: "16px",
218
+ xl: "24px",
219
+ "2xl": "232px",
220
+ full: "1000px",
221
+ },
222
+ dark: {
223
+ none: "0px",
224
+ "2xs": "2px",
225
+ xs: "4px",
226
+ sm: "8px",
227
+ md: "12px",
228
+ lg: "16px",
229
+ xl: "24px",
230
+ "2xl": "232px",
231
+ full: "1000px",
232
+ },
233
+ },
234
+ border: {
235
+ light: {
236
+ size: "1px",
237
+ },
238
+ dark: {
239
+ size: "2px",
240
+ },
241
+ },
242
+ };
243
+
244
+ <ClassicQuizPlay {...otherProps} themeOptions={themeOptions} />;
245
+ ```
246
+
247
+ ### Lead Collection
248
+
249
+ Enable lead capture functionality:
250
+
251
+ ```tsx
252
+ import { LeadsOptions } from "fansunited-frontend-core";
253
+
254
+ const leads: LeadsOptions = {
255
+ position: "before", // "before" | "after"
256
+ fields: ["fullName"], // | "fullName" | "firstName" | "lastName" | "email" | "gender" | "country" | "phoneCountryCode" | "phoneNumber";
257
+ campaignId: "test-quizzes",
258
+ campaignName: "Test Quizzes",
259
+ phoneCountryCode: "359", // When not provided will set the phone country code from component language prop. So for example if the language is "bg" and phoneCountryCode is not provided, it will fallback to "359"
260
+ };
261
+
262
+ <ClassicQuizPlay {...otherProps} leads={leads} />;
263
+ ```
264
+
265
+ ### TypeScript Support
266
+
267
+ This package is built with TypeScript and provides full type definitions. Import types from `fansunited-frontend-core`:
268
+
269
+ ```tsx
270
+ import {
271
+ ClassicQuizPlayProps,
272
+ WidgetTemplate,
273
+ WidgetProps,
274
+ CustomThemeOptions,
275
+ LeadsOptions,
276
+ AnalyticsEvent,
277
+ } from "fansunited-frontend-core";
278
+ ```
279
+
280
+ ### Peer Dependencies
281
+
282
+ ```json
283
+ {
284
+ "react": "^18.0.0",
285
+ "react-dom": "^18.0.0"
286
+ }
287
+ ```
288
+
289
+ ### Bundle Size
290
+
291
+ The component uses shadow DOM and emotion for isolated styling, ensuring no CSS conflicts with your application.
292
+
293
+ ### Examples
294
+
295
+ #### Basic Quiz
296
+
297
+ ```tsx
298
+ import { ClassicQuizPlay } from "fansunited-frontend-components";
299
+ import { WidgetTemplate } from "fansunited-frontend-core";
300
+
301
+ <ClassicQuizPlay
302
+ entityId="quiz-123"
303
+ sdk={sdkInstance}
304
+ template={WidgetTemplate.STANDARD}
305
+ language="en"
306
+ />;
307
+ ```
308
+
309
+ #### Customized Quiz
310
+
311
+ ```tsx
312
+ <ClassicQuizPlay
313
+ entityId="quiz-123"
314
+ sdk={sdkInstance}
315
+ template={WidgetTemplate.STANDARD}
316
+ imagePosition="right"
317
+ language="en"
318
+ showAnswerExplanations={true}
319
+ themeOptions={{
320
+ mode: "dark",
321
+ }}
322
+ leads={{
323
+ phoneCountryCode: "44",
324
+ }}
325
+ />
326
+ ```
327
+
328
+ #### Related Packages
329
+
330
+ - [`fansunited-frontend-core`](https://www.npmjs.com/package/fansunited-frontend-core) - Core types and utilities
package/components.d.ts CHANGED
@@ -1 +1,5 @@
1
- export * from './index'
1
+ import { ClassicQuizPlayProps } from 'fansunited-frontend-core';
2
+
3
+ declare const ClassicQuizPlay: React.FC<ClassicQuizPlayProps>;
4
+ export default ClassicQuizPlay;
5
+ //# sourceMappingURL=components.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/components.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAIhE,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAC1B,CAAC;AAE3B,eAAe,eAAe,CAAC"}
package/components.js CHANGED
@@ -6812,7 +6812,7 @@ const Cp = (e, t = "theme-mode") => {
6812
6812
  border: e.border || yd
6813
6813
  }
6814
6814
  };
6815
- return Ii(o);
6815
+ return console.log("Custom Theme Options:", o), Ii(o);
6816
6816
  }, Ep = (e) => {
6817
6817
  const t = (e == null ? void 0 : e.mode) || "light", o = (e == null ? void 0 : e.modeStorageKey) || "theme-mode", n = xp(e);
6818
6818
  return Ii({
@@ -29959,7 +29959,9 @@ function Na(e) {
29959
29959
  const jI = (e) => {
29960
29960
  const [t, o] = wt(1), [n, r] = wt(null), [i, s] = wt(!1), [l, c] = wt([]), [d, u] = wt(
29961
29961
  []
29962
- ), [A, f] = wt(!1), [p, h] = wt(!0), [y, I] = wt(0), x = C4(e.entityId, e.sdk), R = y4(e.entityId, e.sdk), E = Ar(() => !x || !R ? !1 : x.maxAttempts === 1 && R.length > 0, [x, R]);
29962
+ ), [A, f] = wt(!1), [p, h] = wt(!0), [y, I] = wt(0), x = C4(e.entityId, e.sdk), R = y4(e.entityId, e.sdk);
29963
+ console.log("props", e);
29964
+ const E = Ar(() => !x || !R ? !1 : x.maxAttempts === 1 && R.length > 0, [x, R]);
29963
29965
  if (oo(() => {
29964
29966
  xm(e.language || "en");
29965
29967
  }, [e.language]), oo(() => {
package/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { default as ClassicQuizPlay } from './ClassicQuizPlay';
1
+ export { default as ClassicQuizPlay } from './components';
2
2
  //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fansunited-frontend-components",
3
- "version": "0.0.1-RC10",
3
+ "version": "0.0.1-RC12",
4
4
  "description": "Various user centric components for Fans United features",
5
5
  "main": "components.js",
6
6
  "types": "components.d.ts",
@@ -9,6 +9,11 @@
9
9
  "dependencies": {
10
10
  "fansunited-frontend-core": "latest"
11
11
  },
12
+ "keywords": [
13
+ "fansunited",
14
+ "frontend",
15
+ "components"
16
+ ],
12
17
  "devDependencies": {
13
18
  "vite": "^5.0.0",
14
19
  "vite-plugin-dts": "^3.0.0",
@@ -1,5 +0,0 @@
1
- import { ClassicQuizPlayProps } from 'fansunited-frontend-core';
2
-
3
- declare const ClassicQuizPlay: React.FC<ClassicQuizPlayProps>;
4
- export default ClassicQuizPlay;
5
- //# sourceMappingURL=ClassicQuizPlay.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ClassicQuizPlay.d.ts","sourceRoot":"","sources":["../../src/ClassicQuizPlay.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGhE,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAC1B,CAAC;AAG3B,eAAe,eAAe,CAAC"}