pollcatch 1.0.12 → 1.1.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 +6 -224
- package/package.json +2 -2
- package/pc.js +4030 -2637
package/README.md
CHANGED
|
@@ -12,7 +12,6 @@ A collection of lightweight, customizable feedback Web Components built with Lit
|
|
|
12
12
|
- NPS (Net Promoter Score)
|
|
13
13
|
- Poll questions
|
|
14
14
|
- Text feedback
|
|
15
|
-
- Consistent API across all components
|
|
16
15
|
- Styling via CSS custom properties
|
|
17
16
|
- Accessible and responsive design
|
|
18
17
|
|
|
@@ -34,229 +33,12 @@ pnpm install pollcatch
|
|
|
34
33
|
</script>
|
|
35
34
|
|
|
36
35
|
<!-- Use the unified wrapper component (recommended) -->
|
|
37
|
-
<poll-catch type="stars"
|
|
38
|
-
<poll-catch type="nps"
|
|
39
|
-
<poll-catch type="poll"
|
|
40
|
-
<poll-catch type="text"
|
|
41
|
-
<poll-catch type="reaction"
|
|
42
|
-
|
|
43
|
-
<!-- Or use the components individually -->
|
|
44
|
-
<pc-stars max-stars="5" label="How would you rate our service?"></pc-stars>
|
|
45
|
-
<pc-reaction options="👍,👎" label="Was this helpful?"></pc-reaction>
|
|
46
|
-
<pc-reaction icon="like" label="Like this article?"></pc-reaction>
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Available Components
|
|
50
|
-
|
|
51
|
-
### Stars Component (`<pc-stars>`)
|
|
52
|
-
|
|
53
|
-
A flexible star rating component with a sophisticated two-mode experience for collecting and displaying user feedback.
|
|
54
|
-
|
|
55
|
-
#### Basic Usage
|
|
56
|
-
|
|
57
|
-
```html
|
|
58
|
-
<pc-stars name="satisfaction" label="How satisfied are you?" show-stats></pc-stars>
|
|
59
|
-
<pc-stars name="service" label="Service quality" show-stats="always"show-chart></pc-stars>
|
|
60
|
-
<pc-stars name="detailed" label="Detailed rating (1-10)" num-stars="10" show-stats></pc-stars>
|
|
61
|
-
<pc-stars name="quick" label="Quick feedback"></pc-stars>
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
#### Properties
|
|
65
|
-
|
|
66
|
-
| Property | Type | Default | Description |
|
|
67
|
-
|----------|------|---------|-------------|
|
|
68
|
-
| `name` | `string` | Required | Unique identifier for the rating |
|
|
69
|
-
| `label` | `string` | `''` | Label text displayed above the stars |
|
|
70
|
-
| `num-stars` | `number` | `5` | Number of stars to display (1-10) |
|
|
71
|
-
| `show-stats` | `boolean` | `false` | Show stats text below stars |
|
|
72
|
-
| `show-chart` | `boolean` | `false` | Enable chart toggle button |
|
|
73
|
-
| `readonly` | `boolean` | `false` | Hide add/edit controls |
|
|
74
|
-
| `primary-color` | `string` | `''` | Custom primary color |
|
|
75
|
-
| `accent-color` | `string` | `''` | Custom star color |
|
|
76
|
-
|
|
77
|
-
### Reaction Component (`<pc-reaction>`)
|
|
78
|
-
|
|
79
|
-
An emoji-based reaction component for emotional feedback. Can be used for thumbs up/down, emoji reactions, custom feedback options, and also supports custom reaction icons.
|
|
80
|
-
|
|
81
|
-
```html
|
|
82
|
-
<pc-reaction label="Was this helpful?" options="👍,👎" </pc-reaction>
|
|
83
|
-
<pc-reaction label="React to this article" options="👍,❤️,😂,😮,😢,😡" compact multiple show-stats></pc-reaction>
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
**Custom Reaction Icons:**
|
|
87
|
-
You can define custom icons using the `<pc-reaction-icon>` element as children of `<pc-reaction>`. This allows you to use SVGs or custom images as reaction options.
|
|
88
|
-
|
|
89
|
-
```html
|
|
90
|
-
<pc-reaction label="How do you feel?"
|
|
91
|
-
<pc-reaction-icon name="like" icon="👍" tooltip="Like"></pc-reaction-icon>
|
|
92
|
-
<pc-reaction-icon name="love" icon="❤️" tooltip="Love"></pc-reaction-icon>
|
|
93
|
-
<pc-reaction-icon name="star" icon="star-outline.svg" tooltip="Star"></pc-reaction-icon>
|
|
94
|
-
<pc-reaction-icon name="custom" icon="/images/custom-icon.png" tooltip="Custom"></pc-reaction-icon>
|
|
95
|
-
</pc-reaction>
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
### NPS Component (`<pc-nps>`)
|
|
99
|
-
|
|
100
|
-
A Net Promoter Score component for collecting loyalty metrics.
|
|
101
|
-
|
|
102
|
-
```html
|
|
103
|
-
<pc-nps label="How likely are you to recommend us?"></pc-nps>
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### Poll Component (`<pc-poll>`)
|
|
107
|
-
|
|
108
|
-
A component for single-choice poll questions.
|
|
109
|
-
|
|
110
|
-
```html
|
|
111
|
-
<pc-poll label="Would you use this feature again?" options='["Yes", "No", "Maybe"]' selected="Yes"></pc-poll>
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### Text Component (`<pc-text>`)
|
|
115
|
-
|
|
116
|
-
A component for collecting free-form text feedback.
|
|
117
|
-
|
|
118
|
-
```html
|
|
119
|
-
<pc-text label="Additional comments" placeholder="Your thoughts?" maxlength="200"></pc-text>
|
|
36
|
+
<poll-catch type="stars" question="Rate our service" max="5"></poll-catch>
|
|
37
|
+
<poll-catch type="nps" question="How likely are you to recommend us?"></poll-catch>
|
|
38
|
+
<poll-catch type="poll" question="Favorite color?" options='["Red", "Blue", "Green"]'></poll-catch>
|
|
39
|
+
<poll-catch type="text" question="Feedback" placeholder="Tell us what you think..."></poll-catch>
|
|
40
|
+
<poll-catch type="reaction" question="How was your experience?" options='["👍", "👎"]'></poll-catch>
|
|
120
41
|
```
|
|
121
42
|
|
|
122
|
-
## Common Attributes
|
|
123
|
-
|
|
124
|
-
All components inherit from the base widget and share these common attributes:
|
|
125
|
-
|
|
126
|
-
- `label`: The question or prompt text
|
|
127
|
-
- `label-position`: Position of the label (top, left, right, bottom)
|
|
128
|
-
- `label-align`: Alignment of the label
|
|
129
|
-
- `readonly`: Whether the field is readonly
|
|
130
|
-
- `tags`: Custom tags for analytics or data categorization
|
|
131
|
-
- `widget-type`: Type identifier for the widget (automatically set)
|
|
132
|
-
- `name`: Identifier for the component
|
|
133
|
-
- `project`: Project identifier for the component (optional, for registered users)
|
|
134
|
-
|
|
135
|
-
## Events
|
|
136
|
-
|
|
137
|
-
All components emit a `change` event when their value changes:
|
|
138
|
-
|
|
139
|
-
```javascript
|
|
140
|
-
document.querySelector('pc-stars').addEventListener('change', (e) => {
|
|
141
|
-
console.log('New rating:', e.detail.value);
|
|
142
|
-
});
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
The event detail contains:
|
|
146
|
-
|
|
147
|
-
- `projectId`: The project identifier
|
|
148
|
-
- `widgetType`: The type of the widget
|
|
149
|
-
- `widgetName`: The name of the widget
|
|
150
|
-
- `sessionId`: The session identifier
|
|
151
|
-
- `timestamp`: The timestamp of the event
|
|
152
|
-
- `url`: The URL of the page
|
|
153
|
-
- `numericValue`: The numeric value of the widget
|
|
154
|
-
- `textValues`: The text values of the widget
|
|
155
|
-
- `tags`: Any custom tags assigned to the widget
|
|
156
|
-
|
|
157
|
-
## Customization
|
|
158
|
-
|
|
159
|
-
### CSS Custom Properties
|
|
160
|
-
|
|
161
|
-
You can customize the appearance using the following CSS variables:
|
|
162
|
-
|
|
163
|
-
| Variable | Default | Description |
|
|
164
|
-
|----------|---------|-------------|
|
|
165
|
-
| `--pc-primary-color` | `#2196f3` | Primary accent color for components |
|
|
166
|
-
| `--pc-text-color` | `#333333` | Main text color |
|
|
167
|
-
| `--pc-mute-color` | `#cccccc` | Muted/disabled color |
|
|
168
|
-
| `--pc-accent-color` | `#f2b200` | Accent color for stars, icons, etc. |
|
|
169
|
-
| `--pc-accent-hover-color` | `#ffc61a` | Hover state for accent elements |
|
|
170
|
-
| `--pc-icon-size` | `clamp(1.1em, calc(1em + 0.4vw), 1.6em)` | Icon size |
|
|
171
|
-
| `--pc-control-spacing` | `clamp(0.4em, 0.6em, 0.8em)` | Spacing between controls |
|
|
172
|
-
| `--pc-button-radius` | `var(--pc-border-radius-md)` | Border radius for buttons |
|
|
173
|
-
| `--pc-border-radius-sm` | `2px` | Small border radius |
|
|
174
|
-
| `--pc-border-radius-md` | `4px` | Medium border radius |
|
|
175
|
-
| `--pc-border-radius-lg` | `8px` | Large border radius |
|
|
176
|
-
| `--pc-loading-width` | `clamp(1.4em, 1.8em, 2.2em)` | Width of loading indicator |
|
|
177
|
-
| `--pc-loading-height` | `clamp(0.6em, 0.7em, 0.8em)` | Height of loading indicator |
|
|
178
|
-
| `--pc-chart-max-width` | `clamp(200px, 100%, 300px)` | Max width for charts |
|
|
179
|
-
| `--pc-chart-min-width` | `clamp(150px, 12px, 200px)` | Min width for charts |
|
|
180
|
-
| `--pc-bar-height` | `clamp(0.5em, 0.6em, 0.8em)` | Height of bar charts |
|
|
181
|
-
| `--pc-font-size-small` | `clamp(0.6em, 0.7em, 0.8em)` | Small font size |
|
|
182
|
-
| `--pc-font-size-medium` | `clamp(0.8em, 0.9em, 1em)` | Medium font size |
|
|
183
|
-
|
|
184
|
-
These variables can be overridden globally or per-component to customize the look and feel of Pollcatch widgets.
|
|
185
|
-
|
|
186
|
-
### Custom CSS via Attribute
|
|
187
|
-
|
|
188
|
-
You can also use the `css` attribute on any Pollcatch component to inject custom CSS for internal elements. This allows for advanced customization beyond the available CSS variables.
|
|
189
|
-
|
|
190
|
-
**Example:**
|
|
191
|
-
```html
|
|
192
|
-
<pc-stars
|
|
193
|
-
label="Custom Stars"
|
|
194
|
-
css=".stars-section { background: #f9f9f9; } .pc-label { color: #e91e63; }"
|
|
195
|
-
></pc-stars>
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
## Accessibility
|
|
199
|
-
|
|
200
|
-
All components are designed with accessibility in mind:
|
|
201
|
-
- Proper ARIA attributes
|
|
202
|
-
- Keyboard navigation
|
|
203
|
-
- Screen reader announcements
|
|
204
|
-
- Sufficient color contrast
|
|
205
|
-
|
|
206
|
-
## Browser Support
|
|
207
|
-
|
|
208
|
-
Pollcatch components work in all modern browsers that support Web Components:
|
|
209
|
-
- Chrome
|
|
210
|
-
- Firefox
|
|
211
|
-
- Safari
|
|
212
|
-
- Edge
|
|
213
|
-
|
|
214
|
-
## Project Attribute
|
|
215
|
-
|
|
216
|
-
Registered users can organize their widgets and polls under a unique project by using the `project` attribute. Each project can contain one or more widgets, allowing for better data security, integrity, and access to advanced features.
|
|
217
|
-
|
|
218
|
-
**Benefits of using a project:**
|
|
219
|
-
- Enhanced data security and integrity
|
|
220
|
-
- Project-level reporting and analytics
|
|
221
|
-
- Webhook integrations for real-time notifications
|
|
222
|
-
- Website/domain whitelisting for data access control
|
|
223
|
-
- Longer data retention and advanced management options
|
|
224
|
-
|
|
225
|
-
**Example:**
|
|
226
|
-
```html
|
|
227
|
-
<pc-stars name="customer-satisfaction" label="How satisfied are you?" project="my-website-project"></pc-stars>
|
|
228
|
-
<pc-poll name="feature-vote" label="Vote for a feature" project="my-website-project"></pc-poll>
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
To use these features, register and create a project in your Pollcatch dashboard, then assign the `project` attribute to your widgets.
|
|
232
|
-
|
|
233
|
-
## How to Set the Project Attribute
|
|
234
|
-
|
|
235
|
-
There are several ways to specify the `project` for your widgets. Choose the approach that best fits your integration:
|
|
236
|
-
|
|
237
|
-
### 1. Set on Each Widget (Tag Level)
|
|
238
|
-
Assign the `project` attribute directly to each widget tag. This is the most explicit and flexible method.
|
|
239
|
-
|
|
240
|
-
```html
|
|
241
|
-
<pc-stars name="customer-satisfaction" label="How satisfied are you?" project="my-website-project"></pc-stars>
|
|
242
|
-
<pc-poll name="feature-vote" label="Vote for a feature" project="my-website-project"></pc-poll>
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
### 2. Set as a Global Variable
|
|
246
|
-
If all widgets on the page share the same project, you can set a global variable before loading the Pollcatch script:
|
|
247
|
-
|
|
248
|
-
```html
|
|
249
|
-
<script>
|
|
250
|
-
window.pcProject = 'my-website-project';
|
|
251
|
-
</script>
|
|
252
|
-
<script type="module" src="https://cdn.jsdelivr.net/npm/pollcatch@latest"></script>
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
### 3. Set via Script Tag Attribute
|
|
256
|
-
Alternatively, add a `pc-project` attribute to the script tag that loads Pollcatch. All widgets on the page will use this project key by default:
|
|
257
|
-
|
|
258
|
-
```html
|
|
259
|
-
<script type="module" src="https://cdn.jsdelivr.net/npm/pollcatch@latest" pc-project="my-website-project"></script>
|
|
260
|
-
```
|
|
261
43
|
|
|
262
|
-
|
|
44
|
+
For detailed documentation, properties, and advanced usage, see the [Pollcatch Documentation](https://pollcatch.com).
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pollcatch",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.1.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "pc.js",
|
|
7
7
|
"module": "pc.js",
|
|
@@ -25,4 +25,4 @@
|
|
|
25
25
|
],
|
|
26
26
|
"author": "David Lin <david@pollcatch.com>",
|
|
27
27
|
"homepage": "https://www.pollcatch.com"
|
|
28
|
-
}
|
|
28
|
+
}
|