feat: 12.0 - Frontend - Habit card styling
This commit is contained in:
@@ -87,7 +87,7 @@
|
||||
.habit-card {
|
||||
background: var(--bg-surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-md);
|
||||
border-radius: var(--radius-lg);
|
||||
padding: var(--space-4);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -100,6 +100,10 @@
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.habit-card.checked {
|
||||
background: rgba(34, 197, 94, 0.1);
|
||||
}
|
||||
|
||||
.habit-icon {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
@@ -129,8 +133,13 @@
|
||||
}
|
||||
|
||||
.habit-frequency {
|
||||
display: inline-block;
|
||||
font-size: var(--text-xs);
|
||||
color: var(--text-muted);
|
||||
color: var(--text-secondary);
|
||||
background: var(--bg-elevated);
|
||||
border: 1px solid var(--border);
|
||||
padding: 2px 8px;
|
||||
border-radius: var(--radius-sm);
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
@@ -138,7 +147,7 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
font-size: var(--text-lg);
|
||||
font-size: var(--text-xl);
|
||||
font-weight: 600;
|
||||
color: var(--accent);
|
||||
flex-shrink: 0;
|
||||
@@ -162,6 +171,12 @@
|
||||
.habit-checkbox:hover:not(.disabled) {
|
||||
border-color: var(--accent);
|
||||
background: var(--accent-light, rgba(99, 102, 241, 0.1));
|
||||
animation: pulse 1.5s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0%, 100% { transform: scale(1); }
|
||||
50% { transform: scale(1.05); }
|
||||
}
|
||||
|
||||
.habit-checkbox.checked {
|
||||
@@ -343,6 +358,41 @@
|
||||
transform: translateX(-50%) translateY(0);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
/* Mobile responsiveness */
|
||||
@media (max-width: 768px) {
|
||||
.main {
|
||||
padding: var(--space-3);
|
||||
}
|
||||
|
||||
.habit-card {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.habits-list {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.habit-icon {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
}
|
||||
|
||||
.habit-icon svg {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
.habit-checkbox {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
}
|
||||
|
||||
.habit-checkbox svg {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -627,13 +677,13 @@
|
||||
// Create habit card element
|
||||
function createHabitCard(habit) {
|
||||
const card = document.createElement('div');
|
||||
card.className = 'habit-card';
|
||||
const isChecked = habit.checkedToday || false;
|
||||
card.className = isChecked ? 'habit-card checked' : 'habit-card';
|
||||
|
||||
// Determine icon based on frequency
|
||||
const iconName = habit.frequency === 'daily' ? 'calendar' : 'clock';
|
||||
|
||||
// Checkbox state
|
||||
const isChecked = habit.checkedToday || false;
|
||||
const checkboxClass = isChecked ? 'habit-checkbox checked disabled' : 'habit-checkbox';
|
||||
const checkIcon = isChecked ? '<i data-lucide="check"></i>' : '';
|
||||
|
||||
@@ -677,6 +727,12 @@
|
||||
checkboxElement.innerHTML = '<i data-lucide="check"></i>';
|
||||
lucide.createIcons();
|
||||
|
||||
// Add 'checked' class to parent card for green background
|
||||
const card = checkboxElement.closest('.habit-card');
|
||||
if (card) {
|
||||
card.classList.add('checked');
|
||||
}
|
||||
|
||||
// Store original state for rollback
|
||||
const originalCheckbox = checkboxElement.cloneNode(true);
|
||||
const streakElement = document.getElementById(`streak-${habitId}`);
|
||||
@@ -708,6 +764,12 @@
|
||||
checkboxElement.classList.remove('checked', 'disabled');
|
||||
checkboxElement.innerHTML = '';
|
||||
|
||||
// Revert card background
|
||||
const card = checkboxElement.closest('.habit-card');
|
||||
if (card) {
|
||||
card.classList.remove('checked');
|
||||
}
|
||||
|
||||
// Revert streak
|
||||
if (streakElement) {
|
||||
streakElement.textContent = originalStreak;
|
||||
|
||||
Reference in New Issue
Block a user