Adds dynamic CSS grid column management

Updates ConfigManager to dynamically set CSS grid columns based on work week settings

Ensures the grid layout accurately reflects the number of visible days in the calendar view
Automatically updates grid columns when work week configuration changes

Improves responsive design and layout flexibility
This commit is contained in:
Janus C. H. Knudsen 2025-11-03 22:52:48 +01:00
parent 989c9bd69d
commit d3f4667b61
3 changed files with 18 additions and 3 deletions

View file

@ -5,8 +5,17 @@ import { TimeFormatter } from '../utils/TimeFormatter';
/** /**
* ConfigManager - Static configuration loader * ConfigManager - Static configuration loader
* Loads JSON and creates Configuration instance * Loads JSON and creates Configuration instance
* Also manages CSS custom properties for dynamic styling
*/ */
export class ConfigManager { export class ConfigManager {
/**
* Update CSS custom property for grid columns
* This ensures the CSS grid matches the number of visible columns
*/
static updateGridColumns(weekDays: number): void {
document.documentElement.style.setProperty('--grid-columns', weekDays.toString());
}
/** /**
* Load configuration from JSON and create Configuration instance * Load configuration from JSON and create Configuration instance
*/ */
@ -50,6 +59,10 @@ export class ConfigManager {
// Configure TimeFormatter // Configure TimeFormatter
TimeFormatter.configure(config.timeFormatConfig); TimeFormatter.configure(config.timeFormatConfig);
// Set initial CSS grid columns based on the current work week preset
const workWeekSettings = config.getWorkWeekSettings();
ConfigManager.updateGridColumns(workWeekSettings.totalDays);
return config; return config;
} }
} }

View file

@ -115,10 +115,8 @@ export class CalendarManager {
private setupEventListeners(): void { private setupEventListeners(): void {
// Listen for workweek changes only // Listen for workweek changes only
this.eventBus.on(CoreEvents.WORKWEEK_CHANGED, (event: Event) => { this.eventBus.on(CoreEvents.WORKWEEK_CHANGED, (event: Event) => {
const customEvent = event as CustomEvent; const customEvent = event as CustomEvent;
// this.handleWorkweekChange(); this.handleWorkweekChange();
}); });
} }

View file

@ -1,5 +1,6 @@
import { CalendarView, IEventBus } from '../types/CalendarTypes'; import { CalendarView, IEventBus } from '../types/CalendarTypes';
import { Configuration } from '../configurations/CalendarConfig'; import { Configuration } from '../configurations/CalendarConfig';
import { ConfigManager } from '../configurations/ConfigManager';
import { CoreEvents } from '../constants/CoreEvents'; import { CoreEvents } from '../constants/CoreEvents';
@ -95,6 +96,9 @@ export class ViewManager {
this.config.setWorkWeek(workweekId); this.config.setWorkWeek(workweekId);
// Update CSS grid columns to match new week days count
ConfigManager.updateGridColumns(this.config.dateViewSettings.weekDays);
this.updateAllButtons(); this.updateAllButtons();
const settings = this.config.getWorkWeekSettings(); const settings = this.config.getWorkWeekSettings();