sprintify-ui 0.0.151 → 0.0.152
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 +7226 -6561
- package/dist/types/src/components/BaseBadge.vue.d.ts +5 -5
- package/dist/types/src/components/BaseShortcut.vue.d.ts +3 -3
- package/dist/types/src/utils/colors.d.ts +13 -0
- package/package.json +2 -1
- package/src/components/BaseBadge.stories.js +3 -13
- package/src/components/BaseBadge.vue +9 -89
- package/src/components/BaseColor.stories.js +1 -5
- package/src/components/BaseColor.vue +17 -15
- package/src/components/BaseShortcut.stories.js +2 -11
- package/src/components/BaseShortcut.vue +11 -68
- package/src/utils/colors.ts +200 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
2
2
|
contrast: 'low' | 'high';
|
|
3
|
-
color:
|
|
4
|
-
size
|
|
3
|
+
color: string;
|
|
4
|
+
size?: "base" | "sm" | "lg" | undefined;
|
|
5
5
|
icon?: string | undefined;
|
|
6
6
|
}>, {
|
|
7
7
|
contrast: string;
|
|
@@ -10,8 +10,8 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
10
10
|
icon: undefined;
|
|
11
11
|
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
12
12
|
contrast: 'low' | 'high';
|
|
13
|
-
color:
|
|
14
|
-
size
|
|
13
|
+
color: string;
|
|
14
|
+
size?: "base" | "sm" | "lg" | undefined;
|
|
15
15
|
icon?: string | undefined;
|
|
16
16
|
}>, {
|
|
17
17
|
contrast: string;
|
|
@@ -19,7 +19,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
19
19
|
size: string;
|
|
20
20
|
icon: undefined;
|
|
21
21
|
}>>>, {
|
|
22
|
-
color:
|
|
22
|
+
color: string;
|
|
23
23
|
icon: string;
|
|
24
24
|
size: 'sm' | 'base' | 'lg';
|
|
25
25
|
contrast: 'low' | 'high';
|
|
@@ -19,7 +19,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
19
19
|
};
|
|
20
20
|
color: {
|
|
21
21
|
default: string;
|
|
22
|
-
type: PropType<
|
|
22
|
+
type: PropType<string>;
|
|
23
23
|
};
|
|
24
24
|
icon: {
|
|
25
25
|
required: true;
|
|
@@ -48,7 +48,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
48
48
|
};
|
|
49
49
|
color: {
|
|
50
50
|
default: string;
|
|
51
|
-
type: PropType<
|
|
51
|
+
type: PropType<string>;
|
|
52
52
|
};
|
|
53
53
|
icon: {
|
|
54
54
|
required: true;
|
|
@@ -59,7 +59,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
59
59
|
type: PropType<"high" | "low">;
|
|
60
60
|
};
|
|
61
61
|
}>>, {
|
|
62
|
-
color:
|
|
62
|
+
color: string;
|
|
63
63
|
description: string;
|
|
64
64
|
contrast: "high" | "low";
|
|
65
65
|
linkText: string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare const colors: import("tailwindcss/types/generated/colors").DefaultColors;
|
|
2
|
+
export { colors };
|
|
3
|
+
interface ColorConfig {
|
|
4
|
+
backgroundColor: string;
|
|
5
|
+
textColor: string;
|
|
6
|
+
borderColor: string;
|
|
7
|
+
}
|
|
8
|
+
interface ColorPalette {
|
|
9
|
+
low: ColorConfig;
|
|
10
|
+
high: ColorConfig;
|
|
11
|
+
}
|
|
12
|
+
export declare const palette: Record<string, ColorPalette>;
|
|
13
|
+
export declare function getColorConfig(color: string, contrast?: boolean): ColorConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sprintify-ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.152",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "rimraf dist && vue-tsc && vite build",
|
|
6
6
|
"build-fast": "rimraf dist && vite build",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@headlessui/vue": "^1.7.4",
|
|
38
|
+
"color2k": "^2.0.1",
|
|
38
39
|
"storybook": "^6.5.15"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
import BaseBadge from './BaseBadge.vue';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
'orange',
|
|
7
|
-
'yellow',
|
|
8
|
-
'green',
|
|
9
|
-
'blue',
|
|
10
|
-
'indigo',
|
|
11
|
-
'purple',
|
|
12
|
-
'pink',
|
|
13
|
-
'#ff0000',
|
|
14
|
-
'#dbeafe',
|
|
15
|
-
];
|
|
3
|
+
import { palette } from '@/utils/colors';
|
|
4
|
+
|
|
5
|
+
const colors = [...Object.keys(palette), '#ff0000', '#dbeafe'];
|
|
16
6
|
|
|
17
7
|
const sizes = ['sm', 'base', 'lg'];
|
|
18
8
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<span
|
|
3
3
|
class="inline-flex items-center rounded-full font-medium"
|
|
4
|
-
:class="[
|
|
4
|
+
:class="[sizeClasses]"
|
|
5
5
|
:style="colorStyle"
|
|
6
6
|
>
|
|
7
7
|
<BaseIcon v-if="icon" :icon="icon" :class="iconSizeClasses"> </BaseIcon>
|
|
@@ -10,23 +10,14 @@
|
|
|
10
10
|
</template>
|
|
11
11
|
|
|
12
12
|
<script lang="ts" setup>
|
|
13
|
+
import { getColorConfig } from '@/utils/colors';
|
|
13
14
|
import { BaseIcon } from '.';
|
|
14
15
|
|
|
15
16
|
const props = withDefaults(
|
|
16
17
|
defineProps<{
|
|
17
18
|
contrast: 'low' | 'high';
|
|
18
|
-
color:
|
|
19
|
-
|
|
20
|
-
| 'red'
|
|
21
|
-
| 'orange'
|
|
22
|
-
| 'yellow'
|
|
23
|
-
| 'green'
|
|
24
|
-
| 'blue'
|
|
25
|
-
| 'indigo'
|
|
26
|
-
| 'purple'
|
|
27
|
-
| 'pink'
|
|
28
|
-
| string;
|
|
29
|
-
size: 'sm' | 'base' | 'lg';
|
|
19
|
+
color: string;
|
|
20
|
+
size?: 'sm' | 'base' | 'lg';
|
|
30
21
|
icon?: string;
|
|
31
22
|
}>(),
|
|
32
23
|
{
|
|
@@ -37,84 +28,13 @@ const props = withDefaults(
|
|
|
37
28
|
}
|
|
38
29
|
);
|
|
39
30
|
|
|
40
|
-
const colorClasses = computed(() => {
|
|
41
|
-
if (props.color == 'gray') {
|
|
42
|
-
if (props.contrast == 'high') {
|
|
43
|
-
return 'bg-slate-600 text-white';
|
|
44
|
-
}
|
|
45
|
-
return 'bg-slate-100 text-slate-800';
|
|
46
|
-
}
|
|
47
|
-
if (props.color == 'red') {
|
|
48
|
-
if (props.contrast == 'high') {
|
|
49
|
-
return 'bg-red-600 text-white';
|
|
50
|
-
}
|
|
51
|
-
return 'bg-red-100 text-red-900';
|
|
52
|
-
}
|
|
53
|
-
if (props.color == 'orange') {
|
|
54
|
-
if (props.contrast == 'high') {
|
|
55
|
-
return 'bg-orange-500 text-white';
|
|
56
|
-
}
|
|
57
|
-
return 'bg-orange-100 text-yellow-900';
|
|
58
|
-
}
|
|
59
|
-
if (props.color == 'yellow') {
|
|
60
|
-
if (props.contrast == 'high') {
|
|
61
|
-
return 'bg-yellow-500 text-white';
|
|
62
|
-
}
|
|
63
|
-
return 'bg-yellow-100 text-yellow-900';
|
|
64
|
-
}
|
|
65
|
-
if (props.color == 'green') {
|
|
66
|
-
if (props.contrast == 'high') {
|
|
67
|
-
return 'bg-green-600 text-white';
|
|
68
|
-
}
|
|
69
|
-
return 'bg-green-100 text-green-900';
|
|
70
|
-
}
|
|
71
|
-
if (props.color == 'blue') {
|
|
72
|
-
if (props.contrast == 'high') {
|
|
73
|
-
return 'bg-blue-600 text-white';
|
|
74
|
-
}
|
|
75
|
-
return 'bg-blue-100 text-blue-900';
|
|
76
|
-
}
|
|
77
|
-
if (props.color == 'indigo') {
|
|
78
|
-
if (props.contrast == 'high') {
|
|
79
|
-
return 'bg-indigo-600 text-white';
|
|
80
|
-
}
|
|
81
|
-
return 'bg-indigo-100 text-indigo-900';
|
|
82
|
-
}
|
|
83
|
-
if (props.color == 'purple') {
|
|
84
|
-
if (props.contrast == 'high') {
|
|
85
|
-
return 'bg-purple-600 text-white';
|
|
86
|
-
}
|
|
87
|
-
return 'bg-purple-100 text-purple-900';
|
|
88
|
-
}
|
|
89
|
-
if (props.color == 'pink') {
|
|
90
|
-
if (props.contrast == 'high') {
|
|
91
|
-
return 'bg-pink-600 text-white';
|
|
92
|
-
}
|
|
93
|
-
return 'bg-pink-100 text-pink-900';
|
|
94
|
-
}
|
|
95
|
-
if (!props.color) {
|
|
96
|
-
return 'bg-slate-100 text-slate-900';
|
|
97
|
-
}
|
|
98
|
-
return '';
|
|
99
|
-
});
|
|
100
|
-
|
|
101
31
|
const colorStyle = computed((): Record<string, string> => {
|
|
102
|
-
|
|
103
|
-
props.color &&
|
|
104
|
-
(props.color.startsWith('#') || props.color.startsWith('rgb'))
|
|
105
|
-
) {
|
|
106
|
-
let textColor = 'white';
|
|
107
|
-
|
|
108
|
-
if (props.contrast == 'low') {
|
|
109
|
-
textColor = 'rgba(0,0,0,0.8)';
|
|
110
|
-
}
|
|
32
|
+
const config = getColorConfig(props.color, props.contrast == 'high');
|
|
111
33
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
return {};
|
|
34
|
+
return {
|
|
35
|
+
backgroundColor: config.backgroundColor,
|
|
36
|
+
color: config.textColor,
|
|
37
|
+
};
|
|
118
38
|
});
|
|
119
39
|
|
|
120
40
|
const sizeClasses = computed(() => {
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import { createFieldStory
|
|
1
|
+
import { createFieldStory } from '../../.storybook/utils';
|
|
2
2
|
import BaseColor from './BaseColor.vue';
|
|
3
3
|
import ShowValue from '../../.storybook/components/ShowValue.vue';
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
6
|
title: 'Form/BaseColor',
|
|
7
7
|
component: BaseColor,
|
|
8
|
-
argTypes: {},
|
|
9
|
-
args: {
|
|
10
|
-
colors: colors,
|
|
11
|
-
},
|
|
12
8
|
decorators: [() => ({ template: '<div class="mb-36"><story/></div>' })],
|
|
13
9
|
};
|
|
14
10
|
|
|
@@ -17,10 +17,17 @@
|
|
|
17
17
|
<template #option="option">
|
|
18
18
|
<div
|
|
19
19
|
:style="{ backgroundColor: option.option.value + '' }"
|
|
20
|
-
class="rounded-md border
|
|
20
|
+
class="box-border rounded-md border p-3"
|
|
21
21
|
:class="[
|
|
22
|
-
option.selected.value
|
|
22
|
+
option.selected.value
|
|
23
|
+
? option.option.option.hasLowContrast
|
|
24
|
+
? 'text-slate-700'
|
|
25
|
+
: 'text-white'
|
|
26
|
+
: 'text-transparent',
|
|
23
27
|
disabled ? ' cursor-not-allowed opacity-50' : '',
|
|
28
|
+
option.option.option.hasLowContrast
|
|
29
|
+
? 'border-slate-400'
|
|
30
|
+
: 'border-transparent',
|
|
24
31
|
]"
|
|
25
32
|
>
|
|
26
33
|
<BaseIcon icon="heroicons-solid:check-circle" class="h-5 w-5" />
|
|
@@ -36,6 +43,8 @@ import { BaseButtonGroup } from '.';
|
|
|
36
43
|
import { isArray } from 'lodash';
|
|
37
44
|
import { useField } from '@/composables/field';
|
|
38
45
|
import { Option } from '@/types';
|
|
46
|
+
import { palette } from '@/utils/colors';
|
|
47
|
+
import { getContrast } from 'color2k';
|
|
39
48
|
|
|
40
49
|
const props = defineProps({
|
|
41
50
|
modelValue: {
|
|
@@ -59,19 +68,7 @@ const props = defineProps({
|
|
|
59
68
|
colors: {
|
|
60
69
|
type: [Array] as PropType<string[]>,
|
|
61
70
|
default() {
|
|
62
|
-
return
|
|
63
|
-
'#0f172a',
|
|
64
|
-
'#dc2626',
|
|
65
|
-
'#ea580c',
|
|
66
|
-
'#eab308',
|
|
67
|
-
'#16a34a',
|
|
68
|
-
'#0d9488',
|
|
69
|
-
'#0891b2',
|
|
70
|
-
'#2563eb',
|
|
71
|
-
'#4f46e5',
|
|
72
|
-
'#9333ea',
|
|
73
|
-
'#db2777',
|
|
74
|
-
];
|
|
71
|
+
return Object.values(palette).map((p) => p.high.backgroundColor);
|
|
75
72
|
},
|
|
76
73
|
},
|
|
77
74
|
multiple: {
|
|
@@ -95,10 +92,15 @@ const colorOptions = computed(() => {
|
|
|
95
92
|
return {
|
|
96
93
|
label: c,
|
|
97
94
|
value: c,
|
|
95
|
+
hasLowContrast: hasLowContrast(c),
|
|
98
96
|
};
|
|
99
97
|
});
|
|
100
98
|
});
|
|
101
99
|
|
|
100
|
+
function hasLowContrast(color: string): boolean {
|
|
101
|
+
return getContrast(color, '#fff') < 1.38;
|
|
102
|
+
}
|
|
103
|
+
|
|
102
104
|
const normalizeModelValue = computed(() => {
|
|
103
105
|
return isArray(props.modelValue)
|
|
104
106
|
? props.modelValue?.map((m) => {
|
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import BaseShortcut from './BaseShortcut.vue';
|
|
2
|
+
import { palette } from '@/utils/colors';
|
|
2
3
|
|
|
3
|
-
const colors = [
|
|
4
|
-
'gray',
|
|
5
|
-
'red',
|
|
6
|
-
'orange',
|
|
7
|
-
'yellow',
|
|
8
|
-
'green',
|
|
9
|
-
'blue',
|
|
10
|
-
'indigo',
|
|
11
|
-
'purple',
|
|
12
|
-
'pink',
|
|
13
|
-
];
|
|
4
|
+
const colors = [...Object.keys(palette), '#ff0000', '#dbeafe'];
|
|
14
5
|
|
|
15
6
|
const sizes = ['base', 'lg'];
|
|
16
7
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<!-- Icon -->
|
|
6
6
|
<div
|
|
7
7
|
class="mb-2.5 inline-flex items-center rounded p-2"
|
|
8
|
-
:
|
|
8
|
+
:style="colorStyle"
|
|
9
9
|
>
|
|
10
10
|
<BaseIcon
|
|
11
11
|
v-if="icon"
|
|
@@ -47,6 +47,7 @@ import { PropType } from 'vue';
|
|
|
47
47
|
import { BaseIcon } from '.';
|
|
48
48
|
import BaseCard from './BaseCard.vue';
|
|
49
49
|
import { RouteLocationRaw } from 'vue-router';
|
|
50
|
+
import { getColorConfig } from '@/utils/colors';
|
|
50
51
|
|
|
51
52
|
const props = defineProps({
|
|
52
53
|
to: {
|
|
@@ -67,17 +68,7 @@ const props = defineProps({
|
|
|
67
68
|
},
|
|
68
69
|
color: {
|
|
69
70
|
default: 'gray',
|
|
70
|
-
type: String as PropType<
|
|
71
|
-
| 'gray'
|
|
72
|
-
| 'red'
|
|
73
|
-
| 'orange'
|
|
74
|
-
| 'yellow'
|
|
75
|
-
| 'green'
|
|
76
|
-
| 'blue'
|
|
77
|
-
| 'indigo'
|
|
78
|
-
| 'purple'
|
|
79
|
-
| 'pink'
|
|
80
|
-
>,
|
|
71
|
+
type: String as PropType<string>,
|
|
81
72
|
},
|
|
82
73
|
icon: {
|
|
83
74
|
required: true,
|
|
@@ -89,62 +80,14 @@ const props = defineProps({
|
|
|
89
80
|
},
|
|
90
81
|
});
|
|
91
82
|
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (props.contrast == 'high') {
|
|
101
|
-
return 'bg-red-600 text-white';
|
|
102
|
-
}
|
|
103
|
-
return 'bg-red-100 text-red-700 border border-red-300';
|
|
104
|
-
}
|
|
105
|
-
if (props.color == 'orange') {
|
|
106
|
-
if (props.contrast == 'high') {
|
|
107
|
-
return 'bg-orange-500 text-white';
|
|
108
|
-
}
|
|
109
|
-
return 'bg-orange-100 text-yellow-700 border border-orange-300';
|
|
110
|
-
}
|
|
111
|
-
if (props.color == 'yellow') {
|
|
112
|
-
if (props.contrast == 'high') {
|
|
113
|
-
return 'bg-yellow-500 text-white';
|
|
114
|
-
}
|
|
115
|
-
return 'bg-yellow-100 text-yellow-700 border border-yellow-300';
|
|
116
|
-
}
|
|
117
|
-
if (props.color == 'green') {
|
|
118
|
-
if (props.contrast == 'high') {
|
|
119
|
-
return 'bg-green-600 text-white';
|
|
120
|
-
}
|
|
121
|
-
return 'bg-green-100 text-green-700 border border-green-300';
|
|
122
|
-
}
|
|
123
|
-
if (props.color == 'blue') {
|
|
124
|
-
if (props.contrast == 'high') {
|
|
125
|
-
return 'bg-blue-600 text-white';
|
|
126
|
-
}
|
|
127
|
-
return 'bg-blue-100 text-blue-700 border border-blue-300';
|
|
128
|
-
}
|
|
129
|
-
if (props.color == 'indigo') {
|
|
130
|
-
if (props.contrast == 'high') {
|
|
131
|
-
return 'bg-indigo-600 text-white';
|
|
132
|
-
}
|
|
133
|
-
return 'bg-indigo-100 text-indigo-700 border border-indigo-300';
|
|
134
|
-
}
|
|
135
|
-
if (props.color == 'purple') {
|
|
136
|
-
if (props.contrast == 'high') {
|
|
137
|
-
return 'bg-purple-600 text-white';
|
|
138
|
-
}
|
|
139
|
-
return 'bg-purple-100 text-purple-700 border border-purple-300';
|
|
140
|
-
}
|
|
141
|
-
if (props.color == 'pink') {
|
|
142
|
-
if (props.contrast == 'high') {
|
|
143
|
-
return 'bg-pink-600 text-white';
|
|
144
|
-
}
|
|
145
|
-
return 'bg-pink-100 text-pink-700 border border-pink-300';
|
|
146
|
-
}
|
|
147
|
-
return 'bg-slate-100 text-slate-700 border border-slate-300';
|
|
83
|
+
const colorStyle = computed((): Record<string, string> => {
|
|
84
|
+
const config = getColorConfig(props.color, props.contrast == 'high');
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
backgroundColor: config.backgroundColor,
|
|
88
|
+
border: `1px solid ${config.borderColor}`,
|
|
89
|
+
color: config.textColor,
|
|
90
|
+
};
|
|
148
91
|
});
|
|
149
92
|
|
|
150
93
|
const iconSizeClasses = computed(() => {
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { darken, getContrast } from 'color2k';
|
|
2
|
+
import defaultColors from 'tailwindcss/colors';
|
|
3
|
+
|
|
4
|
+
const colors = defaultColors;
|
|
5
|
+
|
|
6
|
+
export { colors };
|
|
7
|
+
|
|
8
|
+
interface ColorConfig {
|
|
9
|
+
backgroundColor: string;
|
|
10
|
+
textColor: string;
|
|
11
|
+
borderColor: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface ColorPalette {
|
|
15
|
+
low: ColorConfig;
|
|
16
|
+
high: ColorConfig;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const palette: Record<string, ColorPalette> = {
|
|
20
|
+
black: {
|
|
21
|
+
low: {
|
|
22
|
+
backgroundColor: colors.slate[200],
|
|
23
|
+
textColor: colors.slate[900],
|
|
24
|
+
borderColor: 'transparent',
|
|
25
|
+
},
|
|
26
|
+
high: {
|
|
27
|
+
backgroundColor: colors.black,
|
|
28
|
+
textColor: colors.white,
|
|
29
|
+
borderColor: 'transparent',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
gray: {
|
|
33
|
+
low: {
|
|
34
|
+
backgroundColor: colors.slate[100],
|
|
35
|
+
textColor: colors.slate[800],
|
|
36
|
+
borderColor: colors.slate[300],
|
|
37
|
+
},
|
|
38
|
+
high: {
|
|
39
|
+
backgroundColor: colors.slate[600],
|
|
40
|
+
textColor: colors.white,
|
|
41
|
+
borderColor: 'transparent',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
red: {
|
|
45
|
+
low: {
|
|
46
|
+
backgroundColor: colors.red[100],
|
|
47
|
+
textColor: colors.red[700],
|
|
48
|
+
borderColor: colors.red[300],
|
|
49
|
+
},
|
|
50
|
+
high: {
|
|
51
|
+
backgroundColor: colors.red[600],
|
|
52
|
+
textColor: colors.white,
|
|
53
|
+
borderColor: 'transparent',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
orange: {
|
|
57
|
+
low: {
|
|
58
|
+
backgroundColor: colors.orange[100],
|
|
59
|
+
textColor: colors.orange[700],
|
|
60
|
+
borderColor: colors.orange[300],
|
|
61
|
+
},
|
|
62
|
+
high: {
|
|
63
|
+
backgroundColor: colors.orange[500],
|
|
64
|
+
textColor: colors.white,
|
|
65
|
+
borderColor: 'transparent',
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
yellow: {
|
|
69
|
+
low: {
|
|
70
|
+
backgroundColor: colors.yellow[100],
|
|
71
|
+
textColor: colors.yellow[700],
|
|
72
|
+
borderColor: colors.yellow[300],
|
|
73
|
+
},
|
|
74
|
+
high: {
|
|
75
|
+
backgroundColor: colors.yellow[500],
|
|
76
|
+
textColor: colors.white,
|
|
77
|
+
borderColor: 'transparent',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
green: {
|
|
81
|
+
low: {
|
|
82
|
+
backgroundColor: colors.green[100],
|
|
83
|
+
textColor: colors.green[700],
|
|
84
|
+
borderColor: colors.green[300],
|
|
85
|
+
},
|
|
86
|
+
high: {
|
|
87
|
+
backgroundColor: colors.green[600],
|
|
88
|
+
textColor: colors.white,
|
|
89
|
+
borderColor: 'transparent',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
teal: {
|
|
93
|
+
low: {
|
|
94
|
+
backgroundColor: colors.teal[100],
|
|
95
|
+
textColor: colors.teal[700],
|
|
96
|
+
borderColor: colors.teal[300],
|
|
97
|
+
},
|
|
98
|
+
high: {
|
|
99
|
+
backgroundColor: colors.teal[600],
|
|
100
|
+
textColor: colors.white,
|
|
101
|
+
borderColor: 'transparent',
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
cyan: {
|
|
105
|
+
low: {
|
|
106
|
+
backgroundColor: colors.cyan[100],
|
|
107
|
+
textColor: colors.cyan[700],
|
|
108
|
+
borderColor: colors.cyan[300],
|
|
109
|
+
},
|
|
110
|
+
high: {
|
|
111
|
+
backgroundColor: colors.cyan[600],
|
|
112
|
+
textColor: colors.white,
|
|
113
|
+
borderColor: 'transparent',
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
blue: {
|
|
117
|
+
low: {
|
|
118
|
+
backgroundColor: colors.blue[100],
|
|
119
|
+
textColor: colors.blue[700],
|
|
120
|
+
borderColor: colors.blue[300],
|
|
121
|
+
},
|
|
122
|
+
high: {
|
|
123
|
+
backgroundColor: colors.blue[600],
|
|
124
|
+
textColor: colors.white,
|
|
125
|
+
borderColor: 'transparent',
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
indigo: {
|
|
129
|
+
low: {
|
|
130
|
+
backgroundColor: colors.indigo[100],
|
|
131
|
+
textColor: colors.indigo[700],
|
|
132
|
+
borderColor: colors.indigo[300],
|
|
133
|
+
},
|
|
134
|
+
high: {
|
|
135
|
+
backgroundColor: colors.indigo[600],
|
|
136
|
+
textColor: colors.white,
|
|
137
|
+
borderColor: 'transparent',
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
purple: {
|
|
141
|
+
low: {
|
|
142
|
+
backgroundColor: colors.purple[100],
|
|
143
|
+
textColor: colors.purple[700],
|
|
144
|
+
borderColor: colors.purple[300],
|
|
145
|
+
},
|
|
146
|
+
high: {
|
|
147
|
+
backgroundColor: colors.purple[600],
|
|
148
|
+
textColor: colors.white,
|
|
149
|
+
borderColor: 'transparent',
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
pink: {
|
|
153
|
+
low: {
|
|
154
|
+
backgroundColor: colors.pink[100],
|
|
155
|
+
textColor: colors.pink[700],
|
|
156
|
+
borderColor: colors.pink[300],
|
|
157
|
+
},
|
|
158
|
+
high: {
|
|
159
|
+
backgroundColor: colors.pink[600],
|
|
160
|
+
textColor: colors.white,
|
|
161
|
+
borderColor: 'transparent',
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
white: {
|
|
165
|
+
low: {
|
|
166
|
+
backgroundColor: colors.white,
|
|
167
|
+
textColor: colors.slate[600],
|
|
168
|
+
borderColor: 'transparent',
|
|
169
|
+
},
|
|
170
|
+
high: {
|
|
171
|
+
backgroundColor: colors.white,
|
|
172
|
+
textColor: colors.black,
|
|
173
|
+
borderColor: 'transparent',
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export function getColorConfig(color: string, contrast = false): ColorConfig {
|
|
179
|
+
const colorConfig = palette[color]?.[contrast ? 'high' : 'low'];
|
|
180
|
+
|
|
181
|
+
if (colorConfig) {
|
|
182
|
+
return colorConfig;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const c = getContrast(color, 'white');
|
|
186
|
+
|
|
187
|
+
let borderColor = 'transparent';
|
|
188
|
+
let textColor = 'white';
|
|
189
|
+
|
|
190
|
+
if (c < 2) {
|
|
191
|
+
textColor = darken(color, 0.5);
|
|
192
|
+
borderColor = darken(color, 0.1);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return {
|
|
196
|
+
backgroundColor: color,
|
|
197
|
+
textColor: textColor,
|
|
198
|
+
borderColor: borderColor,
|
|
199
|
+
};
|
|
200
|
+
}
|