fansunited-frontend-components 0.0.7 → 0.0.8
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 +165 -0
- package/components.d.ts +2 -1
- package/components.d.ts.map +1 -1
- package/components.js +29105 -22730
- package/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -383,6 +383,171 @@ import { WidgetTemplate } from "fansunited-frontend-core";
|
|
|
383
383
|
/>
|
|
384
384
|
```
|
|
385
385
|
|
|
386
|
+
### PollVote
|
|
387
|
+
|
|
388
|
+
Interactive poll voting component with real-time results, multiple choice support, and customizable templates. Perfect for engaging audiences with opinion polls, surveys, and voting campaigns.
|
|
389
|
+
|
|
390
|
+
**Key Features:**
|
|
391
|
+
- Single and multiple choice voting
|
|
392
|
+
- Real-time vote results and percentages
|
|
393
|
+
- Three responsive templates (Standard, Split, Overlay)
|
|
394
|
+
- Lead collection integration
|
|
395
|
+
- Authentication support
|
|
396
|
+
- Vote attempt limits
|
|
397
|
+
- Custom theming and branding
|
|
398
|
+
|
|
399
|
+
#### Required Props
|
|
400
|
+
|
|
401
|
+
| Prop | Type | Description |
|
|
402
|
+
| ---------- | -------------------- | ----------------------- |
|
|
403
|
+
| `entityId` | `string` | Classic Quiz identifier |
|
|
404
|
+
| `sdk` | `FansUnitedSDKModel` | SDK instance |
|
|
405
|
+
| `template` | `WidgetTemplate` | Layout template |
|
|
406
|
+
| `language` | `LanguageType` | Display language |
|
|
407
|
+
|
|
408
|
+
#### Optional Props
|
|
409
|
+
|
|
410
|
+
| Prop | Type | Description |
|
|
411
|
+
| ---------------------------- | -------------------- | ------------------------------------------- |
|
|
412
|
+
| `themeOptions` | `CustomThemeOptions` | Theme configuration |
|
|
413
|
+
| `leads` | `LeadsOptions` | Lead collection settings |
|
|
414
|
+
| `imagePosition` | `"left" \| "right"` | Image position (STANDARD template only) |
|
|
415
|
+
| `defaultImagePlaceholderUrl` | `string` | URL for default image placeholder |
|
|
416
|
+
| `userIsLoggedIn` | `boolean` | Determine if the user is logged in |
|
|
417
|
+
| `signInCTA` | `SignInCTADetails` | Sign in call to action button configuration |
|
|
418
|
+
|
|
419
|
+
#### Templates
|
|
420
|
+
|
|
421
|
+
```tsx
|
|
422
|
+
import { WidgetTemplate, PollVoteProps } from "fansunited-frontend-core";
|
|
423
|
+
|
|
424
|
+
// Standard template with optional image positioning
|
|
425
|
+
const standardProps: PollVoteProps = {
|
|
426
|
+
template: WidgetTemplate.STANDARD,
|
|
427
|
+
imagePosition: "left", // or 'right'
|
|
428
|
+
// ... other props
|
|
429
|
+
};
|
|
430
|
+
|
|
431
|
+
// Split template - side-by-side layout
|
|
432
|
+
const splitProps: PollVoteProps = {
|
|
433
|
+
template: WidgetTemplate.SPLIT,
|
|
434
|
+
// imagePosition not available for non-standard templates
|
|
435
|
+
// ... other props
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
// Overlay template - full-screen immersive experience
|
|
439
|
+
const overlayProps: PollVoteProps = {
|
|
440
|
+
template: WidgetTemplate.OVERLAY,
|
|
441
|
+
// ... other props
|
|
442
|
+
};
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
#### Sign in Configuration
|
|
446
|
+
|
|
447
|
+
Control user authentication and voting permissions using the `userIsLoggedIn` and `signInCTA` props.
|
|
448
|
+
|
|
449
|
+
```tsx
|
|
450
|
+
import { SignInCTADetails } from "fansunited-frontend-core";
|
|
451
|
+
|
|
452
|
+
// Custom sign-in component
|
|
453
|
+
const signInCTA: SignInCTADetails = {
|
|
454
|
+
component: <CustomSignInButton />
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
// Basic sign-in with onClick handler
|
|
458
|
+
const signInCTA: SignInCTADetails = {
|
|
459
|
+
defaultLabel: "Sign in to vote",
|
|
460
|
+
onClick: () => {
|
|
461
|
+
// Handle sign-in logic
|
|
462
|
+
console.log("Sign in clicked");
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
// Sign-in with URL navigation
|
|
467
|
+
const signInCTA: SignInCTADetails = {
|
|
468
|
+
defaultLabel: "Login to participate",
|
|
469
|
+
url: "https://your-auth-provider.com/login",
|
|
470
|
+
target: "_blank"
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
<PollVote
|
|
474
|
+
{...otherProps}
|
|
475
|
+
userIsLoggedIn={false}
|
|
476
|
+
signInCTA={signInCTA}
|
|
477
|
+
/>
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
**Sign-in Priority Order:**
|
|
481
|
+
|
|
482
|
+
1. **Custom Component** - If `signInCTA.component` is provided, it will be rendered
|
|
483
|
+
2. **Click Handler** - If `signInCTA.onClick` is provided, a button with the handler will be rendered
|
|
484
|
+
3. **URL Navigation** - If `signInCTA.url` is provided, a button will be rendered and clicking will navigate to the URL
|
|
485
|
+
4. **Disabled** - If no `signInCTA` is provided, a disabled button will be shown
|
|
486
|
+
|
|
487
|
+
**Behavior:**
|
|
488
|
+
|
|
489
|
+
- When `userIsLoggedIn` is `false` and the poll requires authentication (`authRequirement: "REGISTERED"`), the sign-in screen will be displayed instead of the poll
|
|
490
|
+
|
|
491
|
+
#### Lead Collection
|
|
492
|
+
|
|
493
|
+
Capture user information before or after voting:
|
|
494
|
+
|
|
495
|
+
```tsx
|
|
496
|
+
import { LeadsOptions } from "fansunited-frontend-core";
|
|
497
|
+
|
|
498
|
+
const leads: LeadsOptions = {
|
|
499
|
+
position: "before", // "before" | "after"
|
|
500
|
+
fields: ["fullName", "email"], // Available: "fullName" | "firstName" | "lastName" | "email" | "gender" | "country" | "phoneCountryCode" | "phoneNumber"
|
|
501
|
+
campaignId: "poll-campaign-2024",
|
|
502
|
+
campaignName: "User Opinion Poll",
|
|
503
|
+
phoneCountryCode: "44", // Default country code for phone fields
|
|
504
|
+
};
|
|
505
|
+
|
|
506
|
+
<PollVote {...otherProps} leads={leads} />;
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
#### Examples
|
|
510
|
+
|
|
511
|
+
##### Basic Poll
|
|
512
|
+
|
|
513
|
+
```tsx
|
|
514
|
+
import { PollVote } from "fansunited-frontend-components";
|
|
515
|
+
import { WidgetTemplate } from "fansunited-frontend-core";
|
|
516
|
+
|
|
517
|
+
<PollVote
|
|
518
|
+
entityId="poll-123"
|
|
519
|
+
sdk={sdkInstance}
|
|
520
|
+
template={WidgetTemplate.STANDARD}
|
|
521
|
+
language="en"
|
|
522
|
+
/>;
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
##### Customized Poll
|
|
526
|
+
|
|
527
|
+
```tsx
|
|
528
|
+
<PollVote
|
|
529
|
+
entityId="poll-123"
|
|
530
|
+
sdk={sdkInstance}
|
|
531
|
+
template={WidgetTemplate.OVERLAY}
|
|
532
|
+
language="en"
|
|
533
|
+
userIsLoggedIn={false}
|
|
534
|
+
signInCTA={{
|
|
535
|
+
defaultLabel: "Sign in to vote",
|
|
536
|
+
onClick: () => handleSignIn(),
|
|
537
|
+
}}
|
|
538
|
+
leads={{
|
|
539
|
+
position: "after",
|
|
540
|
+
fields: ["fullName", "email"],
|
|
541
|
+
campaignId: "poll-campaign",
|
|
542
|
+
campaignName: "User Survey 2024",
|
|
543
|
+
phoneCountryCode: "44",
|
|
544
|
+
}}
|
|
545
|
+
themeOptions={{
|
|
546
|
+
mode: "dark",
|
|
547
|
+
}}
|
|
548
|
+
/>
|
|
549
|
+
```
|
|
550
|
+
|
|
386
551
|
#### Related Packages
|
|
387
552
|
|
|
388
553
|
- [`fansunited-frontend-core`](https://www.npmjs.com/package/fansunited-frontend-core) - Core types and utilities
|
package/components.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ClassicQuizPlayProps } from 'fansunited-frontend-core';
|
|
1
|
+
import { ClassicQuizPlayProps, PollVoteProps } from 'fansunited-frontend-core';
|
|
2
2
|
|
|
3
3
|
export declare const ClassicQuizPlay: React.FC<ClassicQuizPlayProps>;
|
|
4
|
+
export declare const PollVote: React.FC<PollVoteProps>;
|
|
4
5
|
//# sourceMappingURL=components.d.ts.map
|
package/components.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/components.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/components.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAI/E,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CACjC,CAAC;AAE3B,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAAqB,CAAC"}
|