callumalpass_tasknotes/build-css.mjs
Callum Alpass b4fe29068b Refactor and consolidate modal implementation, update naming and imports, and adjust styles and tests
• Remove the legacy “MinimalistTaskModal” base class and its derivatives (MinimalistTaskCreationModal and MinimalistTaskEditModal) by renaming and consolidating them into new classes:
  – Rename MinimalistTaskModal to TaskModal
  – Rename MinimalistTaskCreationModal → TaskCreationModal
  – Rename MinimalistTaskEditModal → TaskEditModal
• Update all references and imports across the project (including AdvancedCalendarView) to use the new TaskModal, TaskCreationModal, and TaskEditModal classes instead of the old minimalist versions.
• Extract and expose a new TaskConversionOptions type (in src/types/taskConversion.ts) to provide a consistent interface for passing conversion-related options.
• Adjust the modal logic:
  – In TaskCreationModal, update natural language parsing, pre-populated values, and form handling using the new base TaskModal APIs.
  – In TaskEditModal, change the constructor signature to accept an options object (including “task” and an optional “onTaskUpdated” callback) and update recurrence handling to convert legacy recurrence objects into display strings.
• Update CSS:
  – Rename styles/minimalist-modal.css to styles/task-modal.css and update class comments (e.g. “MINIMALIST TASK MODAL” → “TASK MODAL – Google Keep/Todoist Inspired”).
  – Modify selectors in modal-bem.css by removing references to “.task-creation-modal” and “.task-edit-modal” in some cases, as these are now included under the unified “tasknotes-plugin” context.
• Remove the tests for BaseTaskModal (tests/unit/modals/BaseTaskModal.test.ts) since that base class is no longer used, and update test references for the new TaskCreationModal class.
• Overall, this commit streamlines the modal codebase and unifies the naming and styling of task-related modals while updating the type definitions and downstream usage in views and tests.

These changes are backward‐compatible with previous plugin settings (aside from renamed classes/interfaces) but may require updates in any custom integrations relying on the old MinimalistTask* modals.
2025-06-27 21:45:08 +10:00

113 lines
No EOL
5 KiB
JavaScript

import { readFileSync, writeFileSync } from 'fs';
import { join } from 'path';
const CSS_FILES = [
// Core System Files
'styles/variables.css', // CSS custom properties and design system variables
'styles/utilities.css', // Scoped utility classes for layout, spacing, typography
'styles/base.css', // Basic styles, animations, card components, and layout
// BEM Component Files
'styles/task-card-bem.css', // TaskCard component with proper BEM scoping
'styles/task-inline-widget.css', // Inline task widget for editor with proper BEM scoping
'styles/note-card-bem.css', // NoteCard component with proper BEM scoping
'styles/filter-bar-bem.css', // FilterBar component with proper BEM scoping
'styles/modal-bem.css', // Modal components with proper BEM scoping
'styles/task-modal.css', // Task modal components (Google Keep/Todoist style)
'styles/date-picker.css', // Enhanced date/time picker styling
'styles/task-selector-modal.css', // TaskSelectorModal component with proper BEM scoping
'styles/unscheduled-tasks-selector-modal.css', // UnscheduledTasksSelectorModal component with proper BEM scoping
'styles/task-action-palette-modal.css', // TaskActionPaletteModal component with proper BEM scoping
// BEM View Files
'styles/task-list-view.css', // TaskListView component with proper BEM scoping
'styles/calendar-view.css', // CalendarView component with proper BEM scoping
'styles/advanced-calendar-view.css', // AdvancedCalendarView component with proper BEM scoping
'styles/kanban-view.css', // KanbanView component with proper BEM scoping
'styles/agenda-view.css', // AgendaView component with proper BEM scoping
'styles/notes-view.css', // NotesView component with proper BEM scoping
'styles/pomodoro-view.css', // PomodoroView component with proper BEM scoping
'styles/pomodoro-stats-view.css', // PomodoroStatsView component with proper BEM scoping
'styles/settings-view.css' // SettingsView component with proper BEM scoping
];
const MAIN_CSS_TEMPLATE = `/* TaskNotes Plugin Styles */
/*
This file is automatically generated by the build process.
To modify styles, edit the source files in the styles/ directory.
Source files:
Core System:
- styles/variables.css: CSS custom properties and design system variables
- styles/utilities.css: Scoped utility classes for layout, spacing, typography, and states
- styles/base.css: Basic styles, animations, card components, and layout
BEM Component Files:
- styles/task-card-bem.css: TaskCard component with proper BEM scoping
- styles/task-inline-widget.css: Inline task widget for editor with proper BEM scoping
- styles/note-card-bem.css: NoteCard component with proper BEM scoping
- styles/filter-bar-bem.css: FilterBar component with proper BEM scoping
- styles/modal-bem.css: Modal components with proper BEM scoping
BEM View Files:
- styles/task-list-view.css: TaskListView component with proper BEM scoping
- styles/calendar-view.css: CalendarView component with proper BEM scoping
- styles/kanban-view.css: KanbanView component with proper BEM scoping
- styles/agenda-view.css: AgendaView component with proper BEM scoping
- styles/notes-view.css: NotesView component with proper BEM scoping
- styles/pomodoro-view.css: PomodoroView component with proper BEM scoping
- styles/pomodoro-stats-view.css: PomodoroStatsView component with proper BEM scoping
- styles/settings-view.css: SettingsView component with proper BEM scoping
Run 'npm run build-css' to regenerate this file.
*/
`;
const REMAINING_STYLES = ``;
function buildCSS() {
console.log('Building CSS...');
let combinedCSS = MAIN_CSS_TEMPLATE;
// Read and concatenate each CSS file
for (const cssFile of CSS_FILES) {
try {
const content = readFileSync(cssFile, 'utf8');
// Add a section header comment
const filename = cssFile.split('/').pop();
combinedCSS += `\n/* ===== ${filename.toUpperCase()} ===== */\n`;
combinedCSS += content;
combinedCSS += '\n';
console.log(`[OK] Included ${cssFile}`);
} catch (error) {
console.error(`[ERROR] Error reading ${cssFile}:`, error.message);
process.exit(1);
}
}
// Add the remaining modal styles
combinedCSS += REMAINING_STYLES;
// Write the combined CSS to styles.css
try {
writeFileSync('styles.css', combinedCSS);
console.log('[OK] Built styles.css successfully');
// Count lines for reference
const lineCount = combinedCSS.split('\n').length;
console.log(`[OK] Generated ${lineCount} lines of CSS`);
} catch (error) {
console.error('[ERROR] Error writing styles.css:', error.message);
process.exit(1);
}
}
// Run the build
buildCSS();