Gathering detailed insights and metrics for poll-party
Gathering detailed insights and metrics for poll-party
Gathering detailed insights and metrics for poll-party
Gathering detailed insights and metrics for poll-party
npm install poll-party
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
19 Stars
14 Commits
2 Watching
1 Branches
1 Contributors
Updated on 29 Sept 2024
TypeScript (76.7%)
CSS (15.07%)
HTML (7%)
JavaScript (1.24%)
Cumulative downloads
Total Downloads
Last day
-83.3%
1
Compared to previous day
Last week
-24.3%
28
Compared to previous week
Last month
-20.4%
109
Compared to previous month
Last year
55.8%
2,057
Compared to previous year
This web component adds a new 'poll-party' element which is used to add a live poll to any web page, given a PartyKit server to connect to.
Built using Stencil.
Check out the live demo.
This component was created during Matt's summer 2023 residency. The purpose is to experiment with multiplayer interactions, and simultaneously see what PartyKit can do. It's called a sketch because it's lightweight and quick, and because we learn something in making it.
The web component allows you to create a live poll straight from HTML, from otherwise static websites. You import the component, and give it a question and some options.
You also have to provide a host. That's where your PartyKit back-end will run. See below.
The poll comes to life and looks like this:
You can vote. It records the fact that you've voted in localStorage on your browser, and sends your option to the PartyKit server.
The results look like this:
...and they update in realtime as other people vote.
To create a new poll: change the HTML. The PartyKit server doesn't know about the question or options specifically -- it stores the votes against a hash of the poll text. So if you change the question or options, it's a new poll.
The component is published on npm as poll-party.
In production, add this script tag to your HTML head:
<script type='module' src='https://unpkg.com/poll-party@0.0.1'></script>
In development: use 127.0.0.1:1999
and, from this repo, run:
npx partykit dev
In production: use the host of your own PartyKit server (you'll be given it when you run npx partykit deploy
) or use: poll-party.genmon.partykit.dev
.
If you'd like to add features (e.g. poll expiry dates) start by building on the server in partykit/polls.ts
.
styles="false"
attribute, it should not use the default styles, and instead rely on the host page to style itFollow these instructions to start developing a new component.
From an empty directory:
npm init stencil
(select 'component')
The project was named 'poll-party' and then the files moved to the top-level directory.
We also use local storage, so:
npm i stencil-store-storage
npm install partykit@beta partysocket@beta
...for PartyKit.
We want to use Tailwind CSS, so use stencil-tailwind-plugin.
Install:
npm install -D stencil-tailwind-plugin tailwindcss
npm install @stencil/sass --save-dev
tailwindcss init
Then copy the stencil.config.ts
from this repo, and also copy src/styles/tailwind.css
into place (with the top three @tailwind
lines).
Finally delete the directory src/components/my-component
and run stencil generate
to create a new component called poll-party
(or whatever).
npm run build
will create the dist
etc directory.
During development, use npm start
to run the test server and look at index.html
from your src/
directory.
Don't forget to also run npx partykit dev
for the server.
No vulnerabilities found.
No security vulnerabilities found.