sprintify-ui 0.12.21 → 0.12.23
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/sprintify-ui.es.js +769 -764
- package/package.json +1 -1
- package/src/utils/colors.ts +19 -14
package/package.json
CHANGED
package/src/utils/colors.ts
CHANGED
|
@@ -211,7 +211,7 @@ const colorNames = {
|
|
|
211
211
|
} as Record<string, string>;
|
|
212
212
|
|
|
213
213
|
export function getColorConfig(color: string, contrast = false): ColorConfig {
|
|
214
|
-
|
|
214
|
+
const originalColor = color;
|
|
215
215
|
color = colorNames[color] || color;
|
|
216
216
|
|
|
217
217
|
const colorConfig = palette[color]?.[contrast ? 'high' : 'low'];
|
|
@@ -220,20 +220,25 @@ export function getColorConfig(color: string, contrast = false): ColorConfig {
|
|
|
220
220
|
return colorConfig;
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
-
|
|
223
|
+
try {
|
|
224
|
+
const c = getContrast(color, 'white');
|
|
224
225
|
|
|
225
|
-
|
|
226
|
-
|
|
226
|
+
let borderColor = 'transparent';
|
|
227
|
+
let textColor = 'white';
|
|
227
228
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
229
|
+
if (c < 2) {
|
|
230
|
+
textColor = darken(color, 0.5);
|
|
231
|
+
borderColor = darken(color, 0.1);
|
|
232
|
+
}
|
|
232
233
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
234
|
+
return {
|
|
235
|
+
backgroundColor: color,
|
|
236
|
+
textColor: textColor,
|
|
237
|
+
borderColor: borderColor,
|
|
238
|
+
color: color,
|
|
239
|
+
};
|
|
240
|
+
} catch {
|
|
241
|
+
console.warn(`[getColorConfig] "${originalColor}" is not a valid color. Falling back to gray.`);
|
|
242
|
+
return palette.gray[contrast ? 'high' : 'low'];
|
|
243
|
+
}
|
|
239
244
|
}
|