@udixio/theme 1.0.0-beta.3 → 1.0.0-beta.31
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/app.container.d.ts +5 -0
- package/dist/app.module.d.ts +2 -2
- package/dist/app.service.d.ts +9 -3
- package/dist/color/color.interface.d.ts +1 -2
- package/dist/color/color.module.d.ts +2 -2
- package/dist/color/entities/color.entity.d.ts +6 -1
- package/dist/color/entities/index.d.ts +1 -0
- package/dist/color/index.d.ts +5 -0
- package/dist/color/models/default-color.model.d.ts +2 -3
- package/dist/color/models/index.d.ts +1 -0
- package/dist/color/services/color-manager.service.d.ts +18 -0
- package/dist/color/services/color.service.d.ts +21 -0
- package/dist/color/services/index.d.ts +2 -0
- package/dist/config/config.interface.d.ts +13 -0
- package/dist/config/config.module.d.ts +2 -0
- package/dist/config/config.service.d.ts +12 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/index.d.ts +11 -0
- package/dist/main.d.ts +6 -1
- package/dist/material-color-utilities/index.d.ts +1 -0
- package/dist/plugin/index.d.ts +3 -0
- package/dist/plugin/plugin.module.d.ts +2 -0
- package/dist/plugin/plugin.service.d.ts +8 -0
- package/dist/plugin/pluginAbstract.d.ts +18 -0
- package/dist/plugins/font/font.plugin.d.ts +49 -0
- package/dist/plugins/font/index.d.ts +1 -0
- package/dist/plugins/tailwind/index.d.ts +3 -0
- package/dist/plugins/tailwind/main.d.ts +13 -0
- package/dist/plugins/tailwind/plugins-tailwind/font.d.ts +5 -0
- package/dist/plugins/tailwind/plugins-tailwind/index.d.ts +2 -0
- package/dist/plugins/tailwind/plugins-tailwind/state.d.ts +4 -0
- package/dist/plugins/tailwind/plugins-tailwind/themer.d.ts +10 -0
- package/dist/plugins/tailwind/tailwind.plugin.d.ts +18 -0
- package/dist/theme/entities/index.d.ts +2 -0
- package/dist/theme/entities/variant.entity.d.ts +2 -1
- package/dist/theme/index.d.ts +4 -0
- package/dist/theme/models/index.d.ts +1 -0
- package/dist/theme/services/index.d.ts +3 -0
- package/dist/theme/services/scheme.service.d.ts +7 -2
- package/dist/theme/services/theme.service.d.ts +16 -7
- package/dist/theme/services/variant.service.d.ts +8 -2
- package/dist/theme/theme.module.d.ts +2 -2
- package/dist/theme.cjs.development.js +1418 -906
- package/dist/theme.cjs.development.js.map +1 -1
- package/dist/theme.cjs.production.min.js +1 -1
- package/dist/theme.cjs.production.min.js.map +1 -1
- package/dist/theme.esm.js +1385 -907
- package/dist/theme.esm.js.map +1 -1
- package/package.json +21 -22
- package/src/app.container.ts +46 -0
- package/src/app.module.ts +5 -8
- package/src/app.service.spec.ts +1 -1
- package/src/app.service.ts +20 -8
- package/src/color/color.interface.ts +1 -3
- package/src/color/color.module.ts +8 -10
- package/src/color/entities/color.entity.ts +13 -1
- package/src/color/entities/index.ts +1 -0
- package/src/color/index.ts +5 -0
- package/src/color/models/default-color.model.ts +205 -202
- package/src/color/models/index.ts +1 -0
- package/src/color/{color-manager.service.ts → services/color-manager.service.ts} +23 -15
- package/src/color/{color.service.spec.ts → services/color.service.spec.ts} +1 -1
- package/src/color/services/color.service.ts +75 -0
- package/src/color/services/index.ts +2 -0
- package/src/config/config.interface.ts +14 -0
- package/src/config/config.module.ts +7 -0
- package/src/config/config.service.ts +104 -0
- package/src/config/index.ts +3 -0
- package/src/index.ts +11 -0
- package/src/main.ts +13 -7
- package/src/material-color-utilities/index.ts +1 -0
- package/src/plugin/index.ts +3 -0
- package/src/plugin/plugin.module.ts +7 -0
- package/src/plugin/plugin.service.ts +42 -0
- package/src/plugin/pluginAbstract.ts +44 -0
- package/src/plugins/font/font.plugin.ts +203 -0
- package/src/plugins/font/index.ts +1 -0
- package/src/plugins/tailwind/index.ts +3 -0
- package/src/plugins/tailwind/main.ts +16 -0
- package/src/plugins/tailwind/plugins-tailwind/font.ts +69 -0
- package/src/plugins/tailwind/plugins-tailwind/index.ts +2 -0
- package/src/plugins/tailwind/plugins-tailwind/state.ts +88 -0
- package/src/plugins/tailwind/plugins-tailwind/themer.ts +137 -0
- package/src/plugins/tailwind/tailwind.plugin.ts +72 -0
- package/src/theme/entities/index.ts +2 -0
- package/src/theme/entities/variant.entity.ts +2 -1
- package/src/theme/index.ts +4 -0
- package/src/theme/models/index.ts +1 -0
- package/src/theme/models/variant.model.ts +7 -0
- package/src/theme/services/index.ts +3 -0
- package/src/theme/services/scheme.service.ts +39 -11
- package/src/theme/services/theme.service.ts +30 -14
- package/src/theme/services/variant.service.ts +40 -5
- package/src/theme/theme.module.ts +8 -9
- package/dist/color/color-manager.service.d.ts +0 -15
- package/dist/color/color.service.d.ts +0 -14
- package/src/color/color.service.ts +0 -58
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DislikeAnalyzer, Hct } from '@material/material-color-utilities';
|
|
2
2
|
import { ContrastCurve, ToneDeltaPair } from '../../material-color-utilities';
|
|
3
3
|
import { DynamicColor } from '../../material-color-utilities/dynamic_color';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { highestSurface } from '../services/color-manager.service';
|
|
5
|
+
import { AddColorsOptions, ColorService } from '../services/color.service';
|
|
6
6
|
|
|
7
7
|
export type DynamicColorKey =
|
|
8
8
|
| 'background'
|
|
@@ -88,210 +88,213 @@ function findDesiredChromaByTone(
|
|
|
88
88
|
return answer;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
export const defaultColors = (
|
|
92
|
-
|
|
93
|
-
)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
palette: (s) => s.getPalette('neutral'),
|
|
101
|
-
tone: (s) => (s.isDark ? 90 : 10),
|
|
102
|
-
background: (s) => colorManagerService.get('background').getDynamicColor(),
|
|
103
|
-
contrastCurve: new ContrastCurve(3, 3, 4.5, 7),
|
|
104
|
-
},
|
|
105
|
-
surface: {
|
|
106
|
-
palette: (s) => s.getPalette('neutral'),
|
|
107
|
-
tone: (s) => (s.isDark ? 6 : 98),
|
|
108
|
-
isBackground: true,
|
|
109
|
-
},
|
|
110
|
-
surfaceDim: {
|
|
111
|
-
palette: (s) => s.getPalette('neutral'),
|
|
112
|
-
tone: (s) => (s.isDark ? 6 : 87),
|
|
113
|
-
isBackground: true,
|
|
114
|
-
},
|
|
115
|
-
surfaceBright: {
|
|
116
|
-
palette: (s) => s.getPalette('neutral'),
|
|
117
|
-
tone: (s) => (s.isDark ? 24 : 98),
|
|
118
|
-
isBackground: true,
|
|
119
|
-
},
|
|
120
|
-
surfaceContainerLowest: {
|
|
121
|
-
palette: (s) => s.getPalette('neutral'),
|
|
122
|
-
tone: (s) => (s.isDark ? 4 : 100),
|
|
123
|
-
isBackground: true,
|
|
124
|
-
},
|
|
125
|
-
surfaceContainerLow: {
|
|
126
|
-
palette: (s) => s.getPalette('neutral'),
|
|
127
|
-
tone: (s) => (s.isDark ? 10 : 96),
|
|
128
|
-
isBackground: true,
|
|
129
|
-
},
|
|
130
|
-
surfaceContainer: {
|
|
131
|
-
palette: (s) => s.getPalette('neutral'),
|
|
132
|
-
tone: (s) => (s.isDark ? 12 : 94),
|
|
133
|
-
isBackground: true,
|
|
134
|
-
},
|
|
135
|
-
surfaceContainerHigh: {
|
|
136
|
-
palette: (s) => s.getPalette('neutral'),
|
|
137
|
-
tone: (s) => (s.isDark ? 17 : 92),
|
|
138
|
-
isBackground: true,
|
|
139
|
-
},
|
|
140
|
-
surfaceContainerHighest: {
|
|
141
|
-
palette: (s) => s.getPalette('neutral'),
|
|
142
|
-
tone: (s) => (s.isDark ? 22 : 90),
|
|
143
|
-
isBackground: true,
|
|
144
|
-
},
|
|
145
|
-
onSurface: {
|
|
146
|
-
palette: (s) => s.getPalette('neutral'),
|
|
147
|
-
tone: (s) => (s.isDark ? 90 : 10),
|
|
148
|
-
background: (s) => highestSurface(s, colorManagerService),
|
|
149
|
-
contrastCurve: new ContrastCurve(4.5, 7, 11, 21),
|
|
150
|
-
},
|
|
151
|
-
surfaceVariant: {
|
|
152
|
-
palette: (s) => s.getPalette('neutralVariant'),
|
|
153
|
-
tone: (s) => (s.isDark ? 30 : 90),
|
|
154
|
-
isBackground: true,
|
|
155
|
-
},
|
|
156
|
-
onSurfaceVariant: {
|
|
157
|
-
palette: (s) => s.getPalette('neutralVariant'),
|
|
158
|
-
tone: (s) => (s.isDark ? 80 : 30),
|
|
159
|
-
background: (s) => highestSurface(s, colorManagerService),
|
|
160
|
-
contrastCurve: new ContrastCurve(3, 4.5, 7, 11),
|
|
161
|
-
},
|
|
162
|
-
inverseSurface: {
|
|
163
|
-
palette: (s) => s.getPalette('neutral'),
|
|
164
|
-
tone: (s) => (s.isDark ? 90 : 20),
|
|
165
|
-
},
|
|
166
|
-
inverseOnSurface: {
|
|
167
|
-
palette: (s) => s.getPalette('neutral'),
|
|
168
|
-
tone: (s) => (s.isDark ? 20 : 95),
|
|
169
|
-
background: (s) =>
|
|
170
|
-
colorManagerService.get('inverseSurface').getDynamicColor(),
|
|
171
|
-
contrastCurve: new ContrastCurve(4.5, 7, 11, 21),
|
|
172
|
-
},
|
|
173
|
-
outline: {
|
|
174
|
-
palette: (s) => s.getPalette('neutralVariant'),
|
|
175
|
-
tone: (s) => (s.isDark ? 60 : 50),
|
|
176
|
-
background: (s) => highestSurface(s, colorManagerService),
|
|
177
|
-
contrastCurve: new ContrastCurve(1.5, 3, 4.5, 7),
|
|
178
|
-
},
|
|
179
|
-
outlineVariant: {
|
|
180
|
-
palette: (s) => s.getPalette('neutralVariant'),
|
|
181
|
-
tone: (s) => (s.isDark ? 30 : 80),
|
|
182
|
-
background: (s) => highestSurface(s, colorManagerService),
|
|
183
|
-
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
184
|
-
},
|
|
185
|
-
shadow: {
|
|
186
|
-
palette: (s) => s.getPalette('neutral'),
|
|
187
|
-
tone: (s) => 0,
|
|
188
|
-
},
|
|
189
|
-
scrim: {
|
|
190
|
-
palette: (s) => s.getPalette('neutral'),
|
|
191
|
-
tone: (s) => 0,
|
|
192
|
-
},
|
|
193
|
-
surfaceTint: {
|
|
194
|
-
palette: (s) => s.getPalette('neutral'),
|
|
195
|
-
tone: (s) => (s.isDark ? 80 : 40),
|
|
196
|
-
isBackground: true,
|
|
197
|
-
},
|
|
198
|
-
secondaryContainer: {
|
|
199
|
-
tone: (s) => {
|
|
200
|
-
const initialTone = s.isDark ? 30 : 90;
|
|
201
|
-
return findDesiredChromaByTone(
|
|
202
|
-
s.getPalette('secondary').hue,
|
|
203
|
-
s.getPalette('secondary').chroma,
|
|
204
|
-
initialTone,
|
|
205
|
-
!s.isDark
|
|
206
|
-
);
|
|
91
|
+
export const defaultColors: AddColorsOptions = (
|
|
92
|
+
colorService: ColorService
|
|
93
|
+
) => ({
|
|
94
|
+
fromPalettes: ['primary', 'secondary', 'tertiary'],
|
|
95
|
+
colors: {
|
|
96
|
+
background: {
|
|
97
|
+
palette: (s) => s.getPalette('neutral'),
|
|
98
|
+
tone: (s) => (s.isDark ? 6 : 98),
|
|
99
|
+
isBackground: true,
|
|
207
100
|
},
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
4.5
|
|
214
|
-
);
|
|
101
|
+
onBackground: {
|
|
102
|
+
palette: (s) => s.getPalette('neutral'),
|
|
103
|
+
tone: (s) => (s.isDark ? 90 : 10),
|
|
104
|
+
background: (s) => colorService.getColor('background').getDynamicColor(),
|
|
105
|
+
contrastCurve: new ContrastCurve(3, 3, 4.5, 7),
|
|
215
106
|
},
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
const proposedHct = s
|
|
221
|
-
.getPalette('tertiary')
|
|
222
|
-
.getHct(s.sourceColorHct.tone);
|
|
223
|
-
return DislikeAnalyzer.fixIfDisliked(proposedHct).tone;
|
|
107
|
+
surface: {
|
|
108
|
+
palette: (s) => s.getPalette('neutral'),
|
|
109
|
+
tone: (s) => (s.isDark ? 6 : 98),
|
|
110
|
+
isBackground: true,
|
|
224
111
|
},
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
)
|
|
112
|
+
surfaceDim: {
|
|
113
|
+
palette: (s) => s.getPalette('neutral'),
|
|
114
|
+
tone: (s) => (s.isDark ? 6 : 87),
|
|
115
|
+
isBackground: true,
|
|
116
|
+
},
|
|
117
|
+
surfaceBright: {
|
|
118
|
+
palette: (s) => s.getPalette('neutral'),
|
|
119
|
+
tone: (s) => (s.isDark ? 24 : 98),
|
|
120
|
+
isBackground: true,
|
|
121
|
+
},
|
|
122
|
+
surfaceContainerLowest: {
|
|
123
|
+
palette: (s) => s.getPalette('neutral'),
|
|
124
|
+
tone: (s) => (s.isDark ? 4 : 100),
|
|
125
|
+
isBackground: true,
|
|
126
|
+
},
|
|
127
|
+
surfaceContainerLow: {
|
|
128
|
+
palette: (s) => s.getPalette('neutral'),
|
|
129
|
+
tone: (s) => (s.isDark ? 10 : 96),
|
|
130
|
+
isBackground: true,
|
|
131
|
+
},
|
|
132
|
+
surfaceContainer: {
|
|
133
|
+
palette: (s) => s.getPalette('neutral'),
|
|
134
|
+
tone: (s) => (s.isDark ? 12 : 94),
|
|
135
|
+
isBackground: true,
|
|
136
|
+
},
|
|
137
|
+
surfaceContainerHigh: {
|
|
138
|
+
palette: (s) => s.getPalette('neutral'),
|
|
139
|
+
tone: (s) => (s.isDark ? 17 : 92),
|
|
140
|
+
isBackground: true,
|
|
141
|
+
},
|
|
142
|
+
surfaceContainerHighest: {
|
|
143
|
+
palette: (s) => s.getPalette('neutral'),
|
|
144
|
+
tone: (s) => (s.isDark ? 22 : 90),
|
|
145
|
+
isBackground: true,
|
|
146
|
+
},
|
|
147
|
+
onSurface: {
|
|
148
|
+
palette: (s) => s.getPalette('neutral'),
|
|
149
|
+
tone: (s) => (s.isDark ? 90 : 10),
|
|
150
|
+
background: (s) => highestSurface(s, colorService),
|
|
151
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21),
|
|
152
|
+
},
|
|
153
|
+
surfaceVariant: {
|
|
154
|
+
palette: (s) => s.getPalette('neutralVariant'),
|
|
155
|
+
tone: (s) => (s.isDark ? 30 : 90),
|
|
156
|
+
isBackground: true,
|
|
157
|
+
},
|
|
158
|
+
onSurfaceVariant: {
|
|
159
|
+
palette: (s) => s.getPalette('neutralVariant'),
|
|
160
|
+
tone: (s) => (s.isDark ? 80 : 30),
|
|
161
|
+
background: (s) => highestSurface(s, colorService),
|
|
162
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11),
|
|
163
|
+
},
|
|
164
|
+
inverseSurface: {
|
|
165
|
+
palette: (s) => s.getPalette('neutral'),
|
|
166
|
+
tone: (s) => (s.isDark ? 90 : 20),
|
|
167
|
+
},
|
|
168
|
+
inverseOnSurface: {
|
|
169
|
+
palette: (s) => s.getPalette('neutral'),
|
|
170
|
+
tone: (s) => (s.isDark ? 20 : 95),
|
|
171
|
+
background: (s) =>
|
|
172
|
+
colorService.getColor('inverseSurface').getDynamicColor(),
|
|
173
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21),
|
|
174
|
+
},
|
|
175
|
+
outline: {
|
|
176
|
+
palette: (s) => s.getPalette('neutralVariant'),
|
|
177
|
+
tone: (s) => (s.isDark ? 60 : 50),
|
|
178
|
+
background: (s) => highestSurface(s, colorService),
|
|
179
|
+
contrastCurve: new ContrastCurve(1.5, 3, 4.5, 7),
|
|
180
|
+
},
|
|
181
|
+
outlineVariant: {
|
|
182
|
+
palette: (s) => s.getPalette('neutralVariant'),
|
|
183
|
+
tone: (s) => (s.isDark ? 30 : 80),
|
|
184
|
+
background: (s) => highestSurface(s, colorService),
|
|
185
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
186
|
+
},
|
|
187
|
+
shadow: {
|
|
188
|
+
palette: (s) => s.getPalette('neutral'),
|
|
189
|
+
tone: (s) => 0,
|
|
190
|
+
},
|
|
191
|
+
scrim: {
|
|
192
|
+
palette: (s) => s.getPalette('neutral'),
|
|
193
|
+
tone: (s) => 0,
|
|
194
|
+
},
|
|
195
|
+
surfaceTint: {
|
|
196
|
+
palette: (s) => s.getPalette('neutral'),
|
|
197
|
+
tone: (s) => (s.isDark ? 80 : 40),
|
|
198
|
+
isBackground: true,
|
|
199
|
+
},
|
|
200
|
+
secondaryContainer: {
|
|
201
|
+
tone: (s) => {
|
|
202
|
+
const initialTone = s.isDark ? 30 : 90;
|
|
203
|
+
return findDesiredChromaByTone(
|
|
204
|
+
s.getPalette('secondary').hue,
|
|
205
|
+
s.getPalette('secondary').chroma,
|
|
206
|
+
initialTone,
|
|
207
|
+
!s.isDark
|
|
208
|
+
);
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
onSecondaryContainer: {
|
|
212
|
+
tone: (s) => {
|
|
213
|
+
return DynamicColor.foregroundTone(
|
|
214
|
+
colorService.getColor('secondaryContainer').getDynamicColor().tone(s),
|
|
215
|
+
4.5
|
|
216
|
+
);
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
tertiaryContainer: {
|
|
220
|
+
palette: (s) => s.getPalette('tertiary'),
|
|
221
|
+
tone: (s) => {
|
|
222
|
+
const proposedHct = s
|
|
223
|
+
.getPalette('tertiary')
|
|
224
|
+
.getHct(s.sourceColorHct.tone);
|
|
225
|
+
return DislikeAnalyzer.fixIfDisliked(proposedHct).tone;
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
onTertiaryContainer: {
|
|
229
|
+
palette: (s) => s.getPalette('tertiary'),
|
|
230
|
+
tone: (s) => {
|
|
231
|
+
return DynamicColor.foregroundTone(
|
|
232
|
+
colorService.getColor('tertiaryContainer').getDynamicColor().tone(s),
|
|
233
|
+
4.5
|
|
234
|
+
);
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
error: {
|
|
238
|
+
palette: (s) => s.getPalette('error'),
|
|
239
|
+
tone: (s) => (s.isDark ? 80 : 40),
|
|
240
|
+
isBackground: true,
|
|
241
|
+
background: (s) => highestSurface(s, colorService),
|
|
242
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11),
|
|
243
|
+
toneDeltaPair: (s) =>
|
|
244
|
+
new ToneDeltaPair(
|
|
245
|
+
colorService.getColor('errorContainer').getDynamicColor(),
|
|
246
|
+
colorService.getColor('error').getDynamicColor(),
|
|
247
|
+
15,
|
|
248
|
+
'nearer',
|
|
249
|
+
false
|
|
250
|
+
),
|
|
251
|
+
},
|
|
252
|
+
onError: {
|
|
253
|
+
palette: (s) => s.getPalette('error'),
|
|
254
|
+
tone: (s) => (s.isDark ? 20 : 100),
|
|
255
|
+
background: (s) => colorService.getColor('error').getDynamicColor(),
|
|
256
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21),
|
|
257
|
+
},
|
|
258
|
+
errorContainer: {
|
|
259
|
+
palette: (s) => s.getPalette('error'),
|
|
260
|
+
tone: (s) => (s.isDark ? 30 : 90),
|
|
261
|
+
isBackground: true,
|
|
262
|
+
background: (s) => highestSurface(s, colorService),
|
|
263
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
264
|
+
toneDeltaPair: (s) =>
|
|
265
|
+
new ToneDeltaPair(
|
|
266
|
+
colorService.getColor('errorContainer').getDynamicColor(),
|
|
267
|
+
colorService.getColor('error').getDynamicColor(),
|
|
268
|
+
15,
|
|
269
|
+
'nearer',
|
|
270
|
+
false
|
|
271
|
+
),
|
|
272
|
+
},
|
|
273
|
+
onErrorContainer: {
|
|
274
|
+
palette: (s) => s.getPalette('error'),
|
|
275
|
+
tone: (s) => (s.isDark ? 90 : 10),
|
|
276
|
+
background: (s) =>
|
|
277
|
+
colorService.getColor('errorContainer').getDynamicColor(),
|
|
278
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21),
|
|
233
279
|
},
|
|
234
|
-
},
|
|
235
|
-
error: {
|
|
236
|
-
palette: (s) => s.getPalette('error'),
|
|
237
|
-
tone: (s) => (s.isDark ? 80 : 40),
|
|
238
|
-
isBackground: true,
|
|
239
|
-
background: (s) => highestSurface(s, colorManagerService),
|
|
240
|
-
contrastCurve: new ContrastCurve(3, 4.5, 7, 11),
|
|
241
|
-
toneDeltaPair: (s) =>
|
|
242
|
-
new ToneDeltaPair(
|
|
243
|
-
colorManagerService.get('errorContainer').getDynamicColor(),
|
|
244
|
-
colorManagerService.get('error').getDynamicColor(),
|
|
245
|
-
15,
|
|
246
|
-
'nearer',
|
|
247
|
-
false
|
|
248
|
-
),
|
|
249
|
-
},
|
|
250
|
-
onError: {
|
|
251
|
-
palette: (s) => s.getPalette('error'),
|
|
252
|
-
tone: (s) => (s.isDark ? 20 : 100),
|
|
253
|
-
background: (s) => colorManagerService.get('error').getDynamicColor(),
|
|
254
|
-
contrastCurve: new ContrastCurve(4.5, 7, 11, 21),
|
|
255
|
-
},
|
|
256
|
-
errorContainer: {
|
|
257
|
-
palette: (s) => s.getPalette('error'),
|
|
258
|
-
tone: (s) => (s.isDark ? 30 : 90),
|
|
259
|
-
isBackground: true,
|
|
260
|
-
background: (s) => highestSurface(s, colorManagerService),
|
|
261
|
-
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
262
|
-
toneDeltaPair: (s) =>
|
|
263
|
-
new ToneDeltaPair(
|
|
264
|
-
colorManagerService.get('errorContainer').getDynamicColor(),
|
|
265
|
-
colorManagerService.get('error').getDynamicColor(),
|
|
266
|
-
15,
|
|
267
|
-
'nearer',
|
|
268
|
-
false
|
|
269
|
-
),
|
|
270
|
-
},
|
|
271
|
-
onErrorContainer: {
|
|
272
|
-
palette: (s) => s.getPalette('error'),
|
|
273
|
-
tone: (s) => (s.isDark ? 90 : 10),
|
|
274
|
-
background: (s) =>
|
|
275
|
-
colorManagerService.get('errorContainer').getDynamicColor(),
|
|
276
|
-
contrastCurve: new ContrastCurve(4.5, 7, 11, 21),
|
|
277
|
-
},
|
|
278
280
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
281
|
+
onTertiaryFixed: {
|
|
282
|
+
palette: (s) => s.getPalette('tertiary'),
|
|
283
|
+
tone: (s) => 10.0,
|
|
284
|
+
background: (s) =>
|
|
285
|
+
colorService.getColor('tertiaryFixedDim').getDynamicColor(),
|
|
286
|
+
secondBackground: (s) =>
|
|
287
|
+
colorService.getColor('tertiaryFixed').getDynamicColor(),
|
|
288
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21),
|
|
289
|
+
},
|
|
290
|
+
onTertiaryFixedVariant: {
|
|
291
|
+
palette: (s) => s.getPalette('tertiary'),
|
|
292
|
+
tone: (s) => 30.0,
|
|
293
|
+
background: (s) =>
|
|
294
|
+
colorService.getColor('tertiaryFixedDim').getDynamicColor(),
|
|
295
|
+
secondBackground: (s) =>
|
|
296
|
+
colorService.getColor('tertiaryFixed').getDynamicColor(),
|
|
297
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11),
|
|
298
|
+
},
|
|
296
299
|
},
|
|
297
300
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './default-color.model';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { SchemeEntity } from '../theme/entities/scheme.entity';
|
|
1
|
+
import { ContrastCurve, ToneDeltaPair } from '../../material-color-utilities';
|
|
2
|
+
import { DynamicColor } from '../../material-color-utilities/dynamic_color';
|
|
3
|
+
import { SchemeEntity } from '../../theme/entities/scheme.entity';
|
|
5
4
|
|
|
6
|
-
import { ColorEntity, ColorOptions } from '
|
|
7
|
-
import { SchemeService } from '
|
|
8
|
-
import { DynamicColorKey } from '
|
|
5
|
+
import { ColorEntity, ColorOptions } from '../entities/color.entity';
|
|
6
|
+
import { SchemeService } from '../../theme/services/scheme.service';
|
|
7
|
+
import { DynamicColorKey } from '../models/default-color.model';
|
|
8
|
+
import { ColorService } from './color.service';
|
|
9
9
|
|
|
10
10
|
function capitalizeFirstLetter(string: string) {
|
|
11
11
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
@@ -13,17 +13,25 @@ function capitalizeFirstLetter(string: string) {
|
|
|
13
13
|
|
|
14
14
|
export const highestSurface = (
|
|
15
15
|
s: SchemeEntity,
|
|
16
|
-
|
|
16
|
+
colorService: ColorManagerService | ColorService
|
|
17
17
|
): DynamicColor => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
if (colorService instanceof ColorService) {
|
|
19
|
+
return s.isDark
|
|
20
|
+
? colorService.getColor('surfaceBright').getDynamicColor()
|
|
21
|
+
: colorService.getColor('surfaceDim').getDynamicColor();
|
|
22
|
+
} else {
|
|
23
|
+
return s.isDark
|
|
24
|
+
? colorService.get('surfaceBright').getDynamicColor()
|
|
25
|
+
: colorService.get('surfaceDim').getDynamicColor();
|
|
26
|
+
}
|
|
21
27
|
};
|
|
22
28
|
|
|
23
|
-
@Injectable()
|
|
24
29
|
export class ColorManagerService {
|
|
25
30
|
private colorMap = new Map<string, ColorEntity>();
|
|
26
|
-
|
|
31
|
+
private readonly schemeService: SchemeService;
|
|
32
|
+
constructor({ schemeService }: { schemeService: SchemeService }) {
|
|
33
|
+
this.schemeService = schemeService;
|
|
34
|
+
}
|
|
27
35
|
|
|
28
36
|
createOrUpdate(key: string, args: Partial<ColorOptions>): ColorEntity {
|
|
29
37
|
let colorEntity = this.colorMap.get(key);
|
|
@@ -91,7 +99,7 @@ export class ColorManagerService {
|
|
|
91
99
|
new ToneDeltaPair(
|
|
92
100
|
this.get(colorKeyContainer).getDynamicColor(),
|
|
93
101
|
this.get(colorKey).getDynamicColor(),
|
|
94
|
-
|
|
102
|
+
10,
|
|
95
103
|
'nearer',
|
|
96
104
|
false
|
|
97
105
|
),
|
|
@@ -116,7 +124,7 @@ export class ColorManagerService {
|
|
|
116
124
|
new ToneDeltaPair(
|
|
117
125
|
this.get(colorKeyContainer).getDynamicColor(),
|
|
118
126
|
this.get(colorKey).getDynamicColor(),
|
|
119
|
-
|
|
127
|
+
10,
|
|
120
128
|
'nearer',
|
|
121
129
|
false
|
|
122
130
|
),
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { ColorManagerService } from './color-manager.service';
|
|
2
|
+
import { ColorInterface } from '../color.interface';
|
|
3
|
+
import { ColorEntity, ColorOptions } from '../entities';
|
|
4
|
+
|
|
5
|
+
type AddColors = {
|
|
6
|
+
colors?: Record<string, Partial<ColorOptions>>;
|
|
7
|
+
fromPalettes?: string[] | string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type AddColorsOptions =
|
|
11
|
+
| AddColors
|
|
12
|
+
| ((colorService: ColorService) => AddColors);
|
|
13
|
+
|
|
14
|
+
export class ColorService implements ColorInterface {
|
|
15
|
+
private readonly colorManagerService: ColorManagerService;
|
|
16
|
+
constructor({
|
|
17
|
+
colorManagerService,
|
|
18
|
+
}: {
|
|
19
|
+
colorManagerService: ColorManagerService;
|
|
20
|
+
}) {
|
|
21
|
+
this.colorManagerService = colorManagerService;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
getColors() {
|
|
25
|
+
return this.colorManagerService.getAll();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// getColors() {
|
|
29
|
+
// const colors: Record<string, string> = {};
|
|
30
|
+
//
|
|
31
|
+
// for (const [key, value] of this.colorManagerService.getAll()) {
|
|
32
|
+
// colors[key] = hexFromArgb(value.getArgb(this.schemeService.get()));
|
|
33
|
+
// }
|
|
34
|
+
//
|
|
35
|
+
// return colors;
|
|
36
|
+
// }
|
|
37
|
+
|
|
38
|
+
addColor(key: string, color: Partial<ColorOptions>): ColorEntity {
|
|
39
|
+
return this.colorManagerService.createOrUpdate(key, color);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
addColors(args: AddColorsOptions | AddColorsOptions[]) {
|
|
43
|
+
const colorsEntity: ColorEntity[] = [];
|
|
44
|
+
if (!Array.isArray(args)) args = [args];
|
|
45
|
+
args.forEach((args) => {
|
|
46
|
+
if (typeof args === 'function') {
|
|
47
|
+
args = args(this);
|
|
48
|
+
}
|
|
49
|
+
if (args.fromPalettes) {
|
|
50
|
+
if (!Array.isArray(args.fromPalettes))
|
|
51
|
+
args.fromPalettes = [args.fromPalettes];
|
|
52
|
+
args.fromPalettes.map((paletteKey) => {
|
|
53
|
+
this.colorManagerService.addFromPalette(paletteKey);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (args.colors) {
|
|
57
|
+
Object.keys(args.colors).map((key) =>
|
|
58
|
+
this.addColor(key, args.colors![key])
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
getColor(key: string): ColorEntity {
|
|
65
|
+
return this.colorManagerService.get(key);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
removeColor(key: string): boolean {
|
|
69
|
+
return this.colorManagerService.remove(key);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
updateColor(key: string, newColor: Partial<ColorOptions>): ColorEntity {
|
|
73
|
+
return this.colorManagerService.createOrUpdate(key, newColor);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AddColorsOptions } from '../color';
|
|
2
|
+
import { VariantEntity } from '../theme';
|
|
3
|
+
import { PluginAbstract } from '../plugin';
|
|
4
|
+
|
|
5
|
+
export interface ConfigInterface {
|
|
6
|
+
sourceColor: string;
|
|
7
|
+
contrastLevel?: number;
|
|
8
|
+
isDark?: boolean;
|
|
9
|
+
variant?: VariantEntity;
|
|
10
|
+
colors?: AddColorsOptions | AddColorsOptions[];
|
|
11
|
+
useDefaultColors?: boolean;
|
|
12
|
+
palettes?: Record<string, string>;
|
|
13
|
+
plugins?: PluginAbstract<any, any>[];
|
|
14
|
+
}
|