@udixio/theme 2.0.0 → 2.1.1
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/CHANGELOG.md +26 -0
- package/dist/bin.cjs +1 -1
- package/dist/bin.js +1 -1
- package/dist/browser.cjs +3 -2
- package/dist/browser.js +24 -23
- package/dist/color/color.api.d.ts +5 -1
- package/dist/color/color.api.d.ts.map +1 -1
- package/dist/color/color.d.ts +1 -0
- package/dist/color/color.d.ts.map +1 -1
- package/dist/color/color.manager.d.ts +1 -2
- package/dist/color/color.manager.d.ts.map +1 -1
- package/dist/color/default-color.d.ts +5 -1
- package/dist/color/default-color.d.ts.map +1 -1
- package/dist/{font.plugin-DZtMajJV.js → font.plugin-B2IbI3Qs.js} +1 -1
- package/dist/{font.plugin-BZ-TTeTo.cjs → font.plugin-Czq_-M7T.cjs} +1 -1
- package/dist/{load-from-path-DZ35yiXK.cjs → load-from-path-Bvj18-eg.cjs} +2 -2
- package/dist/{load-from-path-Dobe0beV.js → load-from-path-CjLV8qqN.js} +1 -1
- package/dist/loader/loader.d.ts.map +1 -1
- package/dist/{loader-C8LnOoqg.cjs → loader-DuLiOKuW.cjs} +1171 -463
- package/dist/{loader-BS_Esfwg.js → loader-Dy9GSe3X.js} +1191 -483
- package/dist/node.cjs +4 -3
- package/dist/node.js +26 -25
- package/dist/palette/palette.d.ts.map +1 -1
- package/dist/variant/variant.d.ts +2 -0
- package/dist/variant/variant.d.ts.map +1 -1
- package/dist/variant/variants/expressive.variant.d.ts.map +1 -1
- package/dist/variant/variants/index.d.ts +1 -1
- package/dist/variant/variants/neutral.variant.d.ts.map +1 -1
- package/dist/variant/variants/tonal-spot.variant.d.ts.map +1 -1
- package/dist/variant/variants/udixio.variant.d.ts +3 -0
- package/dist/variant/variants/udixio.variant.d.ts.map +1 -0
- package/dist/variant/variants/vibrant.variant.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/app.module.ts +1 -1
- package/src/color/color.api.ts +24 -3
- package/src/color/color.manager.ts +4 -16
- package/src/color/color.module.ts +2 -2
- package/src/color/color.ts +4 -0
- package/src/color/default-color.ts +34 -68
- package/src/context/context.module.ts +1 -1
- package/src/loader/loader.ts +0 -4
- package/src/palette/palette.module.ts +2 -2
- package/src/palette/palette.ts +1 -2
- package/src/plugin/plugin.module.ts +1 -1
- package/src/variant/variant.ts +3 -0
- package/src/variant/variants/expressive.variant.ts +2 -0
- package/src/variant/variants/index.ts +2 -2
- package/src/variant/variants/neutral.variant.ts +2 -0
- package/src/variant/variants/tonal-spot.variant.ts +2 -0
- package/src/variant/variants/udixio.variant.ts +846 -0
- package/src/variant/variants/vibrant.variant.ts +2 -0
- package/dist/variant/variants/fidelity.variant.d.ts +0 -3
- package/dist/variant/variants/fidelity.variant.d.ts.map +0 -1
- package/src/variant/variants/fidelity.variant.ts +0 -46
package/dist/node.cjs
CHANGED
|
@@ -22,9 +22,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
22
|
mod
|
|
23
23
|
));
|
|
24
24
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
25
|
-
const loader = require("./loader-
|
|
26
|
-
const font_plugin = require("./font.plugin-
|
|
27
|
-
const loadFromPath = require("./load-from-path-
|
|
25
|
+
const loader = require("./loader-DuLiOKuW.cjs");
|
|
26
|
+
const font_plugin = require("./font.plugin-Czq_-M7T.cjs");
|
|
27
|
+
const loadFromPath = require("./load-from-path-Bvj18-eg.cjs");
|
|
28
28
|
let unpluginInstance = null;
|
|
29
29
|
const createUnpluginTheme = async () => {
|
|
30
30
|
if (unpluginInstance) {
|
|
@@ -169,6 +169,7 @@ exports.PluginModule = loader.PluginModule;
|
|
|
169
169
|
exports.Variant = loader.Variant;
|
|
170
170
|
exports.Variants = loader.Variants;
|
|
171
171
|
exports.bootstrap = loader.bootstrap;
|
|
172
|
+
exports.capitalizeFirstLetter = loader.capitalizeFirstLetter;
|
|
172
173
|
exports.defaultColors = loader.defaultColors;
|
|
173
174
|
exports.expressiveVariant = loader.expressiveVariant;
|
|
174
175
|
exports.getInitialToneFromBackground = loader.getInitialToneFromBackground;
|
package/dist/node.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { A, a, b,
|
|
2
|
-
import { F as F2, b as b2, P as P2, a as a2, d as d2 } from "./font.plugin-
|
|
3
|
-
import { l as loadFromPath } from "./load-from-path-
|
|
4
|
-
import { r as r2 } from "./load-from-path-
|
|
1
|
+
import { A, a, b, h, i, C, j, k, e, f, o, n, q, D, P, r, s, v, u, V, z, c, d, m, F, g, w, x, l, p, G, B, t, y, E } from "./loader-Dy9GSe3X.js";
|
|
2
|
+
import { F as F2, b as b2, P as P2, a as a2, d as d2 } from "./font.plugin-B2IbI3Qs.js";
|
|
3
|
+
import { l as loadFromPath } from "./load-from-path-CjLV8qqN.js";
|
|
4
|
+
import { r as r2 } from "./load-from-path-CjLV8qqN.js";
|
|
5
5
|
let unpluginInstance = null;
|
|
6
6
|
const createUnpluginTheme = async () => {
|
|
7
7
|
if (unpluginInstance) {
|
|
@@ -128,47 +128,48 @@ export {
|
|
|
128
128
|
A as API,
|
|
129
129
|
a as AppContainer,
|
|
130
130
|
b as AppModule,
|
|
131
|
-
|
|
131
|
+
h as Color,
|
|
132
132
|
i as ColorAlias,
|
|
133
133
|
C as ColorApi,
|
|
134
134
|
j as ColorFromHex,
|
|
135
135
|
k as ColorFromPalette,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
136
|
+
e as ColorManager,
|
|
137
|
+
f as ColorModule,
|
|
138
|
+
o as Context,
|
|
139
|
+
n as ContextModule,
|
|
140
|
+
q as ContrastCurve,
|
|
141
141
|
D as DynamicColor,
|
|
142
142
|
F2 as FontFamily,
|
|
143
143
|
b2 as FontPlugin,
|
|
144
144
|
P as Palette,
|
|
145
|
-
|
|
146
|
-
|
|
145
|
+
r as PaletteApi,
|
|
146
|
+
s as PaletteModule,
|
|
147
147
|
P2 as PluginAbstract,
|
|
148
|
-
|
|
148
|
+
v as PluginApi,
|
|
149
149
|
a2 as PluginImplAbstract,
|
|
150
|
-
|
|
150
|
+
u as PluginModule,
|
|
151
151
|
V as Variant,
|
|
152
|
-
|
|
152
|
+
z as Variants,
|
|
153
153
|
c as bootstrap,
|
|
154
|
-
|
|
154
|
+
d as capitalizeFirstLetter,
|
|
155
|
+
m as defaultColors,
|
|
155
156
|
d2 as defineConfig,
|
|
156
157
|
esbuildPlugin,
|
|
157
|
-
|
|
158
|
+
F as expressiveVariant,
|
|
158
159
|
g as getInitialToneFromBackground,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
160
|
+
w as getPiecewiseHue,
|
|
161
|
+
x as getRotatedHue,
|
|
162
|
+
l as highestSurface,
|
|
162
163
|
loadFromPath,
|
|
163
|
-
|
|
164
|
-
|
|
164
|
+
p as loader,
|
|
165
|
+
G as neutralVariant,
|
|
165
166
|
r2 as resolveConfig,
|
|
166
167
|
rollupPlugin,
|
|
167
|
-
|
|
168
|
+
B as tonalSpotVariant,
|
|
168
169
|
t as toneDeltaPair,
|
|
169
170
|
unpluginUdixioTheme,
|
|
170
|
-
|
|
171
|
-
|
|
171
|
+
y as variant,
|
|
172
|
+
E as vibrantVariant,
|
|
172
173
|
vitePlugin,
|
|
173
174
|
webpackPlugin
|
|
174
175
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"palette.d.ts","sourceRoot":"","sources":["../../src/palette/palette.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAEtD,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK;IAClD,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,qBAAa,OAAO;IAQT,IAAI,EAAE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AAC,MAAM,OAAO,CAAC,EAAE,GAAG,IAAI;IA6B9C,OAAO,CAAC,UAAU;IAMlB;;;OAGG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAmB1B;;;OAGG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG;IAIzB,IAAI,GAAG,IAAI,MAAM,CAMhB;IACD,IAAI,MAAM,IAAI,MAAM,CAMnB;IAED,OAAO,CAAC,WAAW;CAkBpB"}
|
|
@@ -12,12 +12,14 @@ export interface VariantOptions {
|
|
|
12
12
|
hue: number;
|
|
13
13
|
chroma: number;
|
|
14
14
|
};
|
|
15
|
+
colorsFromCustomPalette?: (key: string) => AddColorsOptions;
|
|
15
16
|
colors?: AddColorsOptions;
|
|
16
17
|
}
|
|
17
18
|
export declare class Variant {
|
|
18
19
|
private options;
|
|
19
20
|
_palettes?: Record<string, Palette>;
|
|
20
21
|
readonly customPalettes: VariantOptions['customPalettes'];
|
|
22
|
+
readonly colorsFromCustomPalette?: (key: string) => AddColorsOptions;
|
|
21
23
|
readonly colors: AddColorsOptions;
|
|
22
24
|
readonly name: string;
|
|
23
25
|
private context?;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variant.d.ts","sourceRoot":"","sources":["../../src/variant/variant.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,eAAO,MAAM,eAAe,GAC1B,aAAa,GAAG,EAChB,gBAAgB,MAAM,EAAE,EACxB,MAAM,MAAM,EAAE,KACb,MASF,CAAC;AAEF,eAAO,MAAM,aAAa,GACxB,aAAa,GAAG,EACh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AE,gBAAgB,CAAC;CAC3B;AAED,qBAAa,OAAO;IAQN,OAAO,CAAC,OAAO;IAPpB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3C,SAAgB,cAAc,EAAE,cAAc,CAAC,gBAAgB,CAAC,CAAC;IACjE,SAAgB,uBAAuB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,gBAAgB,CAAC;IAC5E,SAAgB,MAAM,EAAE,gBAAgB,CAAC;IACzC,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,OAAO,CAAC,OAAO,CAAC,CAAU;gBAEN,OAAO,EAAE,cAAc;IAO3C,IAAI,QAAQ,4BAKX;IAED,IAAI,CAAC,OAAO,EAAE,OAAO;CAWtB;AAED,eAAO,MAAM,OAAO,GAAI,MAAM,cAAc,YAAsB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expressive.variant.d.ts","sourceRoot":"","sources":["../../../src/variant/variants/expressive.variant.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"expressive.variant.d.ts","sourceRoot":"","sources":["../../../src/variant/variants/expressive.variant.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,iBAAiB,sBA+D5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"neutral.variant.d.ts","sourceRoot":"","sources":["../../../src/variant/variants/neutral.variant.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"neutral.variant.d.ts","sourceRoot":"","sources":["../../../src/variant/variants/neutral.variant.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,OAAO,EAAE,MAAM,YAAY,CAAC;AAK9E,eAAO,MAAM,cAAc,EAAE,OAyC3B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tonal-spot.variant.d.ts","sourceRoot":"","sources":["../../../src/variant/variants/tonal-spot.variant.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"tonal-spot.variant.d.ts","sourceRoot":"","sources":["../../../src/variant/variants/tonal-spot.variant.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,OAAO,EAAE,MAAM,YAAY,CAAC;AAI9E,eAAO,MAAM,gBAAgB,EAAE,OAgC7B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"udixio.variant.d.ts","sourceRoot":"","sources":["../../../src/variant/variants/udixio.variant.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,OAAO,EAAE,MAAM,YAAY,CAAC;AAuD9E,eAAO,MAAM,aAAa,EAAE,OAsxB1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vibrant.variant.d.ts","sourceRoot":"","sources":["../../../src/variant/variants/vibrant.variant.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"vibrant.variant.d.ts","sourceRoot":"","sources":["../../../src/variant/variants/vibrant.variant.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,OAAO,EAAE,MAAM,YAAY,CAAC;AAiB9E,eAAO,MAAM,cAAc,EAAE,OAuD3B,CAAC"}
|
package/package.json
CHANGED
package/src/app.module.ts
CHANGED
package/src/color/color.api.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Color, ColorOptions } from './color';
|
|
2
|
-
import { ColorManager
|
|
2
|
+
import { ColorManager } from './color.manager';
|
|
3
3
|
import { DynamicColorKey, getCurve, tMaxC, tMinC } from './color.utils';
|
|
4
4
|
import { API } from '../API';
|
|
5
5
|
import { toneDeltaPair } from '../material-color-utilities';
|
|
6
|
+
import { Context } from 'src/context';
|
|
7
|
+
import { highestSurface } from './default-color';
|
|
6
8
|
|
|
7
|
-
function capitalizeFirstLetter(string: string) {
|
|
9
|
+
export function capitalizeFirstLetter(string: string) {
|
|
8
10
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
9
11
|
}
|
|
10
12
|
|
|
@@ -14,10 +16,25 @@ export type AddColorsOptions =
|
|
|
14
16
|
|
|
15
17
|
export class ColorApi {
|
|
16
18
|
private readonly colorManager: ColorManager;
|
|
19
|
+
private readonly context: Context;
|
|
17
20
|
public api?: API;
|
|
18
21
|
|
|
19
|
-
constructor({
|
|
22
|
+
constructor({
|
|
23
|
+
colorManager,
|
|
24
|
+
context,
|
|
25
|
+
}: {
|
|
26
|
+
colorManager: ColorManager;
|
|
27
|
+
context: Context;
|
|
28
|
+
}) {
|
|
29
|
+
this.context = context;
|
|
20
30
|
this.colorManager = colorManager;
|
|
31
|
+
|
|
32
|
+
this.context.onUpdate((changed) => {
|
|
33
|
+
if (changed.includes('variant')) {
|
|
34
|
+
this.colorManager.clear();
|
|
35
|
+
this.addColors(this.context.variant.colors);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
21
38
|
}
|
|
22
39
|
|
|
23
40
|
getAll() {
|
|
@@ -57,6 +74,10 @@ export class ColorApi {
|
|
|
57
74
|
}
|
|
58
75
|
|
|
59
76
|
addFromCustomPalette(key: string): void {
|
|
77
|
+
if (this.context.variant.colorsFromCustomPalette) {
|
|
78
|
+
return this.addColors(this.context.variant.colorsFromCustomPalette(key));
|
|
79
|
+
}
|
|
80
|
+
|
|
60
81
|
const colorKey = key as DynamicColorKey;
|
|
61
82
|
const colorDimKey = (colorKey + 'Dim') as DynamicColorKey;
|
|
62
83
|
const ColorKey = capitalizeFirstLetter(key);
|
|
@@ -5,24 +5,8 @@ import {
|
|
|
5
5
|
ColorFromPalette,
|
|
6
6
|
ColorOptions,
|
|
7
7
|
} from './color';
|
|
8
|
-
import { ColorApi } from './color.api';
|
|
9
8
|
import { Context } from '../context';
|
|
10
9
|
|
|
11
|
-
export const highestSurface = (
|
|
12
|
-
context: Context,
|
|
13
|
-
colorService: ColorManager | ColorApi,
|
|
14
|
-
): Color => {
|
|
15
|
-
if (colorService instanceof ColorApi) {
|
|
16
|
-
return context.isDark
|
|
17
|
-
? colorService.get('surfaceBright')
|
|
18
|
-
: colorService.get('surfaceDim');
|
|
19
|
-
} else {
|
|
20
|
-
return context.isDark
|
|
21
|
-
? colorService.get('surfaceBright')
|
|
22
|
-
: colorService.get('surfaceDim');
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
|
|
26
10
|
export class ColorManager {
|
|
27
11
|
private colorMap = new Map<string, Color>();
|
|
28
12
|
private readonly context: Context;
|
|
@@ -57,6 +41,10 @@ export class ColorManager {
|
|
|
57
41
|
return this.colorMap.delete(key);
|
|
58
42
|
}
|
|
59
43
|
|
|
44
|
+
public clear() {
|
|
45
|
+
this.colorMap.clear();
|
|
46
|
+
}
|
|
47
|
+
|
|
60
48
|
public get(key: string): Color {
|
|
61
49
|
const colorEntity = this.colorMap.get(key);
|
|
62
50
|
if (colorEntity) {
|
|
@@ -4,6 +4,6 @@ import { asClass } from 'awilix';
|
|
|
4
4
|
import { Module } from '../app.container';
|
|
5
5
|
|
|
6
6
|
export const ColorModule: Module = {
|
|
7
|
-
colorManager: asClass(ColorManager).
|
|
8
|
-
colorApi: asClass(ColorApi).
|
|
7
|
+
colorManager: asClass(ColorManager).scoped(),
|
|
8
|
+
colorApi: asClass(ColorApi).scoped(),
|
|
9
9
|
};
|
package/src/color/color.ts
CHANGED
|
@@ -35,6 +35,10 @@ export function getInitialToneFromBackground(background?: Color): number {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export abstract class Color {
|
|
38
|
+
static maxChroma(hue: number, tone = 50): number {
|
|
39
|
+
return Hct.from(hue, 200, tone).chroma;
|
|
40
|
+
}
|
|
41
|
+
|
|
38
42
|
abstract getHct(): Hct;
|
|
39
43
|
|
|
40
44
|
protected constructor(public readonly name: string) {}
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import { toneDeltaPair } from '../material-color-utilities';
|
|
2
|
-
import {
|
|
3
|
-
import { AddColorsOptions } from './color.api';
|
|
2
|
+
import { ColorManager } from './color.manager';
|
|
3
|
+
import { AddColorsOptions, ColorApi } from './color.api';
|
|
4
4
|
import { Hct } from '../material-color-utilities/htc';
|
|
5
|
-
import {
|
|
5
|
+
import { Color, getInitialToneFromBackground } from './color';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
DynamicColorKey,
|
|
10
|
-
getCurve,
|
|
11
|
-
tMaxC,
|
|
12
|
-
tMinC,
|
|
13
|
-
} from './color.utils';
|
|
14
|
-
import { Contrast } from '@material/material-color-utilities';
|
|
7
|
+
import { DynamicColorKey, getCurve, tMaxC, tMinC } from './color.utils';
|
|
8
|
+
import { Context } from '../context';
|
|
15
9
|
|
|
16
|
-
const
|
|
17
|
-
|
|
10
|
+
export const highestSurface = (
|
|
11
|
+
context: Context,
|
|
12
|
+
colorService: ColorManager | ColorApi,
|
|
13
|
+
): Color => {
|
|
14
|
+
if (colorService instanceof ColorApi) {
|
|
15
|
+
return context.isDark
|
|
16
|
+
? colorService.get('surfaceBright')
|
|
17
|
+
: colorService.get('surfaceDim');
|
|
18
|
+
} else {
|
|
19
|
+
return context.isDark
|
|
20
|
+
? colorService.get('surfaceBright')
|
|
21
|
+
: colorService.get('surfaceDim');
|
|
22
|
+
}
|
|
18
23
|
};
|
|
19
24
|
|
|
20
25
|
export const defaultColors: AddColorsOptions = ({
|
|
@@ -36,9 +41,6 @@ export const defaultColors: AddColorsOptions = ({
|
|
|
36
41
|
if (c.isDark) {
|
|
37
42
|
return 4;
|
|
38
43
|
} else {
|
|
39
|
-
if (c.variant.name == 'fidelity') {
|
|
40
|
-
return 100;
|
|
41
|
-
}
|
|
42
44
|
if (Hct.isYellow(palettes.get('neutral').hue)) {
|
|
43
45
|
return 99;
|
|
44
46
|
} else if (c.variant.name === 'vibrant') {
|
|
@@ -357,8 +359,6 @@ export const defaultColors: AddColorsOptions = ({
|
|
|
357
359
|
? 88
|
|
358
360
|
: 98,
|
|
359
361
|
);
|
|
360
|
-
} else if (c.variant.name == 'fidelity') {
|
|
361
|
-
return c.sourceColor.tone;
|
|
362
362
|
} else {
|
|
363
363
|
return tMaxC(
|
|
364
364
|
palettes.get('primary'),
|
|
@@ -371,31 +371,14 @@ export const defaultColors: AddColorsOptions = ({
|
|
|
371
371
|
background: () => highestSurface(c, colors),
|
|
372
372
|
contrastCurve: () => getCurve(4.5),
|
|
373
373
|
adjustTone: () =>
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
surfaceTone,
|
|
383
|
-
selfTone,
|
|
384
|
-
3,
|
|
385
|
-
);
|
|
386
|
-
const inverseT = inverseTone(primaryTone);
|
|
387
|
-
selfTone = selfTone + (inverseT - selfTone) * ratio;
|
|
388
|
-
}
|
|
389
|
-
return selfTone;
|
|
390
|
-
}
|
|
391
|
-
: toneDeltaPair(
|
|
392
|
-
colors.get('primaryContainer'),
|
|
393
|
-
colors.get('primary'),
|
|
394
|
-
5,
|
|
395
|
-
'relative_lighter',
|
|
396
|
-
true,
|
|
397
|
-
'farther',
|
|
398
|
-
),
|
|
374
|
+
toneDeltaPair(
|
|
375
|
+
colors.get('primaryContainer'),
|
|
376
|
+
colors.get('primary'),
|
|
377
|
+
5,
|
|
378
|
+
'relative_lighter',
|
|
379
|
+
true,
|
|
380
|
+
'farther',
|
|
381
|
+
),
|
|
399
382
|
},
|
|
400
383
|
primaryDim: {
|
|
401
384
|
palette: () => palettes.get('primary'),
|
|
@@ -444,34 +427,17 @@ export const defaultColors: AddColorsOptions = ({
|
|
|
444
427
|
Hct.isCyan(palettes.get('primary').hue) ? 88 : 90,
|
|
445
428
|
);
|
|
446
429
|
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
: tMaxC(
|
|
456
|
-
palettes.get('primary'),
|
|
457
|
-
66,
|
|
458
|
-
Hct.isCyan(palettes.get('primary').hue) ? 88 : 93,
|
|
459
|
-
);
|
|
460
|
-
}
|
|
430
|
+
// VIBRANT
|
|
431
|
+
return c.isDark
|
|
432
|
+
? tMinC(palettes.get('primary'), 66, 93)
|
|
433
|
+
: tMaxC(
|
|
434
|
+
palettes.get('primary'),
|
|
435
|
+
66,
|
|
436
|
+
Hct.isCyan(palettes.get('primary').hue) ? 88 : 93,
|
|
437
|
+
);
|
|
461
438
|
},
|
|
462
439
|
isBackground: true,
|
|
463
440
|
background: () => highestSurface(c, colors),
|
|
464
|
-
adjustTone: () =>
|
|
465
|
-
c.variant.name == 'fidelity'
|
|
466
|
-
? toneDeltaPair(
|
|
467
|
-
colors.get('primary'),
|
|
468
|
-
colors.get('primaryContainer'),
|
|
469
|
-
15,
|
|
470
|
-
'relative_darker',
|
|
471
|
-
true,
|
|
472
|
-
'farther',
|
|
473
|
-
)
|
|
474
|
-
: undefined,
|
|
475
441
|
contrastCurve: () => (c.contrastLevel > 0 ? getCurve(1.5) : undefined),
|
|
476
442
|
},
|
|
477
443
|
onPrimaryContainer: {
|
package/src/loader/loader.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { defaultColors } from '../color';
|
|
2
1
|
import { bootstrap } from '../bootstrap';
|
|
3
2
|
import { ConfigInterface } from '../config';
|
|
4
3
|
import { Variants } from '../variant/variants';
|
|
@@ -23,9 +22,6 @@ export const loader = async (config: ConfigInterface, load = true) => {
|
|
|
23
22
|
sourceColor,
|
|
24
23
|
variant: variant,
|
|
25
24
|
});
|
|
26
|
-
|
|
27
|
-
api.colors.addColors(defaultColors);
|
|
28
|
-
|
|
29
25
|
if (palettes) {
|
|
30
26
|
api.palettes.add(palettes);
|
|
31
27
|
}
|
|
@@ -4,6 +4,6 @@ import { PaletteManager } from './palette.manager';
|
|
|
4
4
|
import { PaletteApi } from './palette.api';
|
|
5
5
|
|
|
6
6
|
export const PaletteModule: Module = {
|
|
7
|
-
paletteApi: asClass(PaletteApi).
|
|
8
|
-
paletteManager: asClass(PaletteManager).
|
|
7
|
+
paletteApi: asClass(PaletteApi).scoped(),
|
|
8
|
+
paletteManager: asClass(PaletteManager).scoped(),
|
|
9
9
|
};
|
package/src/palette/palette.ts
CHANGED
package/src/variant/variant.ts
CHANGED
|
@@ -42,12 +42,14 @@ export interface VariantOptions {
|
|
|
42
42
|
hue: number;
|
|
43
43
|
chroma: number;
|
|
44
44
|
};
|
|
45
|
+
colorsFromCustomPalette?: (key: string) => AddColorsOptions;
|
|
45
46
|
colors?: AddColorsOptions;
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
export class Variant {
|
|
49
50
|
public _palettes?: Record<string, Palette>;
|
|
50
51
|
public readonly customPalettes: VariantOptions['customPalettes'];
|
|
52
|
+
public readonly colorsFromCustomPalette?: (key: string) => AddColorsOptions;
|
|
51
53
|
public readonly colors: AddColorsOptions;
|
|
52
54
|
public readonly name: string;
|
|
53
55
|
private context?: Context;
|
|
@@ -56,6 +58,7 @@ export class Variant {
|
|
|
56
58
|
this.customPalettes = options.customPalettes;
|
|
57
59
|
this.colors = options.colors || {};
|
|
58
60
|
this.name = options.name;
|
|
61
|
+
this.colorsFromCustomPalette = options.colorsFromCustomPalette;
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
get palettes() {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getPiecewiseHue, getRotatedHue, variant } from '../variant';
|
|
2
2
|
import { TonalPalette } from '@material/material-color-utilities';
|
|
3
3
|
import { Hct } from '../../material-color-utilities/htc';
|
|
4
|
+
import { defaultColors } from '../../color';
|
|
4
5
|
|
|
5
6
|
const getExpressiveNeutralHue = (sourceColor: Hct): number => {
|
|
6
7
|
const hue = getRotatedHue(
|
|
@@ -80,4 +81,5 @@ export const expressiveVariant = variant({
|
|
|
80
81
|
),
|
|
81
82
|
isDark ? 16 : 24,
|
|
82
83
|
),
|
|
84
|
+
colors: defaultColors,
|
|
83
85
|
});
|
|
@@ -2,7 +2,7 @@ import { expressiveVariant } from './expressive.variant';
|
|
|
2
2
|
import { neutralVariant } from './neutral.variant';
|
|
3
3
|
import { tonalSpotVariant } from './tonal-spot.variant';
|
|
4
4
|
import { vibrantVariant } from './vibrant.variant';
|
|
5
|
-
import {
|
|
5
|
+
import { udixioVariant } from './udixio.variant';
|
|
6
6
|
|
|
7
7
|
export * from './tonal-spot.variant';
|
|
8
8
|
export * from './vibrant.variant';
|
|
@@ -14,5 +14,5 @@ export const Variants = {
|
|
|
14
14
|
Neutral: neutralVariant,
|
|
15
15
|
TonalSpot: tonalSpotVariant,
|
|
16
16
|
Vibrant: vibrantVariant,
|
|
17
|
-
|
|
17
|
+
Udixio: udixioVariant,
|
|
18
18
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getPiecewiseHue, getRotatedHue, variant, Variant } from '../variant';
|
|
2
2
|
import { TonalPalette } from '@material/material-color-utilities';
|
|
3
3
|
import { Hct } from '../../material-color-utilities/htc';
|
|
4
|
+
import { defaultColors } from '../../color';
|
|
4
5
|
|
|
5
6
|
export const neutralVariant: Variant = variant({
|
|
6
7
|
name: 'neutral',
|
|
@@ -42,4 +43,5 @@ export const neutralVariant: Variant = variant({
|
|
|
42
43
|
colorHct.hue,
|
|
43
44
|
Hct.isBlue(colorHct.hue) ? 6 : 4,
|
|
44
45
|
),
|
|
46
|
+
colors: defaultColors,
|
|
45
47
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getPiecewiseHue, getRotatedHue, variant, Variant } from '../variant';
|
|
2
2
|
import { TonalPalette } from '@material/material-color-utilities';
|
|
3
|
+
import { defaultColors } from '../../color';
|
|
3
4
|
|
|
4
5
|
export const tonalSpotVariant: Variant = variant({
|
|
5
6
|
name: 'tonalSpot',
|
|
@@ -32,4 +33,5 @@ export const tonalSpotVariant: Variant = variant({
|
|
|
32
33
|
},
|
|
33
34
|
customPalettes: (_, colorHct) =>
|
|
34
35
|
TonalPalette.fromHueAndChroma(colorHct.hue, 16),
|
|
36
|
+
colors: defaultColors,
|
|
35
37
|
});
|