Initial code of the vibes

This commit is contained in:
2025-07-18 23:22:06 -05:00
parent e7413bcb7b
commit 72a4c4f265
8 changed files with 1392 additions and 2 deletions

387
static/css/style.css Normal file
View File

@@ -0,0 +1,387 @@
/* Reset and base styles */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
line-height: 1.6;
color: #333;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
/* Header */
.header {
text-align: center;
margin-bottom: 40px;
color: white;
}
.header h1 {
font-size: 2.5rem;
font-weight: 700;
margin-bottom: 10px;
text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.header p {
font-size: 1.1rem;
opacity: 0.9;
font-weight: 300;
}
/* Main content */
.main-content {
display: grid;
gap: 30px;
grid-template-columns: 1fr;
}
@media (min-width: 768px) {
.main-content {
grid-template-columns: 1fr 1fr;
}
}
/* Sections */
.input-section,
.results-section,
.sessions-section {
background: white;
border-radius: 16px;
padding: 30px;
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
backdrop-filter: blur(10px);
}
.sessions-section {
grid-column: 1 / -1;
}
/* Section headers */
h2 {
font-size: 1.5rem;
font-weight: 600;
margin-bottom: 20px;
color: #2d3748;
display: flex;
align-items: center;
gap: 10px;
}
/* Form elements */
.input-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 8px;
font-weight: 500;
color: #4a5568;
}
input[type="text"],
textarea {
width: 100%;
padding: 12px 16px;
border: 2px solid #e2e8f0;
border-radius: 8px;
font-size: 1rem;
font-family: inherit;
transition: all 0.3s ease;
background: #f7fafc;
}
input[type="text"]:focus,
textarea:focus {
outline: none;
border-color: #667eea;
background: white;
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
textarea {
resize: vertical;
min-height: 120px;
}
/* Buttons */
.btn {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 12px 24px;
border: none;
border-radius: 8px;
font-size: 1rem;
font-weight: 500;
cursor: pointer;
transition: all 0.3s ease;
text-decoration: none;
font-family: inherit;
}
.btn-primary {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}
.btn-secondary {
background: #48bb78;
color: white;
box-shadow: 0 4px 15px rgba(72, 187, 120, 0.4);
}
.btn-secondary:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(72, 187, 120, 0.6);
}
.btn-outline {
background: transparent;
color: #667eea;
border: 2px solid #667eea;
}
.btn-outline:hover {
background: #667eea;
color: white;
}
/* Results section */
.session-info {
background: #f7fafc;
padding: 20px;
border-radius: 8px;
margin-bottom: 20px;
border-left: 4px solid #667eea;
}
.session-info h3 {
color: #2d3748;
margin-bottom: 5px;
}
.session-info p {
color: #718096;
font-size: 0.9rem;
}
/* Pairs container */
.pairs-container {
display: grid;
gap: 15px;
margin-bottom: 20px;
}
.pair-card {
background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
border: 1px solid #e2e8f0;
border-radius: 12px;
padding: 20px;
display: flex;
align-items: center;
justify-content: space-between;
transition: all 0.3s ease;
}
.pair-card:hover {
transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(0,0,0,0.1);
border-color: #667eea;
}
.pair-info {
display: flex;
align-items: center;
gap: 15px;
flex: 1;
}
.person {
background: white;
padding: 8px 16px;
border-radius: 20px;
font-weight: 500;
color: #2d3748;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.pair-arrow {
color: #667eea;
font-size: 1.2rem;
}
/* Actions */
.actions {
display: flex;
gap: 15px;
flex-wrap: wrap;
}
/* Sessions section */
.sessions-container {
display: grid;
gap: 20px;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}
.session-card {
background: white;
border: 1px solid #e2e8f0;
border-radius: 12px;
padding: 20px;
transition: all 0.3s ease;
cursor: pointer;
}
.session-card:hover {
transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(0,0,0,0.1);
border-color: #667eea;
}
.session-card h3 {
color: #2d3748;
margin-bottom: 10px;
font-size: 1.1rem;
}
.session-card p {
color: #718096;
font-size: 0.9rem;
margin-bottom: 15px;
}
.session-names {
display: flex;
flex-wrap: wrap;
gap: 5px;
margin-bottom: 15px;
}
.name-tag {
background: #edf2f7;
color: #4a5568;
padding: 4px 8px;
border-radius: 12px;
font-size: 0.8rem;
font-weight: 500;
}
.session-pairs {
font-size: 0.9rem;
color: #718096;
}
/* Modals */
.modal {
display: none;
position: fixed;
z-index: 1000;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.5);
backdrop-filter: blur(5px);
}
.modal-content {
background-color: white;
margin: 15% auto;
padding: 30px;
border-radius: 16px;
width: 90%;
max-width: 400px;
text-align: center;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.success-icon {
font-size: 3rem;
color: #48bb78;
margin-bottom: 20px;
}
/* Spinner */
.spinner {
border: 4px solid #f3f3f3;
border-top: 4px solid #667eea;
border-radius: 50%;
width: 40px;
height: 40px;
animation: spin 1s linear infinite;
margin: 0 auto 20px;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
/* Responsive design */
@media (max-width: 768px) {
.container {
padding: 15px;
}
.header h1 {
font-size: 2rem;
}
.input-section,
.results-section,
.sessions-section {
padding: 20px;
}
.actions {
flex-direction: column;
}
.btn {
width: 100%;
justify-content: center;
}
}
/* Loading states */
.loading {
opacity: 0.6;
pointer-events: none;
}
/* Error states */
.error {
border-color: #e53e3e !important;
background-color: #fed7d7 !important;
}
.error-message {
color: #e53e3e;
font-size: 0.9rem;
margin-top: 5px;
}
/* Success states */
.success {
border-color: #48bb78 !important;
background-color: #f0fff4 !important;
}

281
static/js/app.js Normal file
View File

@@ -0,0 +1,281 @@
// Global variables
let currentSession = null;
// DOM elements
const createPairsBtn = document.getElementById('createPairsBtn');
const namesInput = document.getElementById('namesInput');
const sessionNameInput = document.getElementById('sessionName');
const resultsSection = document.getElementById('resultsSection');
const pairsContainer = document.getElementById('pairsContainer');
const sessionTitle = document.getElementById('sessionTitle');
const sessionDate = document.getElementById('sessionDate');
const sessionsContainer = document.getElementById('sessionsContainer');
const loadingModal = document.getElementById('loadingModal');
const successModal = document.getElementById('successModal');
// Event listeners
document.addEventListener('DOMContentLoaded', function() {
loadPreviousSessions();
createPairsBtn.addEventListener('click', createPairs);
// Add event listeners for action buttons
document.addEventListener('click', function(e) {
if (e.target.id === 'newSessionBtn') {
resetForm();
}
});
});
// API functions
async function createPairs() {
const names = namesInput.value.trim();
const sessionName = sessionNameInput.value.trim() || 'Prayer Session';
if (!names) {
showError('Please enter at least one name.');
return;
}
const nameList = names.split('\n')
.map(name => name.trim())
.filter(name => name.length > 0);
if (nameList.length < 3) {
showError('Please enter at least 3 names to create vibes.');
return;
}
showLoading();
try {
const response = await fetch('/create-pairs', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
names: nameList,
session_name: sessionName
})
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.detail || 'Failed to create vibes');
}
const result = await response.json();
currentSession = result;
displayResults(result);
hideLoading();
showSuccess();
loadPreviousSessions(); // Refresh the sessions list
} catch (error) {
hideLoading();
showError(error.message);
}
}
async function loadPreviousSessions() {
try {
const response = await fetch('/sessions');
if (!response.ok) {
throw new Error('Failed to load sessions');
}
const sessions = await response.json();
displaySessions(sessions);
} catch (error) {
console.error('Error loading sessions:', error);
}
}
async function loadSession(sessionId) {
try {
const response = await fetch(`/session/${sessionId}`);
if (!response.ok) {
throw new Error('Failed to load session');
}
const session = await response.json();
currentSession = session;
displayResults(session);
// Scroll to results section
resultsSection.scrollIntoView({ behavior: 'smooth' });
} catch (error) {
showError('Failed to load session');
}
}
// Display functions
function displayResults(session) {
sessionTitle.textContent = session.session_name;
sessionDate.textContent = formatDate(session.created_at);
// Clear previous pairs
pairsContainer.innerHTML = '';
// Display pairs
session.pairs.forEach(pair => {
const pairCard = document.createElement('div');
pairCard.className = 'pair-card';
pairCard.innerHTML = `
<div class="pair-info">
<span class="person">${pair.person1}</span>
<i class="fas fa-arrow-right pair-arrow"></i>
<span class="person">${pair.person2}</span>
</div>
`;
pairsContainer.appendChild(pairCard);
});
// Show results section
resultsSection.style.display = 'block';
// Scroll to results
resultsSection.scrollIntoView({ behavior: 'smooth' });
}
function displaySessions(sessions) {
sessionsContainer.innerHTML = '';
if (sessions.length === 0) {
sessionsContainer.innerHTML = '<p style="color: #718096; text-align: center;">No previous sessions found.</p>';
return;
}
sessions.forEach(session => {
const sessionCard = document.createElement('div');
sessionCard.className = 'session-card';
sessionCard.onclick = () => loadSession(session.id);
const namesHtml = session.names.map(name =>
`<span class="name-tag">${name}</span>`
).join('');
sessionCard.innerHTML = `
<h3>${session.session_name}</h3>
<p>Created: ${formatDate(session.created_at)}</p>
<div class="session-names">
${namesHtml}
</div>
<div class="session-pairs">
${session.pairs.length} prayer vibes created
</div>
`;
sessionsContainer.appendChild(sessionCard);
});
}
// Utility functions
function formatDate(dateString) {
const date = new Date(dateString);
return date.toLocaleDateString('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric',
hour: '2-digit',
minute: '2-digit'
});
}
function showLoading() {
loadingModal.style.display = 'block';
createPairsBtn.classList.add('loading');
}
function hideLoading() {
loadingModal.style.display = 'none';
createPairsBtn.classList.remove('loading');
}
function showSuccess() {
successModal.style.display = 'block';
setTimeout(() => {
hideSuccess();
}, 3000);
}
function hideSuccess() {
successModal.style.display = 'none';
}
function closeModal(modalId) {
document.getElementById(modalId).style.display = 'none';
}
function showError(message) {
// Remove any existing error messages
const existingError = document.querySelector('.error-message');
if (existingError) {
existingError.remove();
}
// Create error message
const errorDiv = document.createElement('div');
errorDiv.className = 'error-message';
errorDiv.textContent = message;
// Add error styling to input
namesInput.classList.add('error');
// Insert error message after the textarea
namesInput.parentNode.insertBefore(errorDiv, namesInput.nextSibling);
// Remove error styling after 3 seconds
setTimeout(() => {
namesInput.classList.remove('error');
if (errorDiv.parentNode) {
errorDiv.remove();
}
}, 3000);
}
function resetForm() {
namesInput.value = '';
sessionNameInput.value = 'Prayer Session';
resultsSection.style.display = 'none';
currentSession = null;
// Remove any error states
namesInput.classList.remove('error');
const errorMessage = document.querySelector('.error-message');
if (errorMessage) {
errorMessage.remove();
}
// Scroll to top
window.scrollTo({ top: 0, behavior: 'smooth' });
}
// Close modals when clicking outside
window.onclick = function(event) {
if (event.target.classList.contains('modal')) {
event.target.style.display = 'none';
}
}
// Keyboard shortcuts
document.addEventListener('keydown', function(e) {
// Ctrl/Cmd + Enter to create vibes
if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') {
e.preventDefault();
createPairs();
}
// Escape to close modals
if (e.key === 'Escape') {
const modals = document.querySelectorAll('.modal');
modals.forEach(modal => {
if (modal.style.display === 'block') {
modal.style.display = 'none';
}
});
}
});