1
+ import lodash from 'lodash' ;
2
+
1
3
export const Theme = {
2
4
contrast : 'contrast' ,
3
5
dark : 'dark' ,
4
6
light : 'light' ,
5
7
} ;
6
8
7
9
export const colors = {
8
- p5pink : '#ed225d' ,
10
+ p5jsPink : '#ed225d' ,
11
+ processingBlue : '#007BBB' ,
12
+ p5jsActivePink : '#f10046' ,
13
+ white : '#fff' ,
14
+ black : '#000' ,
9
15
yellow : '#f5dc23' ,
16
+ orange : '#ffa500' ,
17
+ red : '#ff0000' ,
18
+ lightsteelblue : '#B0C4DE' ,
19
+ dodgerblue : '#1E90FF' ,
20
+ p5ContrastPink : ' #FFA9D9' ,
21
+
22
+ borderColor : ' #B5B5B5' ,
23
+ outlineColor : '#0F9DD7' ,
24
+ } ;
25
+
26
+ export const grays = {
27
+ lightest : '#FFF' , // primary
28
+ lighter : '#FBFBFB' ,
29
+
30
+ light : '#F0F0F0' , // primary
31
+ mediumLight : '#D9D9D9' ,
32
+ middleLight : '#A6A6A6' ,
33
+
34
+ middleGray : '#747474' , // primary
35
+ middleDark : '#666' ,
36
+ mediumDark : '#4D4D4D' ,
37
+
38
+ dark : '#333' , // primary
39
+ darker : '#1C1C1C' ,
40
+ darkest : '#000' ,
10
41
} ;
11
42
12
43
export const common = {
@@ -16,7 +47,8 @@ export const common = {
16
47
export const remSize = size => `${ size / common . baseFontSize } rem` ;
17
48
18
49
export const prop = key => ( props ) => {
19
- const value = props . theme [ key ] ;
50
+ const keypath = `theme.${ key } ` ;
51
+ const value = lodash . get ( props , keypath ) ;
20
52
21
53
if ( value == null ) {
22
54
throw new Error ( `themed prop ${ key } not found` ) ;
@@ -29,40 +61,85 @@ export default {
29
61
[ Theme . light ] : {
30
62
colors,
31
63
...common ,
32
- primaryTextColor : '#333' ,
33
-
34
- buttonColor : '#000' ,
35
- buttonColorBackground : '#f4f4f4' ,
36
- buttonBorderColor : '#b5b5b5' ,
37
- buttonHoverColor : '#fff' ,
38
- buttonHoverColorBackground : colors . p5pink ,
39
- buttonDisabledColor : '#f10046' ,
40
- buttonDisabledColorBackground : '#fff' ,
64
+ primaryTextColor : grays . dark ,
65
+
66
+ Button : {
67
+ default : {
68
+ foreground : colors . black ,
69
+ background : grays . light ,
70
+ border : grays . middleLight ,
71
+ } ,
72
+ hover : {
73
+ foreground : grays . lightest ,
74
+ background : colors . p5jsPink ,
75
+ border : colors . p5jsPink ,
76
+ } ,
77
+ active : {
78
+ foreground : grays . lightest ,
79
+ background : colors . p5jsActivePink ,
80
+ border : colors . p5jsActivePink ,
81
+ } ,
82
+ disabled : {
83
+ foreground : colors . black ,
84
+ background : grays . light ,
85
+ border : grays . middleLight ,
86
+ } ,
87
+ } ,
41
88
} ,
42
89
[ Theme . dark ] : {
43
90
colors,
44
91
...common ,
45
- primaryTextColor : '#FFF' ,
46
-
47
- buttonColor : '#000' ,
48
- buttonColorBackground : '#f4f4f4' ,
49
- buttonBorderColor : '#b5b5b5' ,
50
- buttonHoverColor : '#fff' ,
51
- buttonHoverColorBackground : colors . p5pink ,
52
- buttonDisabledColor : '#f10046' ,
53
- buttonDisabledColorBackground : '#fff' ,
92
+ primaryTextColor : grays . lightest ,
93
+
94
+ Button : {
95
+ default : {
96
+ foreground : grays . light ,
97
+ background : grays . dark ,
98
+ border : grays . middleDark ,
99
+ } ,
100
+ hover : {
101
+ foreground : grays . lightest ,
102
+ background : colors . p5jsPink ,
103
+ border : colors . p5jsPink ,
104
+ } ,
105
+ active : {
106
+ foreground : grays . lightest ,
107
+ background : colors . p5jsActivePink ,
108
+ border : colors . p5jsActivePink ,
109
+ } ,
110
+ disabled : {
111
+ foreground : grays . light ,
112
+ background : grays . dark ,
113
+ border : grays . middleDark ,
114
+ } ,
115
+ } ,
54
116
} ,
55
117
[ Theme . contrast ] : {
56
118
colors,
57
119
...common ,
58
- primaryTextColor : '#F5DC23' ,
59
-
60
- buttonColor : '#000' ,
61
- buttonColorBackground : colors . yellow ,
62
- buttonBorderColor : '#b5b5b5' ,
63
- buttonHoverColor : '#333' ,
64
- buttonHoverColorBackground : '#fff' ,
65
- buttonDisabledColor : '#333' ,
66
- buttonDisabledColorBackground : colors . yellow ,
120
+ primaryTextColor : grays . lightest ,
121
+
122
+ Button : {
123
+ default : {
124
+ foreground : grays . light ,
125
+ background : grays . dark ,
126
+ border : grays . middleDark ,
127
+ } ,
128
+ hover : {
129
+ foreground : grays . dark ,
130
+ background : colors . yellow ,
131
+ border : colors . yellow ,
132
+ } ,
133
+ active : {
134
+ foreground : grays . dark ,
135
+ background : colors . p5jsActivePink ,
136
+ border : colors . p5jsActivePink ,
137
+ } ,
138
+ disabled : {
139
+ foreground : grays . light ,
140
+ background : grays . dark ,
141
+ border : grays . middleDark ,
142
+ } ,
143
+ } ,
67
144
} ,
68
145
} ;
0 commit comments