forked from quic-issues/427e7578-d7bf-49c8-aee9-2dd999e25316
- Add peer-to-peer polling with real-time synchronization via PeerJS - Implement vote changing, unvoting, and proper vote validation - Add modal interface for adding poll options - Fix vote inheritance issues for new users joining rooms - Create sidebar with available polls and connected peers - Add vote count synchronization across all connected peers - Implement proper vote state validation per user - Add localStorage persistence for polls and vote states - Create responsive design with modern UI components - Replace emojis with proper text-based icons - Add comprehensive error handling and user feedback - Support multiple polls with switching capabilities - Implement conflict resolution for concurrent voting
666 lines
10 KiB
CSS
666 lines
10 KiB
CSS
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
min-height: 100vh;
|
|
color: #333;
|
|
}
|
|
|
|
.container {
|
|
max-width: 1200px;
|
|
margin: 0 auto;
|
|
padding: 20px;
|
|
}
|
|
|
|
.main-content {
|
|
display: grid;
|
|
grid-template-columns: 280px 1fr;
|
|
gap: 20px;
|
|
margin-top: 20px;
|
|
}
|
|
|
|
.sidebar {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 20px;
|
|
}
|
|
|
|
.sidebar-section {
|
|
background: white;
|
|
border-radius: 12px;
|
|
padding: 20px;
|
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.sidebar-section h3 {
|
|
margin: 0 0 15px 0;
|
|
color: #333;
|
|
font-size: 1.1rem;
|
|
}
|
|
|
|
.sidebar-hint {
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
.hint-text {
|
|
font-size: 0.8rem;
|
|
color: #6b7280;
|
|
font-style: italic;
|
|
text-align: center;
|
|
padding: 8px;
|
|
background: #f9fafb;
|
|
border-radius: 6px;
|
|
border: 1px solid #e5e7eb;
|
|
}
|
|
|
|
.polls-list {
|
|
max-height: 300px;
|
|
overflow-y: auto;
|
|
}
|
|
|
|
.poll-item {
|
|
padding: 12px;
|
|
border: 1px solid #e5e7eb;
|
|
border-radius: 8px;
|
|
margin-bottom: 8px;
|
|
cursor: pointer;
|
|
transition: all 0.3s;
|
|
position: relative;
|
|
}
|
|
|
|
.poll-item:hover {
|
|
border-color: #667eea;
|
|
background: #f9fafb;
|
|
transform: translateY(-1px);
|
|
}
|
|
|
|
.poll-item.active {
|
|
border-color: #667eea;
|
|
background: #ede9fe;
|
|
}
|
|
|
|
.poll-item-title {
|
|
font-weight: 500;
|
|
color: #333;
|
|
margin-bottom: 4px;
|
|
}
|
|
|
|
.poll-item-meta {
|
|
font-size: 0.8rem;
|
|
color: #6b7280;
|
|
}
|
|
|
|
.poll-item::after {
|
|
content: ">";
|
|
position: absolute;
|
|
right: 12px;
|
|
top: 50%;
|
|
transform: translateY(-50%);
|
|
color: #9ca3af;
|
|
font-size: 0.8rem;
|
|
opacity: 0;
|
|
transition: opacity 0.3s;
|
|
}
|
|
|
|
.poll-item:hover::after {
|
|
opacity: 1;
|
|
}
|
|
|
|
.no-polls {
|
|
color: #9ca3af;
|
|
font-style: italic;
|
|
text-align: center;
|
|
padding: 20px 0;
|
|
}
|
|
|
|
.peers-info {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 10px;
|
|
}
|
|
|
|
.peers-status {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
font-size: 0.9rem;
|
|
}
|
|
|
|
.status-text {
|
|
padding: 2px 8px;
|
|
border-radius: 12px;
|
|
font-size: 0.8rem;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.status-text.connected {
|
|
background: #dcfce7;
|
|
color: #16a34a;
|
|
}
|
|
|
|
.status-text.disconnected {
|
|
background: #fef2f2;
|
|
color: #dc2626;
|
|
}
|
|
|
|
.status-text.connecting {
|
|
background: #fef3c7;
|
|
color: #d97706;
|
|
}
|
|
|
|
.peers-sidebar {
|
|
list-style: none;
|
|
margin: 0;
|
|
padding: 0;
|
|
max-height: 150px;
|
|
overflow-y: auto;
|
|
}
|
|
|
|
.peers-sidebar li {
|
|
padding: 6px 0;
|
|
border-bottom: 1px solid #f3f4f6;
|
|
font-size: 0.9rem;
|
|
color: #6b7280;
|
|
}
|
|
|
|
.peers-sidebar li:last-child {
|
|
border-bottom: none;
|
|
}
|
|
|
|
header {
|
|
background: white;
|
|
border-radius: 12px;
|
|
padding: 20px;
|
|
margin-bottom: 20px;
|
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
|
|
h1 {
|
|
color: #667eea;
|
|
font-size: 2rem;
|
|
}
|
|
|
|
.connection-status {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
font-size: 0.9rem;
|
|
}
|
|
|
|
#peer-id {
|
|
background: #f0f0f0;
|
|
padding: 5px 10px;
|
|
border-radius: 6px;
|
|
font-family: monospace;
|
|
max-width: 150px;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
|
|
.status-connected {
|
|
color: #10b981;
|
|
}
|
|
|
|
.status-disconnected {
|
|
color: #ef4444;
|
|
}
|
|
|
|
.status-connecting {
|
|
color: #f59e0b;
|
|
}
|
|
|
|
.section {
|
|
background: white;
|
|
border-radius: 12px;
|
|
padding: 20px;
|
|
margin-bottom: 20px;
|
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.section.hidden {
|
|
display: none;
|
|
}
|
|
|
|
h2 {
|
|
color: #333;
|
|
margin-bottom: 20px;
|
|
font-size: 1.5rem;
|
|
}
|
|
|
|
h3 {
|
|
color: #666;
|
|
margin-bottom: 15px;
|
|
font-size: 1.1rem;
|
|
}
|
|
|
|
.connection-info {
|
|
background: #f0f9ff;
|
|
padding: 15px;
|
|
border-radius: 8px;
|
|
margin-bottom: 20px;
|
|
border-left: 4px solid #3b82f6;
|
|
}
|
|
|
|
.connection-info p {
|
|
margin: 5px 0;
|
|
font-size: 0.9rem;
|
|
color: #1e40af;
|
|
}
|
|
|
|
.connection-controls {
|
|
display: flex;
|
|
gap: 10px;
|
|
margin-bottom: 20px;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
input[type="text"] {
|
|
flex: 1;
|
|
min-width: 200px;
|
|
padding: 12px;
|
|
border: 2px solid #e5e7eb;
|
|
border-radius: 8px;
|
|
font-size: 1rem;
|
|
transition: border-color 0.3s;
|
|
}
|
|
|
|
input[type="text"]:focus {
|
|
outline: none;
|
|
border-color: #667eea;
|
|
}
|
|
|
|
button {
|
|
background: #667eea;
|
|
color: white;
|
|
border: none;
|
|
padding: 12px 20px;
|
|
border-radius: 8px;
|
|
font-size: 1rem;
|
|
cursor: pointer;
|
|
transition: all 0.3s;
|
|
}
|
|
|
|
button:hover {
|
|
background: #5a67d8;
|
|
transform: translateY(-1px);
|
|
}
|
|
|
|
button:disabled {
|
|
background: #9ca3af;
|
|
cursor: not-allowed;
|
|
transform: none;
|
|
}
|
|
|
|
button.small-btn {
|
|
padding: 8px 12px;
|
|
font-size: 0.9rem;
|
|
}
|
|
|
|
button.danger {
|
|
background: #ef4444;
|
|
}
|
|
|
|
button.danger:hover {
|
|
background: #dc2626;
|
|
}
|
|
|
|
|
|
.poll-form {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 15px;
|
|
}
|
|
|
|
#options-container {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 10px;
|
|
}
|
|
|
|
.option-input {
|
|
display: flex;
|
|
gap: 10px;
|
|
align-items: center;
|
|
}
|
|
|
|
.option-text {
|
|
flex: 1;
|
|
}
|
|
|
|
.remove-option-btn {
|
|
background: #ef4444;
|
|
color: white;
|
|
border: none;
|
|
padding: 4px 8px;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
font-size: 0.8rem;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
min-width: 60px;
|
|
}
|
|
|
|
.remove-option-btn.hidden {
|
|
display: none;
|
|
}
|
|
|
|
.poll-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.vote-hint {
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.vote-hint .hint-text {
|
|
font-size: 0.9rem;
|
|
color: #6b7280;
|
|
text-align: center;
|
|
padding: 10px;
|
|
background: #f0f9ff;
|
|
border-radius: 8px;
|
|
border: 1px solid #bfdbfe;
|
|
}
|
|
|
|
.options-list {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 15px;
|
|
}
|
|
|
|
.poll-option {
|
|
background: #f9fafb;
|
|
padding: 15px;
|
|
border-radius: 8px;
|
|
border: 2px solid transparent;
|
|
transition: all 0.3s;
|
|
cursor: pointer;
|
|
position: relative;
|
|
}
|
|
|
|
.poll-option:hover {
|
|
border-color: #667eea;
|
|
transform: translateY(-1px);
|
|
}
|
|
|
|
.poll-option.voted {
|
|
border-color: #10b981;
|
|
background: #ecfdf5;
|
|
}
|
|
|
|
.poll-option.voted::before {
|
|
content: "✓";
|
|
position: absolute;
|
|
top: 10px;
|
|
right: 10px;
|
|
background: #10b981;
|
|
color: white;
|
|
width: 20px;
|
|
height: 20px;
|
|
border-radius: 50%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-size: 12px;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.poll-option.change-vote {
|
|
border-color: #f59e0b;
|
|
background: #fffbeb;
|
|
}
|
|
|
|
.poll-option.change-vote:hover {
|
|
border-color: #d97706;
|
|
}
|
|
|
|
.option-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
.option-text {
|
|
font-weight: 500;
|
|
color: #333;
|
|
}
|
|
|
|
.vote-count {
|
|
background: #667eea;
|
|
color: white;
|
|
padding: 4px 8px;
|
|
border-radius: 12px;
|
|
font-size: 0.8rem;
|
|
}
|
|
|
|
.vote-bar {
|
|
background: #e5e7eb;
|
|
height: 8px;
|
|
border-radius: 4px;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.vote-fill {
|
|
background: #667eea;
|
|
height: 100%;
|
|
transition: width 0.3s ease;
|
|
}
|
|
|
|
.poll-actions {
|
|
display: flex;
|
|
gap: 10px;
|
|
margin-top: 20px;
|
|
}
|
|
|
|
.overlay {
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
background: rgba(0, 0, 0, 0.5);
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
align-items: center;
|
|
z-index: 1000;
|
|
}
|
|
|
|
.overlay.hidden {
|
|
display: none;
|
|
}
|
|
|
|
.loading-spinner {
|
|
width: 40px;
|
|
height: 40px;
|
|
border: 4px solid #f3f3f3;
|
|
border-top: 4px solid #667eea;
|
|
border-radius: 50%;
|
|
animation: spin 1s linear infinite;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
@keyframes spin {
|
|
0% { transform: rotate(0deg); }
|
|
100% { transform: rotate(360deg); }
|
|
}
|
|
|
|
.notification {
|
|
position: fixed;
|
|
top: 20px;
|
|
right: 20px;
|
|
background: #333;
|
|
color: white;
|
|
padding: 15px 20px;
|
|
border-radius: 8px;
|
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
z-index: 1001;
|
|
max-width: 300px;
|
|
}
|
|
|
|
.notification.success {
|
|
background: #10b981;
|
|
}
|
|
|
|
.notification.error {
|
|
background: #ef4444;
|
|
}
|
|
|
|
.notification.hidden {
|
|
display: none;
|
|
}
|
|
|
|
/* Modal Styles */
|
|
.modal {
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
background: rgba(0, 0, 0, 0.5);
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
z-index: 1002;
|
|
}
|
|
|
|
.modal.hidden {
|
|
display: none;
|
|
}
|
|
|
|
.modal-content {
|
|
background: white;
|
|
border-radius: 12px;
|
|
width: 90%;
|
|
max-width: 400px;
|
|
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
|
|
overflow: hidden;
|
|
}
|
|
|
|
.modal-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
padding: 20px;
|
|
border-bottom: 1px solid #e5e7eb;
|
|
}
|
|
|
|
.modal-header h3 {
|
|
margin: 0;
|
|
color: #333;
|
|
font-size: 1.2rem;
|
|
}
|
|
|
|
.modal-close {
|
|
background: none;
|
|
border: none;
|
|
font-size: 1.5rem;
|
|
color: #6b7280;
|
|
cursor: pointer;
|
|
padding: 0;
|
|
width: 30px;
|
|
height: 30px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
border-radius: 50%;
|
|
transition: all 0.3s;
|
|
}
|
|
|
|
.modal-close:hover {
|
|
background: #f3f4f6;
|
|
color: #374151;
|
|
}
|
|
|
|
.modal-body {
|
|
padding: 20px;
|
|
}
|
|
|
|
.modal-body input {
|
|
width: 100%;
|
|
padding: 12px;
|
|
border: 2px solid #e5e7eb;
|
|
border-radius: 8px;
|
|
font-size: 1rem;
|
|
transition: border-color 0.3s;
|
|
}
|
|
|
|
.modal-body input:focus {
|
|
outline: none;
|
|
border-color: #667eea;
|
|
}
|
|
|
|
.modal-footer {
|
|
padding: 20px;
|
|
border-top: 1px solid #e5e7eb;
|
|
display: flex;
|
|
gap: 10px;
|
|
justify-content: flex-end;
|
|
}
|
|
|
|
.btn-secondary {
|
|
background: #6b7280;
|
|
color: white;
|
|
}
|
|
|
|
.btn-secondary:hover {
|
|
background: #4b5563;
|
|
}
|
|
|
|
.btn-primary {
|
|
background: #667eea;
|
|
color: white;
|
|
}
|
|
|
|
.btn-primary:hover {
|
|
background: #5a67d8;
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.container {
|
|
padding: 10px;
|
|
}
|
|
|
|
.main-content {
|
|
grid-template-columns: 1fr;
|
|
gap: 15px;
|
|
}
|
|
|
|
.sidebar {
|
|
order: 2;
|
|
}
|
|
|
|
main {
|
|
order: 1;
|
|
}
|
|
|
|
header {
|
|
flex-direction: column;
|
|
gap: 15px;
|
|
text-align: center;
|
|
}
|
|
|
|
.connection-controls {
|
|
flex-direction: column;
|
|
}
|
|
|
|
.poll-header {
|
|
flex-direction: column;
|
|
gap: 10px;
|
|
align-items: flex-start;
|
|
}
|
|
}
|