diff --git a/frontend/print-preview.css b/frontend/print-preview.css index 59932a9..2a3e6a1 100644 --- a/frontend/print-preview.css +++ b/frontend/print-preview.css @@ -315,27 +315,51 @@ overflow: visible !important; } -/* Scale time slots appropriately in preview */ +/* Dynamic time slot heights based on calculated base unit */ .print-preview-paper .time-slot { - height: 60px !important; /* Default for 30-minute mode: 2 × 30px = 60px */ - min-height: 60px !important; - max-height: 60px !important; + height: calc(var(--print-pixels-per-hour) * 1px) !important; + min-height: calc(var(--print-pixels-per-hour) * 1px) !important; + max-height: calc(var(--print-pixels-per-hour) * 1px) !important; border-bottom: 1px solid #ddd !important; overflow: visible !important; } -/* 15-minute mode (quarter-mode) gets more height */ -.print-preview-paper .time-slot.quarter-mode { - height: 120px !important; /* 15-minute mode: 4 slots × 30px = 120px */ - min-height: 120px !important; - max-height: 120px !important; +/* Dynamic time label heights - should match time slots */ +.print-preview-paper .time-label { + height: calc(var(--print-pixels-per-hour) * 1px) !important; + min-height: calc(var(--print-pixels-per-hour) * 1px) !important; + max-height: calc(var(--print-pixels-per-hour) * 1px) !important; } -/* Sub-hour time slot styling */ +/* Fixed week header height for print - smaller to maximize content */ +.print-preview-paper .week-day-header { + height: 50px !important; + min-height: 50px !important; + max-height: 50px !important; + padding: 0.25rem !important; /* Reduce padding to fit content */ +} + +.print-preview-paper .weekday-name { + font-size: 0.75rem !important; /* Slightly smaller font */ + margin-bottom: 0.125rem !important; +} + +.print-preview-paper .week-day-header .day-number { + font-size: 1.25rem !important; /* Slightly smaller day number */ +} + +/* 15-minute and 30-minute modes use the same calculated height */ +.print-preview-paper .time-slot.quarter-mode { + height: calc(var(--print-pixels-per-hour) * 1px) !important; + min-height: calc(var(--print-pixels-per-hour) * 1px) !important; + max-height: calc(var(--print-pixels-per-hour) * 1px) !important; +} + +/* Sub-hour time slot styling - use dynamic base unit */ .print-preview-paper .time-slot-half { - height: 30px !important; - min-height: 30px !important; - max-height: 30px !important; + height: calc(var(--print-base-unit) * 1px) !important; + min-height: calc(var(--print-base-unit) * 1px) !important; + max-height: calc(var(--print-base-unit) * 1px) !important; border-bottom: 1px dotted #ddd !important; overflow: visible !important; } @@ -345,9 +369,9 @@ } .print-preview-paper .time-slot-quarter { - height: 30px !important; - min-height: 30px !important; - max-height: 30px !important; + height: calc(var(--print-base-unit) * 1px) !important; + min-height: calc(var(--print-base-unit) * 1px) !important; + max-height: calc(var(--print-base-unit) * 1px) !important; border-bottom: 1px dotted #eee !important; overflow: visible !important; } @@ -356,23 +380,7 @@ border-bottom: none !important; } -/* Debug: Test if data attributes are working at all */ -.print-preview-paper .time-slot[data-hour] { - border-left: 3px solid blue !important; -} - -.print-preview-paper .time-label[data-hour] { - background-color: yellow !important; -} - -/* Test specific hour targeting */ -.print-preview-paper .time-slot[data-hour="0"] { - border-left: 3px solid red !important; -} - -.print-preview-paper .time-label[data-hour="0"] { - background-color: red !important; -} +/* Debug styles removed */ /* Use data attributes for precise hour targeting */ /* Hide hours before start hour - both time slots AND time labels */ @@ -1089,7 +1097,6 @@ .print-preview-paper[data-start-hour][data-end-hour] .time-grid, .print-preview-paper[data-start-hour][data-end-hour] .week-day-column { min-height: 400px !important; - border: 2px solid red !important; /* Debug border to see if this rule applies */ } /* Height adjustments based on visible hours = end_hour - start_hour */ diff --git a/frontend/src/components/print_preview_modal.rs b/frontend/src/components/print_preview_modal.rs index 23c921f..64b8dba 100644 --- a/frontend/src/components/print_preview_modal.rs +++ b/frontend/src/components/print_preview_modal.rs @@ -122,6 +122,24 @@ pub fn PrintPreviewModal(props: &PrintPreviewModalProps) -> Html { } }; + // Calculate dynamic base unit for print preview + let calculate_print_dimensions = |start_hour: u32, end_hour: u32, time_increment: u32| -> (f64, f64, f64) { + let visible_hours = (end_hour - start_hour) as f64; + let slots_per_hour = if time_increment == 15 { 4.0 } else { 2.0 }; + let header_height = 50.0; // Fixed week header height in print preview + let header_border = 2.0; // Week header bottom border (2px solid) + let container_spacing = 8.0; // Additional container spacing/margins + let total_overhead = header_height + header_border + container_spacing; + let available_height = 720.0 - total_overhead; // Available for time content + let base_unit = available_height / (visible_hours * slots_per_hour); + let pixels_per_hour = base_unit * slots_per_hour; + + (base_unit, pixels_per_hour, available_height) + }; + + // Calculate print dimensions for the current hour range + let (base_unit, pixels_per_hour, _available_height) = calculate_print_dimensions(*start_hour, *end_hour, props.time_increment); + html! {