Add card color system with wrapCard helper and reset support
Introduce localStorage-backed card color assignment for all card types with a reusable wrapCard() helper that provides consistent card shell structure (top actions, bottom actions with color picker). Move color picker from top-right to bottom-right action bar. Add color reset button to clear card color back to default. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,7 @@ import { Modal } from '../core/modal.js';
|
||||
import { CardSection } from '../core/card-sections.js';
|
||||
import { updateTabBadge } from './tabs.js';
|
||||
import { ICON_SETTINGS, ICON_START, ICON_PAUSE, ICON_CLOCK, ICON_AUTOMATION, ICON_HELP, ICON_OK, ICON_TIMER, ICON_MONITOR, ICON_RADIO, ICON_SCENE } from '../core/icons.js';
|
||||
import { wrapCard } from '../core/card-colors.js';
|
||||
import { csScenes, createSceneCard } from './scene-presets.js';
|
||||
|
||||
class AutomationEditorModal extends Modal {
|
||||
@@ -152,11 +153,13 @@ function createAutomationCard(automation, sceneMap = new Map()) {
|
||||
lastActivityMeta = `<span class="card-meta" title="${t('automations.last_activated')}">${ICON_CLOCK} ${ts.toLocaleString()}</span>`;
|
||||
}
|
||||
|
||||
return `
|
||||
<div class="card${!automation.enabled ? ' automation-status-disabled' : ''}" data-automation-id="${automation.id}">
|
||||
<div class="card-top-actions">
|
||||
<button class="card-remove-btn" onclick="deleteAutomation('${automation.id}', '${escapeHtml(automation.name)}')" title="${t('common.delete')}">✕</button>
|
||||
</div>
|
||||
return wrapCard({
|
||||
dataAttr: 'data-automation-id',
|
||||
id: automation.id,
|
||||
classes: !automation.enabled ? 'automation-status-disabled' : '',
|
||||
removeOnclick: `deleteAutomation('${automation.id}', '${escapeHtml(automation.name)}')`,
|
||||
removeTitle: t('common.delete'),
|
||||
content: `
|
||||
<div class="card-header">
|
||||
<div class="card-title">
|
||||
${escapeHtml(automation.name)}
|
||||
@@ -169,14 +172,13 @@ function createAutomationCard(automation, sceneMap = new Map()) {
|
||||
${deactivationLabel ? `<span class="card-meta">${deactivationLabel}</span>` : ''}
|
||||
${lastActivityMeta}
|
||||
</div>
|
||||
<div class="stream-card-props">${condPills}</div>
|
||||
<div class="card-actions">
|
||||
<div class="stream-card-props">${condPills}</div>`,
|
||||
actions: `
|
||||
<button class="btn btn-icon btn-secondary" onclick="openAutomationEditor('${automation.id}')" title="${t('automations.edit')}">${ICON_SETTINGS}</button>
|
||||
<button class="btn btn-icon ${automation.enabled ? 'btn-warning' : 'btn-success'}" onclick="toggleAutomationEnabled('${automation.id}', ${!automation.enabled})" title="${automation.enabled ? t('automations.action.disable') : t('automations.status.active')}">
|
||||
${automation.enabled ? ICON_PAUSE : ICON_START}
|
||||
</button>
|
||||
</div>
|
||||
</div>`;
|
||||
</button>`,
|
||||
});
|
||||
}
|
||||
|
||||
export async function openAutomationEditor(automationId) {
|
||||
|
||||
Reference in New Issue
Block a user