fix: use per-day-of-week colors in PDF export (weekday/sat/sun)
The PDF was showing all day headers in the same weekdayColor. The webapp uses three separate color settings: weekdayColor (Mon–Fri), weekendColorSat, and weekendColorSun. Fetch both weekend colors from DB and apply via dayColor() helper based on d.getDay(). v1.95.1
This commit is contained in:
parent
f75bd6ebe5
commit
72c51c2bea
@ -169,11 +169,21 @@ type WeatherDay = { maxTemp: number | null; code: number | null; };
|
|||||||
// User-specific style settings passed to the PDF
|
// User-specific style settings passed to the PDF
|
||||||
type UserStyle = {
|
type UserStyle = {
|
||||||
weekdayColor: string; // e.g. "#0ea5e9"
|
weekdayColor: string; // e.g. "#0ea5e9"
|
||||||
|
weekendColorSat: string; // e.g. "#ffc107"
|
||||||
|
weekendColorSun: string; // e.g. "#dc2626"
|
||||||
dateColor: string; // e.g. "#888888"
|
dateColor: string; // e.g. "#888888"
|
||||||
headlineFontWeight: string; // e.g. "900"
|
headlineFontWeight: string; // e.g. "900"
|
||||||
useOswald: boolean; // whether Oswald was successfully registered
|
useOswald: boolean; // whether Oswald was successfully registered
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function dayColor(d: Date, isToday: boolean, us: UserStyle): string {
|
||||||
|
if (isToday) return '#6366f1';
|
||||||
|
const dow = d.getDay();
|
||||||
|
if (dow === 6) return us.weekendColorSat;
|
||||||
|
if (dow === 0) return us.weekendColorSun;
|
||||||
|
return us.weekdayColor;
|
||||||
|
}
|
||||||
|
|
||||||
// ── PDF Document ──────────────────────────────────────────────────────────────
|
// ── PDF Document ──────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
function WeekCalendarPDF({
|
function WeekCalendarPDF({
|
||||||
@ -388,7 +398,7 @@ function WeekCalendarPDF({
|
|||||||
fontFamily: headlineFontFamily,
|
fontFamily: headlineFontFamily,
|
||||||
fontWeight: headlineFW,
|
fontWeight: headlineFW,
|
||||||
fontSize: dayNameSize,
|
fontSize: dayNameSize,
|
||||||
color: isToday ? '#6366f1' : userStyle.weekdayColor,
|
color: dayColor(d, isToday, userStyle),
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
letterSpacing: 0.5,
|
letterSpacing: 0.5,
|
||||||
lineHeight: 1.1,
|
lineHeight: 1.1,
|
||||||
@ -397,7 +407,7 @@ function WeekCalendarPDF({
|
|||||||
React.createElement(Text, {
|
React.createElement(Text, {
|
||||||
style: {
|
style: {
|
||||||
fontSize: 7.5,
|
fontSize: 7.5,
|
||||||
color: isToday ? '#6366f1' : userStyle.dateColor,
|
color: dayColor(d, isToday, userStyle),
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
marginTop: 2,
|
marginTop: 2,
|
||||||
fontFamily: 'Helvetica',
|
fontFamily: 'Helvetica',
|
||||||
@ -623,8 +633,8 @@ export async function GET(request: Request) {
|
|||||||
select: {
|
select: {
|
||||||
id: true, name: true, email: true,
|
id: true, name: true, email: true,
|
||||||
timezone: true,
|
timezone: true,
|
||||||
weekdayColor: true, dateColor: true,
|
weekdayColor: true, weekendColorSat: true, weekendColorSun: true,
|
||||||
headlineFontWeight: true,
|
dateColor: true, headlineFontWeight: true,
|
||||||
weatherLat: true, weatherLon: true,
|
weatherLat: true, weatherLon: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -638,6 +648,8 @@ export async function GET(request: Request) {
|
|||||||
|
|
||||||
const userStyle: UserStyle = {
|
const userStyle: UserStyle = {
|
||||||
weekdayColor: (user as any).weekdayColor || '#0ea5e9',
|
weekdayColor: (user as any).weekdayColor || '#0ea5e9',
|
||||||
|
weekendColorSat: (user as any).weekendColorSat || '#ffc107',
|
||||||
|
weekendColorSun: (user as any).weekendColorSun || '#dc2626',
|
||||||
dateColor: (user as any).dateColor || '#888888',
|
dateColor: (user as any).dateColor || '#888888',
|
||||||
headlineFontWeight: (user as any).headlineFontWeight || '900',
|
headlineFontWeight: (user as any).headlineFontWeight || '900',
|
||||||
useOswald: oswaldAvailable,
|
useOswald: oswaldAvailable,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user