sprintify-ui 0.12.22 → 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 +784 -786
- package/package.json +1 -1
- package/src/components/BaseBadge.vue +13 -18
- package/src/components/BaseButton.vue +9 -13
- package/src/utils/colors.ts +19 -14
package/package.json
CHANGED
|
@@ -43,25 +43,20 @@ const props = withDefaults(
|
|
|
43
43
|
);
|
|
44
44
|
|
|
45
45
|
const colorStyle = computed((): Record<string, string> => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
styles.borderStyle = 'solid';
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return styles;
|
|
61
|
-
} catch {
|
|
62
|
-
console.warn(`[BaseBadge] "${props.color}" is not a valid color.`);
|
|
63
|
-
return {};
|
|
46
|
+
const config = getColorConfig(props.color, props.contrast == 'high');
|
|
47
|
+
|
|
48
|
+
const styles: Record<string, string> = {
|
|
49
|
+
backgroundColor: config.backgroundColor,
|
|
50
|
+
color: config.textColor,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
if (props.bordered) {
|
|
54
|
+
styles.borderColor = config.borderColor;
|
|
55
|
+
styles.borderWidth = '1px';
|
|
56
|
+
styles.borderStyle = 'solid';
|
|
64
57
|
}
|
|
58
|
+
|
|
59
|
+
return styles;
|
|
65
60
|
});
|
|
66
61
|
|
|
67
62
|
const sizeInternal = computed(() => {
|
|
@@ -207,19 +207,15 @@ const classes = computed(() => {
|
|
|
207
207
|
|
|
208
208
|
const styles = computed(() => {
|
|
209
209
|
if (props.color && !(props.color in colors)) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
};
|
|
220
|
-
} catch {
|
|
221
|
-
console.warn(`[BaseButton] "${props.color}" is not a valid color.`);
|
|
222
|
-
}
|
|
210
|
+
const config = getColorConfig(props.color);
|
|
211
|
+
|
|
212
|
+
return {
|
|
213
|
+
backgroundColor: config.backgroundColor,
|
|
214
|
+
color: config.textColor,
|
|
215
|
+
borderColor: config.borderColor,
|
|
216
|
+
borderWidth: '1px',
|
|
217
|
+
borderStyle: 'solid',
|
|
218
|
+
};
|
|
223
219
|
}
|
|
224
220
|
|
|
225
221
|
return {};
|
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
|
}
|