1
1
import { createAlphaScaleWithTransparentize , transparentize } from '../utils/colorMix' ;
2
2
3
- export const whiteAlpha = Object . freeze ( {
4
- whiteAlpha25 : transparentize ( 'white' , '2%' ) ,
5
- whiteAlpha50 : transparentize ( 'white' , '3%' ) ,
6
- whiteAlpha100 : transparentize ( 'white' , '7%' ) ,
7
- whiteAlpha150 : transparentize ( 'white' , '11%' ) ,
8
- whiteAlpha200 : transparentize ( 'white' , '15%' ) ,
9
- whiteAlpha300 : transparentize ( 'white' , '28%' ) ,
10
- whiteAlpha400 : transparentize ( 'white' , '41%' ) ,
11
- whiteAlpha500 : transparentize ( 'white' , '53%' ) ,
12
- whiteAlpha600 : transparentize ( 'white' , '62%' ) ,
13
- whiteAlpha700 : transparentize ( 'white' , '73%' ) ,
14
- whiteAlpha750 : transparentize ( 'white' , '78%' ) ,
15
- whiteAlpha800 : transparentize ( 'white' , '81%' ) ,
16
- whiteAlpha850 : transparentize ( 'white' , '84%' ) ,
17
- whiteAlpha900 : transparentize ( 'white' , '87%' ) ,
18
- whiteAlpha950 : transparentize ( 'white' , '92%' ) ,
19
- } as const ) ;
3
+ type ColorScale < Prefix extends string > = {
4
+ [ K in `${Prefix } ${'50' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | '950' } `] : string ;
5
+ } ;
20
6
21
- export const neutralAlpha = Object . freeze ( {
22
- neutralAlpha25 : transparentize ( 'black' , '2%' ) ,
23
- neutralAlpha50 : transparentize ( 'black' , '3%' ) ,
24
- neutralAlpha100 : transparentize ( 'black' , '7%' ) ,
25
- neutralAlpha150 : transparentize ( 'black' , '11%' ) ,
26
- neutralAlpha200 : transparentize ( 'black' , '15%' ) ,
27
- neutralAlpha300 : transparentize ( 'black' , '28%' ) ,
28
- neutralAlpha400 : transparentize ( 'black' , '41%' ) ,
29
- neutralAlpha500 : transparentize ( 'black' , '53%' ) ,
30
- neutralAlpha600 : transparentize ( 'black' , '62%' ) ,
31
- neutralAlpha700 : transparentize ( 'black' , '73%' ) ,
32
- neutralAlpha750 : transparentize ( 'black' , '78%' ) ,
33
- neutralAlpha800 : transparentize ( 'black' , '81%' ) ,
34
- neutralAlpha850 : transparentize ( 'black' , '84%' ) ,
35
- neutralAlpha900 : transparentize ( 'black' , '87%' ) ,
36
- neutralAlpha950 : transparentize ( 'black' , '92%' ) ,
37
- } as const ) ;
7
+ // Create alpha scales separately to preserve types
8
+ export const whiteAlpha = createAlphaScaleWithTransparentize ( 'white' , 'whiteAlpha' ) ;
9
+ export const neutralAlpha = createAlphaScaleWithTransparentize ( 'black' , 'neutralAlpha' ) ;
10
+
11
+ const primaryAlpha = createAlphaScaleWithTransparentize ( '#2F3037' , 'primaryAlpha' ) ;
12
+ const dangerAlpha = createAlphaScaleWithTransparentize ( '#EF4444' , 'dangerAlpha' ) ;
13
+ const warningAlpha = createAlphaScaleWithTransparentize ( '#F36B16' , 'warningAlpha' ) ;
14
+ const successAlpha = createAlphaScaleWithTransparentize ( '#22C543' , 'successAlpha' ) ;
15
+
16
+ // Define the base colors object type
17
+ type BaseColors = {
18
+ avatarBorder : string ;
19
+ avatarBackground : string ;
20
+ modalBackdrop : string ;
21
+ colorBackground : string ;
22
+ colorInputBackground : string ;
23
+ colorText : string ;
24
+ colorTextSecondary : string ;
25
+ colorInputText : string ;
26
+ colorTextOnPrimaryBackground : string ;
27
+ colorShimmer : string ;
28
+ transparent : string ;
29
+ white : string ;
30
+ black : string ;
31
+ primaryHover : string ;
32
+ } ;
33
+
34
+ // Combine all types
35
+ type Colors = BaseColors &
36
+ ColorScale < 'primary' > &
37
+ ColorScale < 'danger' > &
38
+ ColorScale < 'warning' > &
39
+ ColorScale < 'success' > &
40
+ typeof neutralAlpha &
41
+ typeof whiteAlpha &
42
+ typeof primaryAlpha &
43
+ typeof dangerAlpha &
44
+ typeof warningAlpha &
45
+ typeof successAlpha ;
38
46
39
- export const colors = Object . freeze ( {
47
+ export const colors : Colors = Object . freeze ( {
40
48
avatarBorder : neutralAlpha . neutralAlpha200 ,
41
49
avatarBackground : neutralAlpha . neutralAlpha400 ,
42
50
modalBackdrop : neutralAlpha . neutralAlpha700 ,
@@ -63,8 +71,9 @@ export const colors = Object.freeze({
63
71
primary700 : '#25232A' ,
64
72
primary800 : '#201D23' ,
65
73
primary900 : '#1B171C' ,
66
- primaryHover : '#3B3C45' , //primary 500 adjusted for lightness
67
- ...createAlphaScaleWithTransparentize ( '#2F3037' , 'primaryAlpha' ) ,
74
+ primary950 : '#0F0D12' ,
75
+ primaryHover : '#3B3C45' , // primary 500 adjusted for lightness
76
+ ...primaryAlpha ,
68
77
danger50 : '#FEF2F2' ,
69
78
danger100 : '#FEE5E5' ,
70
79
danger200 : '#FECACA' ,
@@ -76,7 +85,7 @@ export const colors = Object.freeze({
76
85
danger800 : '#991B1B' ,
77
86
danger900 : '#7F1D1D' ,
78
87
danger950 : '#450A0A' ,
79
- ...createAlphaScaleWithTransparentize ( '#EF4444' , ' dangerAlpha' ) ,
88
+ ...dangerAlpha ,
80
89
warning50 : '#FFF6ED' ,
81
90
warning100 : '#FFEBD5' ,
82
91
warning200 : '#FED1AA' ,
@@ -88,7 +97,7 @@ export const colors = Object.freeze({
88
97
warning800 : '#9A2F12' ,
89
98
warning900 : '#7C2912' ,
90
99
warning950 : '#431207' ,
91
- ...createAlphaScaleWithTransparentize ( '#F36B16' , ' warningAlpha' ) ,
100
+ ...warningAlpha ,
92
101
success50 : '#F0FDF2' ,
93
102
success100 : '#DCFCE2' ,
94
103
success200 : '#BBF7C6' ,
@@ -100,5 +109,5 @@ export const colors = Object.freeze({
100
109
success800 : '#166527' ,
101
110
success900 : '#145323' ,
102
111
success950 : '#052E0F' ,
103
- ...createAlphaScaleWithTransparentize ( '#22C543' , ' successAlpha' ) ,
112
+ ...successAlpha ,
104
113
} as const ) ;
0 commit comments