@udixio/theme 2.1.16 → 2.1.18
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 +20 -0
- package/dist/bin.cjs +1 -1
- package/dist/bin.js +1 -1
- package/dist/browser.cjs +2 -2
- package/dist/browser.js +2 -2
- package/dist/config/config.interface.d.ts +3 -1
- package/dist/config/config.interface.d.ts.map +1 -1
- package/dist/context/context.d.ts +3 -1
- package/dist/context/context.d.ts.map +1 -1
- package/dist/{font.plugin-BXjaZrFM.js → font.plugin-CZBx3UOh.js} +1 -1
- package/dist/{font.plugin-CCt54Tnx.cjs → font.plugin-Dyfi_9m6.cjs} +1 -1
- package/dist/{load-from-path-Cctfzaw6.js → load-from-path-CWtVz4o_.js} +1 -1
- package/dist/{load-from-path-CewyV1N6.cjs → load-from-path-CqNK9dVK.cjs} +2 -2
- package/dist/{loader-DKt7MGAX.cjs → loader-Bwk-gC1Q.cjs} +15 -4
- package/dist/{loader-DnW57GzE.js → loader-CXjYZgR0.js} +15 -4
- package/dist/node.cjs +3 -3
- package/dist/node.js +4 -4
- package/dist/variant/variants/udixio.variant.d.ts +1 -1
- package/dist/variant/variants/udixio.variant.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/config/config.interface.ts +3 -2
- package/src/context/context.ts +8 -1
- package/src/variant/variants/udixio.variant.ts +21 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
## 2.1.18 (2026-03-22)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- **theme:** enhance `sourceColor` flexibility and improve context handling ([9bb6068](https://github.com/Udixio/UI/commit/9bb6068))
|
|
6
|
+
|
|
7
|
+
### ❤️ Thank You
|
|
8
|
+
|
|
9
|
+
- Joël VIGREUX
|
|
10
|
+
|
|
11
|
+
## 2.1.17 (2026-03-20)
|
|
12
|
+
|
|
13
|
+
### 🩹 Fixes
|
|
14
|
+
|
|
15
|
+
- **variant:** normalize contrast levels and adjust tone inversion logic ([cc369c3](https://github.com/Udixio/UI/commit/cc369c3))
|
|
16
|
+
|
|
17
|
+
### ❤️ Thank You
|
|
18
|
+
|
|
19
|
+
- Joël VIGREUX
|
|
20
|
+
|
|
1
21
|
## 2.1.16 (2026-02-15)
|
|
2
22
|
|
|
3
23
|
This was a version bump only for @udixio/theme to align it with other projects, there were no code changes.
|
package/dist/bin.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const commander = require("commander");
|
|
3
3
|
const chokidar = require("chokidar");
|
|
4
4
|
const chalk = require("chalk");
|
|
5
|
-
const loadFromPath = require("./load-from-path-
|
|
5
|
+
const loadFromPath = require("./load-from-path-CqNK9dVK.cjs");
|
|
6
6
|
const program = new commander.Command();
|
|
7
7
|
async function runOnce(configPath) {
|
|
8
8
|
try {
|
package/dist/bin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import chokidar from "chokidar";
|
|
3
3
|
import chalk from "chalk";
|
|
4
|
-
import { l as loadFromPath } from "./load-from-path-
|
|
4
|
+
import { l as loadFromPath } from "./load-from-path-CWtVz4o_.js";
|
|
5
5
|
const program = new Command();
|
|
6
6
|
async function runOnce(configPath) {
|
|
7
7
|
try {
|
package/dist/browser.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const loader = require("./loader-
|
|
4
|
-
const font_plugin = require("./font.plugin-
|
|
3
|
+
const loader = require("./loader-Bwk-gC1Q.cjs");
|
|
4
|
+
const font_plugin = require("./font.plugin-Dyfi_9m6.cjs");
|
|
5
5
|
exports.API = loader.API;
|
|
6
6
|
exports.AppContainer = loader.AppContainer;
|
|
7
7
|
exports.AppModule = loader.AppModule;
|
package/dist/browser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A, a, b, C, c, d, e, f, g, h, i, j, k, D, P, l, m, n, o, V, p, q, r, s, t, u, v, w, x, y, z, B, E, F, G } from "./loader-
|
|
2
|
-
import { F as F2, a as a2, P as P2, b as b2, d as d2 } from "./font.plugin-
|
|
1
|
+
import { A, a, b, C, c, d, e, f, g, h, i, j, k, D, P, l, m, n, o, V, p, q, r, s, t, u, v, w, x, y, z, B, E, F, G } from "./loader-CXjYZgR0.js";
|
|
2
|
+
import { F as F2, a as a2, P as P2, b as b2, d as d2 } from "./font.plugin-CZBx3UOh.js";
|
|
3
3
|
export {
|
|
4
4
|
A as API,
|
|
5
5
|
a as AppContainer,
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { AddColorsOptions } from '../color';
|
|
2
|
+
import { Hct } from '../material-color-utilities/htc';
|
|
2
3
|
import { PluginAbstract } from '../plugin';
|
|
3
4
|
import { Variant } from '../variant/variant';
|
|
4
5
|
import { PaletteCallback } from '../palette/palette';
|
|
6
|
+
import { Context } from '../context';
|
|
5
7
|
export interface ConfigInterface {
|
|
6
|
-
sourceColor: string;
|
|
8
|
+
sourceColor: string | Hct | ((context: Context) => string | Hct);
|
|
7
9
|
contrastLevel?: number;
|
|
8
10
|
isDark?: boolean;
|
|
9
11
|
variant?: Variant;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.interface.d.ts","sourceRoot":"","sources":["../../src/config/config.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"config.interface.d.ts","sourceRoot":"","sources":["../../src/config/config.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC,OAAO,EAAE,OAAO,KAAK,MAAM,GAAG,GAAG,CAAC,CAAC;IACjE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAAC,CAAC;IACpD,OAAO,CAAC,EAAE,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;CACtC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Hct } from '../material-color-utilities/htc';
|
|
2
2
|
import { Variant } from '../variant/variant';
|
|
3
|
+
import { ConfigInterface } from '../config';
|
|
3
4
|
export interface ContextOptions {
|
|
4
|
-
sourceColor:
|
|
5
|
+
sourceColor: ConfigInterface['sourceColor'] | Hct;
|
|
5
6
|
contrastLevel: number;
|
|
6
7
|
isDark: boolean;
|
|
7
8
|
variant: Variant;
|
|
@@ -33,6 +34,7 @@ export declare class Context {
|
|
|
33
34
|
get contrastLevel(): number;
|
|
34
35
|
set sourceColor(sourceColor: string);
|
|
35
36
|
get sourceColor(): Hct;
|
|
37
|
+
get rawSourceColor(): ContextOptions['sourceColor'];
|
|
36
38
|
set variant(variant: Variant);
|
|
37
39
|
get variant(): Variant;
|
|
38
40
|
temp<T>(args: Partial<ContextOptions>, callback: () => T): T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/context/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/context/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,eAAe,CAAC,aAAa,CAAC,GAAG,GAAG,CAAC;IAClD,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,qBAAa,OAAO;IAClB,OAAO,CAAC,QAAQ,CAAC,CAAiB;IAClC,OAAO,CAAC,WAAW,CAA+B;IAClD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAEzB;;IAUP;;;;;;;;OAQG;IACH,MAAM,CAAC,iBAAiB,CAAC,CAAC,EACxB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,CAAC,GAC5B;QAAE,MAAM,EAAE,CAAC,CAAC;QAAC,YAAY,EAAE,CAAC,MAAM,OAAO,CAAC,EAAE,CAAA;KAAE;IAsBjD,GAAG,CAAC,OAAO,EAAE,cAAc;IAoBpB,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC;IA4B3C,OAAO,CAAC,UAAU;IAalB,IAAI,QAAQ,CAAC,MAAM,EAAE,OAAO,EAE3B;IACD,IAAI,MAAM,YAET;IAED,IAAI,aAAa,CAAC,aAAa,EAAE,MAAM,EAEtC;IACD,IAAI,aAAa,IAHgB,MAAM,CAKtC;IAED,IAAI,WAAW,CAAC,WAAW,EAAE,MAAM,EAElC;IACD,IAAI,WAAW,IAAI,GAAG,CASrB;IACD,IAAI,cAAc,IAAI,cAAc,CAAC,aAAa,CAAC,CAElD;IAED,IAAI,OAAO,CAAC,OAAO,EAAE,OAAO,EAE3B;IACD,IAAI,OAAO,IAHU,OAAO,CAK3B;IAED,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC;IAW5D,QAAQ,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,CAAC,MAAM,OAAO,CAAC,EAAE,KAAK,IAAI,GAAG,IAAI;CAG/D"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import "./loader-
|
|
4
|
+
import "./loader-CXjYZgR0.js";
|
|
5
5
|
class PluginAbstract {
|
|
6
6
|
constructor(options) {
|
|
7
7
|
__publicField(this, "options");
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
require("./loader-
|
|
5
|
+
require("./loader-Bwk-gC1Q.cjs");
|
|
6
6
|
class PluginAbstract {
|
|
7
7
|
constructor(options) {
|
|
8
8
|
__publicField(this, "options");
|
|
@@ -21,7 +21,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
22
|
mod
|
|
23
23
|
));
|
|
24
|
-
const loader = require("./loader-
|
|
24
|
+
const loader = require("./loader-Bwk-gC1Q.cjs");
|
|
25
25
|
const fs = require("node:fs");
|
|
26
26
|
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
|
|
27
27
|
function _interopNamespaceDefault(e) {
|
|
@@ -44,7 +44,7 @@ const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
|
|
|
44
44
|
async function resolveConfig(configPath = "./theme.config") {
|
|
45
45
|
const { createJiti } = await import("jiti");
|
|
46
46
|
const { resolve } = await import("pathe");
|
|
47
|
-
const jiti = createJiti(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("load-from-path-
|
|
47
|
+
const jiti = createJiti(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("load-from-path-CqNK9dVK.cjs", document.baseURI).href, {
|
|
48
48
|
debug: process.env.NODE_ENV === "development",
|
|
49
49
|
fsCache: true,
|
|
50
50
|
interopDefault: true
|
|
@@ -2591,11 +2591,17 @@ class Context {
|
|
|
2591
2591
|
}
|
|
2592
2592
|
get sourceColor() {
|
|
2593
2593
|
let sourceColor = this.getOptions().sourceColor;
|
|
2594
|
+
if (typeof sourceColor == "function") {
|
|
2595
|
+
sourceColor = sourceColor(this);
|
|
2596
|
+
}
|
|
2594
2597
|
if (typeof sourceColor === "string") {
|
|
2595
2598
|
sourceColor = Hct.fromInt(materialColorUtilities.argbFromHex(sourceColor));
|
|
2596
2599
|
}
|
|
2597
2600
|
return sourceColor;
|
|
2598
2601
|
}
|
|
2602
|
+
get rawSourceColor() {
|
|
2603
|
+
return this.getOptions().sourceColor;
|
|
2604
|
+
}
|
|
2599
2605
|
set variant(variant2) {
|
|
2600
2606
|
this.update({ variant: variant2 });
|
|
2601
2607
|
}
|
|
@@ -3074,8 +3080,12 @@ const vibrantVariant = variant({
|
|
|
3074
3080
|
colors: defaultColors
|
|
3075
3081
|
});
|
|
3076
3082
|
const surfaceContainerToneDelta = 2.5;
|
|
3077
|
-
const
|
|
3078
|
-
|
|
3083
|
+
const normalize = (value, inputRange, outputRange = [0, 1]) => {
|
|
3084
|
+
const [inputMin, inputMax] = inputRange;
|
|
3085
|
+
const [outputMin, outputMax] = outputRange;
|
|
3086
|
+
const clampedValue = Math.max(inputMin, Math.min(value, inputMax));
|
|
3087
|
+
const normalizedValue = (clampedValue - inputMin) / (inputMax - inputMin);
|
|
3088
|
+
return outputMin + normalizedValue * (outputMax - outputMin);
|
|
3079
3089
|
};
|
|
3080
3090
|
const surfaceContainerTone = (layer, api) => {
|
|
3081
3091
|
const t = surfaceContainerToneDelta * layer * (1 + api.context.contrastLevel);
|
|
@@ -3096,7 +3106,8 @@ const highestSurface = (context, colorService) => {
|
|
|
3096
3106
|
}
|
|
3097
3107
|
};
|
|
3098
3108
|
const createMinContrastToneAdjuster = (ctx, colors, options) => {
|
|
3099
|
-
const { selfKey, referenceKey
|
|
3109
|
+
const { selfKey, referenceKey } = options;
|
|
3110
|
+
const minContrast = ctx.contrastLevel >= 0 ? normalize(ctx.contrastLevel, [0, 1], [3, 7]) : normalize(ctx.contrastLevel, [-1, 0], [0, 3]);
|
|
3100
3111
|
const referenceTone = referenceKey ? colors.get(referenceKey).getTone() : highestSurface(ctx, colors).getTone();
|
|
3101
3112
|
const baseTone = colors.get(selfKey).options.tone;
|
|
3102
3113
|
let selfTone = baseTone;
|
|
@@ -3106,7 +3117,7 @@ const createMinContrastToneAdjuster = (ctx, colors, options) => {
|
|
|
3106
3117
|
selfTone,
|
|
3107
3118
|
minContrast
|
|
3108
3119
|
);
|
|
3109
|
-
const inverseT =
|
|
3120
|
+
const inverseT = ctx.isDark ? 100 : 0;
|
|
3110
3121
|
selfTone = selfTone + (inverseT - selfTone) * ratio;
|
|
3111
3122
|
}
|
|
3112
3123
|
return selfTone;
|
|
@@ -2590,11 +2590,17 @@ class Context {
|
|
|
2590
2590
|
}
|
|
2591
2591
|
get sourceColor() {
|
|
2592
2592
|
let sourceColor = this.getOptions().sourceColor;
|
|
2593
|
+
if (typeof sourceColor == "function") {
|
|
2594
|
+
sourceColor = sourceColor(this);
|
|
2595
|
+
}
|
|
2593
2596
|
if (typeof sourceColor === "string") {
|
|
2594
2597
|
sourceColor = Hct.fromInt(argbFromHex(sourceColor));
|
|
2595
2598
|
}
|
|
2596
2599
|
return sourceColor;
|
|
2597
2600
|
}
|
|
2601
|
+
get rawSourceColor() {
|
|
2602
|
+
return this.getOptions().sourceColor;
|
|
2603
|
+
}
|
|
2598
2604
|
set variant(variant2) {
|
|
2599
2605
|
this.update({ variant: variant2 });
|
|
2600
2606
|
}
|
|
@@ -3073,8 +3079,12 @@ const vibrantVariant = variant({
|
|
|
3073
3079
|
colors: defaultColors
|
|
3074
3080
|
});
|
|
3075
3081
|
const surfaceContainerToneDelta = 2.5;
|
|
3076
|
-
const
|
|
3077
|
-
|
|
3082
|
+
const normalize = (value, inputRange, outputRange = [0, 1]) => {
|
|
3083
|
+
const [inputMin, inputMax] = inputRange;
|
|
3084
|
+
const [outputMin, outputMax] = outputRange;
|
|
3085
|
+
const clampedValue = Math.max(inputMin, Math.min(value, inputMax));
|
|
3086
|
+
const normalizedValue = (clampedValue - inputMin) / (inputMax - inputMin);
|
|
3087
|
+
return outputMin + normalizedValue * (outputMax - outputMin);
|
|
3078
3088
|
};
|
|
3079
3089
|
const surfaceContainerTone = (layer, api) => {
|
|
3080
3090
|
const t = surfaceContainerToneDelta * layer * (1 + api.context.contrastLevel);
|
|
@@ -3095,7 +3105,8 @@ const highestSurface = (context, colorService) => {
|
|
|
3095
3105
|
}
|
|
3096
3106
|
};
|
|
3097
3107
|
const createMinContrastToneAdjuster = (ctx, colors, options) => {
|
|
3098
|
-
const { selfKey, referenceKey
|
|
3108
|
+
const { selfKey, referenceKey } = options;
|
|
3109
|
+
const minContrast = ctx.contrastLevel >= 0 ? normalize(ctx.contrastLevel, [0, 1], [3, 7]) : normalize(ctx.contrastLevel, [-1, 0], [0, 3]);
|
|
3099
3110
|
const referenceTone = referenceKey ? colors.get(referenceKey).getTone() : highestSurface(ctx, colors).getTone();
|
|
3100
3111
|
const baseTone = colors.get(selfKey).options.tone;
|
|
3101
3112
|
let selfTone = baseTone;
|
|
@@ -3105,7 +3116,7 @@ const createMinContrastToneAdjuster = (ctx, colors, options) => {
|
|
|
3105
3116
|
selfTone,
|
|
3106
3117
|
minContrast
|
|
3107
3118
|
);
|
|
3108
|
-
const inverseT =
|
|
3119
|
+
const inverseT = ctx.isDark ? 100 : 0;
|
|
3109
3120
|
selfTone = selfTone + (inverseT - selfTone) * ratio;
|
|
3110
3121
|
}
|
|
3111
3122
|
return selfTone;
|
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-Bwk-gC1Q.cjs");
|
|
26
|
+
const font_plugin = require("./font.plugin-Dyfi_9m6.cjs");
|
|
27
|
+
const loadFromPath = require("./load-from-path-CqNK9dVK.cjs");
|
|
28
28
|
let unpluginInstance = null;
|
|
29
29
|
const createUnpluginTheme = async () => {
|
|
30
30
|
if (unpluginInstance) {
|
package/dist/node.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { A, a, b, C, c, d, e, f, g, h, i, j, k, D, P, l, m, n, o, V, p, q, r, s, t, u, v, w, x, y, z, B, E, F, G } from "./loader-
|
|
2
|
-
import { F as F2, a as a2, P as P2, b as b2, 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, C, c, d, e, f, g, h, i, j, k, D, P, l, m, n, o, V, p, q, r, s, t, u, v, w, x, y, z, B, E, F, G } from "./loader-CXjYZgR0.js";
|
|
2
|
+
import { F as F2, a as a2, P as P2, b as b2, d as d2 } from "./font.plugin-CZBx3UOh.js";
|
|
3
|
+
import { l as loadFromPath } from "./load-from-path-CWtVz4o_.js";
|
|
4
|
+
import { r as r2 } from "./load-from-path-CWtVz4o_.js";
|
|
5
5
|
let unpluginInstance = null;
|
|
6
6
|
const createUnpluginTheme = async () => {
|
|
7
7
|
if (unpluginInstance) {
|
|
@@ -2,10 +2,10 @@ import { Variant } from '../variant';
|
|
|
2
2
|
import { DynamicColorKey } from '../../color/color.utils';
|
|
3
3
|
import { ColorApi, ColorManager } from '../../color';
|
|
4
4
|
import { Context } from '../../context';
|
|
5
|
+
export declare const normalize: (value: number, inputRange: [number, number], outputRange?: [number, number]) => number;
|
|
5
6
|
export declare const createMinContrastToneAdjuster: (ctx: Context, colors: ColorManager | ColorApi, options: {
|
|
6
7
|
selfKey: DynamicColorKey;
|
|
7
8
|
referenceKey?: DynamicColorKey;
|
|
8
|
-
minContrast?: number;
|
|
9
9
|
}) => number;
|
|
10
10
|
export declare const udixioVariant: Variant;
|
|
11
11
|
//# sourceMappingURL=udixio.variant.d.ts.map
|
|
@@ -1 +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;AAC9E,OAAO,EAEL,eAAe,EAIhB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAIL,QAAQ,EAER,YAAY,EAEb,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;
|
|
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;AAC9E,OAAO,EAEL,eAAe,EAIhB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAIL,QAAQ,EAER,YAAY,EAEb,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AASxC,eAAO,MAAM,SAAS,GACpB,OAAO,MAAM,EACb,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,EAC5B,cAAa,CAAC,MAAM,EAAE,MAAM,CAAU,KACrC,MASF,CAAC;AAkCF,eAAO,MAAM,6BAA6B,GACxC,KAAK,OAAO,EACZ,QAAQ,YAAY,GAAG,QAAQ,EAC/B,SAAS;IACP,OAAO,EAAE,eAAe,CAAC;IACzB,YAAY,CAAC,EAAE,eAAe,CAAC;CAChC,WA2BF,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,OA6vB1B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { AddColorsOptions } from '../color';
|
|
2
|
-
|
|
2
|
+
import { Hct } from '../material-color-utilities/htc';
|
|
3
3
|
import { PluginAbstract } from '../plugin';
|
|
4
4
|
import { Variant } from '../variant/variant';
|
|
5
5
|
import { PaletteCallback } from '../palette/palette';
|
|
6
|
+
import { Context } from '../context';
|
|
6
7
|
|
|
7
8
|
export interface ConfigInterface {
|
|
8
|
-
sourceColor: string;
|
|
9
|
+
sourceColor: string | Hct | ((context: Context) => string | Hct);
|
|
9
10
|
contrastLevel?: number;
|
|
10
11
|
isDark?: boolean;
|
|
11
12
|
variant?: Variant;
|
package/src/context/context.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { argbFromHex } from '@material/material-color-utilities';
|
|
2
2
|
import { Hct } from '../material-color-utilities/htc';
|
|
3
3
|
import { Variant } from '../variant/variant';
|
|
4
|
+
import { ConfigInterface } from '../config';
|
|
4
5
|
|
|
5
6
|
export interface ContextOptions {
|
|
6
|
-
sourceColor:
|
|
7
|
+
sourceColor: ConfigInterface['sourceColor'] | Hct;
|
|
7
8
|
contrastLevel: number;
|
|
8
9
|
isDark: boolean;
|
|
9
10
|
variant: Variant;
|
|
@@ -138,11 +139,17 @@ export class Context {
|
|
|
138
139
|
}
|
|
139
140
|
get sourceColor(): Hct {
|
|
140
141
|
let sourceColor = this.getOptions().sourceColor;
|
|
142
|
+
if (typeof sourceColor == 'function') {
|
|
143
|
+
sourceColor = sourceColor(this);
|
|
144
|
+
}
|
|
141
145
|
if (typeof sourceColor === 'string') {
|
|
142
146
|
sourceColor = Hct.fromInt(argbFromHex(sourceColor));
|
|
143
147
|
}
|
|
144
148
|
return sourceColor;
|
|
145
149
|
}
|
|
150
|
+
get rawSourceColor(): ContextOptions['sourceColor'] {
|
|
151
|
+
return this.getOptions().sourceColor;
|
|
152
|
+
}
|
|
146
153
|
|
|
147
154
|
set variant(variant: Variant) {
|
|
148
155
|
this.update({ variant });
|
|
@@ -27,6 +27,21 @@ const inverseTone = (tone: number) => {
|
|
|
27
27
|
return 100 - tone;
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
+
export const normalize = (
|
|
31
|
+
value: number,
|
|
32
|
+
inputRange: [number, number],
|
|
33
|
+
outputRange: [number, number] = [0, 1],
|
|
34
|
+
): number => {
|
|
35
|
+
const [inputMin, inputMax] = inputRange;
|
|
36
|
+
const [outputMin, outputMax] = outputRange;
|
|
37
|
+
|
|
38
|
+
const clampedValue = Math.max(inputMin, Math.min(value, inputMax));
|
|
39
|
+
|
|
40
|
+
const normalizedValue = (clampedValue - inputMin) / (inputMax - inputMin);
|
|
41
|
+
|
|
42
|
+
return outputMin + normalizedValue * (outputMax - outputMin);
|
|
43
|
+
};
|
|
44
|
+
|
|
30
45
|
const surfaceContainerTone = (
|
|
31
46
|
layer: number,
|
|
32
47
|
api: Pick<API, 'palettes' | 'context'>,
|
|
@@ -65,10 +80,13 @@ export const createMinContrastToneAdjuster = (
|
|
|
65
80
|
options: {
|
|
66
81
|
selfKey: DynamicColorKey;
|
|
67
82
|
referenceKey?: DynamicColorKey; // par défaut: la surface la plus "haute"
|
|
68
|
-
minContrast?: number; // par défaut: 3
|
|
69
83
|
},
|
|
70
84
|
) => {
|
|
71
|
-
const { selfKey, referenceKey
|
|
85
|
+
const { selfKey, referenceKey } = options;
|
|
86
|
+
const minContrast =
|
|
87
|
+
ctx.contrastLevel >= 0
|
|
88
|
+
? normalize(ctx.contrastLevel, [0, 1], [3, 7])
|
|
89
|
+
: normalize(ctx.contrastLevel, [-1, 0], [0, 3]);
|
|
72
90
|
|
|
73
91
|
const referenceTone = referenceKey
|
|
74
92
|
? colors.get(referenceKey).getTone()
|
|
@@ -84,7 +102,7 @@ export const createMinContrastToneAdjuster = (
|
|
|
84
102
|
selfTone,
|
|
85
103
|
minContrast,
|
|
86
104
|
);
|
|
87
|
-
const inverseT =
|
|
105
|
+
const inverseT = ctx.isDark ? 100 : 0;
|
|
88
106
|
selfTone = selfTone + (inverseT - selfTone) * ratio;
|
|
89
107
|
}
|
|
90
108
|
|