fansunited-frontend-components 0.0.1-RC8 → 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/README.md +323 -0
- package/components.d.ts +4 -1
- package/components.d.ts.map +1 -0
- package/components.js +7559 -7794
- package/index.d.ts +1 -3
- package/index.d.ts.map +1 -1
- package/package.json +9 -2
package/README.md
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
# Fans United Frontend Components
|
|
2
|
+
|
|
3
|
+
A collection of interactive components for Fans United widgets providing engaging experiences and 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 types and utilities, while `fansunited-frontend-components` provides the UI 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
|
+
import { FansUnitedSDK } from "fansunited-sdk-esm";
|
|
24
|
+
|
|
25
|
+
const sdk = FansUnitedSDK({
|
|
26
|
+
// your config here
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const App: React.FC = () => {
|
|
30
|
+
const props: ClassicQuizPlayProps = {
|
|
31
|
+
entityId: "your-quiz-id",
|
|
32
|
+
sdk,
|
|
33
|
+
template: WidgetTemplate.STANDARD, // Also SPLIT and OVERLAY templates are available
|
|
34
|
+
language: "en", // "bg" | "en" | "ro" | "pt" | "sr" | "fr" | "de" | "it" | "fr-be" | "fr" | "pl" | "pt" | "pt-br"
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div>
|
|
39
|
+
<h1>My App</h1>
|
|
40
|
+
<ClassicQuizPlay {...props} />
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default App;
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Components
|
|
49
|
+
|
|
50
|
+
### ClassicQuizPlay
|
|
51
|
+
|
|
52
|
+
Interactive quiz component with multiple templates and customization options.
|
|
53
|
+
|
|
54
|
+
#### Required Props
|
|
55
|
+
|
|
56
|
+
| Prop | Type | Description |
|
|
57
|
+
| ---------- | -------------------- | ----------------------- |
|
|
58
|
+
| `entityId` | `string` | Classic Quiz identifier |
|
|
59
|
+
| `sdk` | `FansUnitedSDKModel` | SDK instance |
|
|
60
|
+
| `template` | `WidgetTemplate` | Layout template |
|
|
61
|
+
| `language` | `LanguageType` | Display language |
|
|
62
|
+
|
|
63
|
+
#### Optional Props
|
|
64
|
+
|
|
65
|
+
| Prop | Type | Description |
|
|
66
|
+
| ------------------------ | -------------------- | --------------------------------------- |
|
|
67
|
+
| `themeOptions` | `CustomThemeOptions` | Theme configuration |
|
|
68
|
+
| `showAnswerExplanations` | `boolean` | Show explanations after quiz completion |
|
|
69
|
+
| `leads` | `LeadsOptions` | Lead collection settings |
|
|
70
|
+
| `imagePosition` | `"left" \| "right"` | Image position (STANDARD template only) |
|
|
71
|
+
|
|
72
|
+
#### Templates
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
import { WidgetTemplate, ClassicQuizPlayProps } from "fansunited-frontend-core";
|
|
76
|
+
|
|
77
|
+
// Standard template with optional image positioning
|
|
78
|
+
const standardProps: ClassicQuizPlayProps = {
|
|
79
|
+
template: WidgetTemplate.STANDARD,
|
|
80
|
+
imagePosition: "left", // or 'right'
|
|
81
|
+
// ... other props
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// Other templates
|
|
85
|
+
const overlayProps: ClassicQuizPlayProps = {
|
|
86
|
+
template: WidgetTemplate.OVERLAY, // WidgetTemplate.SPLIT
|
|
87
|
+
// imagePosition not available for non-standard templates
|
|
88
|
+
// ... other props
|
|
89
|
+
};
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
#### Theming
|
|
93
|
+
|
|
94
|
+
Customize the appearance using theme options:
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
import { CustomThemeOptions } from "fansunited-frontend-core";
|
|
98
|
+
|
|
99
|
+
// Default theme options
|
|
100
|
+
const themeOptions: CustomThemeOptions = {
|
|
101
|
+
mode: "light", // or 'dark'
|
|
102
|
+
colorSchemes: {
|
|
103
|
+
light: {
|
|
104
|
+
palette: {
|
|
105
|
+
success: {
|
|
106
|
+
plainColor: "#4CAF50",
|
|
107
|
+
outlinedBorder: "#4CAF50",
|
|
108
|
+
},
|
|
109
|
+
danger: {
|
|
110
|
+
softBg: "#FEE4E2",
|
|
111
|
+
plainColor: "#F44336",
|
|
112
|
+
outlinedBorder: "#F44336",
|
|
113
|
+
},
|
|
114
|
+
primary: {
|
|
115
|
+
plainColor: "#1A77D2",
|
|
116
|
+
outlinedBorder: "#1A77D2",
|
|
117
|
+
onPrimary: "#FAFAFA",
|
|
118
|
+
primaryContainer: "#2397F3",
|
|
119
|
+
},
|
|
120
|
+
warning: {
|
|
121
|
+
softBg: "#FEF0C7",
|
|
122
|
+
plainColor: "#DC6803",
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
textPrimary: "#212121",
|
|
126
|
+
textSecondary: "#212121",
|
|
127
|
+
textColor: "#212121",
|
|
128
|
+
textDisabled: "#212121",
|
|
129
|
+
surface: "#FFFFFF",
|
|
130
|
+
onSurface: "#F5F5F5",
|
|
131
|
+
surfaceVariant: "#EEEEEE",
|
|
132
|
+
surfaceTintDim: "#212121",
|
|
133
|
+
surfaceInverse: "#F5F5F5",
|
|
134
|
+
outlineEnabledBorder: "#E0E0E0",
|
|
135
|
+
secondaryContainer: "#BDBDBD",
|
|
136
|
+
},
|
|
137
|
+
dark: {
|
|
138
|
+
palette: {
|
|
139
|
+
primary: {
|
|
140
|
+
plainColor: "#1A77D2",
|
|
141
|
+
outlinedBorder: "#1A77D2",
|
|
142
|
+
onPrimary: "#FAFAFA",
|
|
143
|
+
primaryContainer: "#2397F3",
|
|
144
|
+
},
|
|
145
|
+
success: {
|
|
146
|
+
plainColor: "#4CAF50",
|
|
147
|
+
outlinedBorder: "#4CAF50",
|
|
148
|
+
},
|
|
149
|
+
danger: {
|
|
150
|
+
softBg: "#FEE4E2",
|
|
151
|
+
plainColor: "#F44336",
|
|
152
|
+
outlinedBorder: "#F44336",
|
|
153
|
+
},
|
|
154
|
+
warning: {
|
|
155
|
+
softBg: "#FEF0C7",
|
|
156
|
+
plainColor: "#DC6803",
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
textPrimary: "#FAFAFA",
|
|
160
|
+
textSecondary: "#FAFAFA",
|
|
161
|
+
textColor: "#FAFAFA",
|
|
162
|
+
textDisabled: "#FAFAFA",
|
|
163
|
+
surface: "#424242",
|
|
164
|
+
onSurface: "#212121",
|
|
165
|
+
surfaceVariant: "#616161",
|
|
166
|
+
surfaceTintDim: "#FAFAFA",
|
|
167
|
+
surfaceInverse: "#FAFAFA",
|
|
168
|
+
outlineEnabledBorder: "#757575",
|
|
169
|
+
secondaryContainer: "#757575",
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
breakpoints: {
|
|
173
|
+
values: {
|
|
174
|
+
xs: 0,
|
|
175
|
+
sm: 444,
|
|
176
|
+
md: 600,
|
|
177
|
+
lg: 900,
|
|
178
|
+
xl: 1200,
|
|
179
|
+
xxl: 1536,
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
spacingScale: {
|
|
183
|
+
"3xs": "2px",
|
|
184
|
+
"2xs": "4px",
|
|
185
|
+
xs: "8px",
|
|
186
|
+
sm: "12px",
|
|
187
|
+
md: "16px",
|
|
188
|
+
lg: "24px",
|
|
189
|
+
xl: "32px",
|
|
190
|
+
"2xl": "40px",
|
|
191
|
+
"3xl": "48px",
|
|
192
|
+
},
|
|
193
|
+
customFontFamily: {
|
|
194
|
+
light: {
|
|
195
|
+
primary: "Ubuntu, sans-serif",
|
|
196
|
+
secondary: "Roboto, sans-serif",
|
|
197
|
+
},
|
|
198
|
+
dark: {
|
|
199
|
+
primary: "Ubuntu, sans-serif",
|
|
200
|
+
secondary: "Roboto, sans-serif",
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
customRadius: {
|
|
204
|
+
light: {
|
|
205
|
+
none: "0px",
|
|
206
|
+
"2xs": "2px",
|
|
207
|
+
xs: "4px",
|
|
208
|
+
sm: "8px",
|
|
209
|
+
md: "12px",
|
|
210
|
+
lg: "16px",
|
|
211
|
+
xl: "24px",
|
|
212
|
+
"2xl": "232px",
|
|
213
|
+
full: "1000px",
|
|
214
|
+
},
|
|
215
|
+
dark: {
|
|
216
|
+
none: "0px",
|
|
217
|
+
"2xs": "2px",
|
|
218
|
+
xs: "4px",
|
|
219
|
+
sm: "8px",
|
|
220
|
+
md: "12px",
|
|
221
|
+
lg: "16px",
|
|
222
|
+
xl: "24px",
|
|
223
|
+
"2xl": "232px",
|
|
224
|
+
full: "1000px",
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
border: {
|
|
228
|
+
light: {
|
|
229
|
+
size: "1px",
|
|
230
|
+
},
|
|
231
|
+
dark: {
|
|
232
|
+
size: "2px",
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
<ClassicQuizPlay {...otherProps} themeOptions={themeOptions} />;
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
#### Lead Collection
|
|
241
|
+
|
|
242
|
+
Enable lead capture functionality:
|
|
243
|
+
|
|
244
|
+
```tsx
|
|
245
|
+
import { LeadsOptions } from "fansunited-frontend-core";
|
|
246
|
+
|
|
247
|
+
const leads: LeadsOptions = {
|
|
248
|
+
position: "before", // "before" | "after"
|
|
249
|
+
fields: ["fullName"], // | "fullName" | "firstName" | "lastName" | "email" | "gender" | "country" | "phoneCountryCode" | "phoneNumber";
|
|
250
|
+
campaignId: "test-quizzes",
|
|
251
|
+
campaignName: "Test Quizzes",
|
|
252
|
+
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"
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
<ClassicQuizPlay {...otherProps} leads={leads} />;
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
#### TypeScript Support
|
|
259
|
+
|
|
260
|
+
This package is built with TypeScript and provides full type definitions. Import types from `fansunited-frontend-core`:
|
|
261
|
+
|
|
262
|
+
```tsx
|
|
263
|
+
import {
|
|
264
|
+
ClassicQuizPlayProps,
|
|
265
|
+
WidgetTemplate,
|
|
266
|
+
WidgetProps,
|
|
267
|
+
CustomThemeOptions,
|
|
268
|
+
LeadsOptions,
|
|
269
|
+
AnalyticsEvent,
|
|
270
|
+
} from "fansunited-frontend-core";
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
#### Peer Dependencies
|
|
274
|
+
|
|
275
|
+
```json
|
|
276
|
+
{
|
|
277
|
+
"react": ">=16.8.0",
|
|
278
|
+
"react-dom": ">=16.8.0"
|
|
279
|
+
}
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
#### Bundle
|
|
283
|
+
|
|
284
|
+
The component uses shadow DOM and emotion for isolated styling, ensuring no CSS conflicts with your application.
|
|
285
|
+
|
|
286
|
+
#### Examples
|
|
287
|
+
|
|
288
|
+
##### Basic Quiz
|
|
289
|
+
|
|
290
|
+
```tsx
|
|
291
|
+
import { ClassicQuizPlay } from "fansunited-frontend-components";
|
|
292
|
+
import { WidgetTemplate } from "fansunited-frontend-core";
|
|
293
|
+
|
|
294
|
+
<ClassicQuizPlay
|
|
295
|
+
entityId="quiz-123"
|
|
296
|
+
sdk={sdkInstance}
|
|
297
|
+
template={WidgetTemplate.STANDARD}
|
|
298
|
+
language="en"
|
|
299
|
+
/>;
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
##### Customized Quiz
|
|
303
|
+
|
|
304
|
+
```tsx
|
|
305
|
+
<ClassicQuizPlay
|
|
306
|
+
entityId="quiz-123"
|
|
307
|
+
sdk={sdkInstance}
|
|
308
|
+
template={WidgetTemplate.STANDARD}
|
|
309
|
+
imagePosition="right"
|
|
310
|
+
language="en"
|
|
311
|
+
showAnswerExplanations={true}
|
|
312
|
+
themeOptions={{
|
|
313
|
+
mode: "dark",
|
|
314
|
+
}}
|
|
315
|
+
leads={{
|
|
316
|
+
phoneCountryCode: "44",
|
|
317
|
+
}}
|
|
318
|
+
/>
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
#### Related Packages
|
|
322
|
+
|
|
323
|
+
- [`fansunited-frontend-core`](https://www.npmjs.com/package/fansunited-frontend-core) - Core types and utilities
|
package/components.d.ts
CHANGED
|
@@ -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,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CACjC,CAAC"}
|