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