@forcecalendar/interface 1.0.47 → 1.0.49
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/package.json
CHANGED
|
@@ -115,40 +115,16 @@ export class BaseViewRenderer {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
/**
|
|
118
|
-
* Get contrasting text color for a background color
|
|
119
|
-
*
|
|
118
|
+
* Get contrasting text color for a background color.
|
|
119
|
+
* Delegates to StyleUtils.getContrastColor() as the single implementation.
|
|
120
120
|
* @param {string} bgColor - Hex color string
|
|
121
|
-
* @returns {string} '
|
|
121
|
+
* @returns {string} '#000000' or '#FFFFFF'
|
|
122
122
|
*/
|
|
123
123
|
getContrastingTextColor(bgColor) {
|
|
124
|
-
if (!bgColor || typeof bgColor !== 'string')
|
|
125
|
-
|
|
126
|
-
const color = bgColor.charAt(0) === '#' ? bgColor.substring(1) : bgColor;
|
|
127
|
-
|
|
128
|
-
if (!/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(color)) {
|
|
129
|
-
return 'white';
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const fullColor =
|
|
133
|
-
color.length === 3 ? color[0] + color[0] + color[1] + color[1] + color[2] + color[2] : color;
|
|
134
|
-
|
|
135
|
-
const r = parseInt(fullColor.substring(0, 2), 16);
|
|
136
|
-
const g = parseInt(fullColor.substring(2, 4), 16);
|
|
137
|
-
const b = parseInt(fullColor.substring(4, 6), 16);
|
|
138
|
-
|
|
139
|
-
if (isNaN(r) || isNaN(g) || isNaN(b)) {
|
|
124
|
+
if (!bgColor || typeof bgColor !== 'string' || bgColor.charAt(0) !== '#') {
|
|
140
125
|
return 'white';
|
|
141
126
|
}
|
|
142
|
-
|
|
143
|
-
const uicolors = [r / 255, g / 255, b / 255];
|
|
144
|
-
const c = uicolors.map(col => {
|
|
145
|
-
if (col <= 0.03928) {
|
|
146
|
-
return col / 12.92;
|
|
147
|
-
}
|
|
148
|
-
return Math.pow((col + 0.055) / 1.055, 2.4);
|
|
149
|
-
});
|
|
150
|
-
const L = 0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2];
|
|
151
|
-
return L > 0.179 ? 'black' : 'white';
|
|
127
|
+
return StyleUtils.getContrastColor(bgColor);
|
|
152
128
|
}
|
|
153
129
|
|
|
154
130
|
/**
|
|
@@ -246,6 +222,7 @@ export class BaseViewRenderer {
|
|
|
246
222
|
const startMinutes = start.getHours() * 60 + start.getMinutes();
|
|
247
223
|
const durationMinutes = Math.max((end - start) / (1000 * 60), compact ? 20 : 30);
|
|
248
224
|
const color = this.getEventColor(event);
|
|
225
|
+
const textColor = this.getContrastingTextColor(color);
|
|
249
226
|
|
|
250
227
|
const padding = compact ? '4px 8px' : '8px 12px';
|
|
251
228
|
const fontSize = compact ? '11px' : '13px';
|
|
@@ -271,7 +248,7 @@ export class BaseViewRenderer {
|
|
|
271
248
|
left: ${leftPx}; width: ${widthCalc};
|
|
272
249
|
background-color: ${color}; border-radius: ${borderRadius};
|
|
273
250
|
padding: ${padding}; font-size: ${fontSize};
|
|
274
|
-
font-weight: 500; color:
|
|
251
|
+
font-weight: 500; color: ${textColor}; overflow: hidden;
|
|
275
252
|
box-shadow: 0 1px 2px rgba(0,0,0,0.1);
|
|
276
253
|
cursor: pointer; z-index: 5;">
|
|
277
254
|
<div style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
|