@stfrigerio/sito-template 0.1.19 → 0.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1957,6 +1957,23 @@ function Calendar({ events, onEventClick, onDateClick, viewMode = 'month', initi
1957
1957
  }
1958
1958
  return '#4A90E2'; // Default blue
1959
1959
  };
1960
+ const getContrastColor = (bgColor) => {
1961
+ // Convert hex to RGB
1962
+ const hex = bgColor.replace('#', '');
1963
+ const r = parseInt(hex.substring(0, 2), 16);
1964
+ const g = parseInt(hex.substring(2, 4), 16);
1965
+ const b = parseInt(hex.substring(4, 6), 16);
1966
+ // Calculate luminance
1967
+ const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
1968
+ // Return black or white based on luminance
1969
+ return luminance > 0.5 ? '#000000' : '#FFFFFF';
1970
+ };
1971
+ const getEventTextColor = (event) => {
1972
+ if (event.textColor)
1973
+ return event.textColor;
1974
+ const bgColor = getEventColor(event);
1975
+ return getContrastColor(bgColor);
1976
+ };
1960
1977
  const handleEventClick = (event) => {
1961
1978
  if (onEventClick) {
1962
1979
  onEventClick(event);
@@ -2003,6 +2020,7 @@ function Calendar({ events, onEventClick, onDateClick, viewMode = 'month', initi
2003
2020
  });
2004
2021
  return (jsxRuntime.jsxs("div", { className: styles$7.hourSlot, children: [jsxRuntime.jsx("div", { className: styles$7.hourLine }), hourEvents.map((event, eventIndex) => (jsxRuntime.jsxs(framerMotion.motion.div, { className: `${styles$7.dayEvent} ${event.status === 'completed' ? styles$7.completed : ''}`, style: {
2005
2022
  backgroundColor: getEventColor(event),
2023
+ color: getEventTextColor(event),
2006
2024
  opacity: event.status === 'completed' ? 0.7 : 1
2007
2025
  }, onClick: (e) => {
2008
2026
  e.stopPropagation();
@@ -2030,6 +2048,7 @@ function Calendar({ events, onEventClick, onDateClick, viewMode = 'month', initi
2030
2048
  ease: "easeOut"
2031
2049
  }, onClick: () => handleDateClick(day), children: [isWeekStart && (jsxRuntime.jsx("div", { className: styles$7.weekNumber, children: getWeekNumber(day) })), jsxRuntime.jsx("div", { className: styles$7.dayNumber, children: day.getDate() }), dayEvents.length > 0 && (jsxRuntime.jsxs("div", { className: styles$7.events, children: [dayEvents.slice(0, maxEventsPerDay).map((event, eventIndex) => (jsxRuntime.jsxs(framerMotion.motion.div, { className: `${styles$7.event} ${event.status === 'completed' ? styles$7.completed : ''}`, style: {
2032
2050
  backgroundColor: getEventColor(event),
2051
+ color: getEventTextColor(event),
2033
2052
  opacity: event.status === 'completed' ? 0.7 : 1
2034
2053
  }, onClick: (e) => {
2035
2054
  e.stopPropagation();