sprintify-ui 0.0.150 → 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.
@@ -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
+ }