@udixio/theme 2.1.10 → 2.1.12

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 CHANGED
@@ -1,3 +1,18 @@
1
+ ## 2.1.12 (2026-01-30)
2
+
3
+ ### 🚀 Features
4
+
5
+ - **theme:** improve tone logic and adjust background calculations ([6eda481](https://github.com/Udixio/UI/commit/6eda481))
6
+ - **theme:** add `createMinContrastToneAdjuster` util for dynamic tone adjustments ([d963806](https://github.com/Udixio/UI/commit/d963806))
7
+
8
+ ### ❤️ Thank You
9
+
10
+ - Joël VIGREUX
11
+
12
+ ## 2.1.11 (2026-01-18)
13
+
14
+ This was a version bump only for @udixio/theme to align it with other projects, there were no code changes.
15
+
1
16
  ## 2.1.10 (2026-01-18)
2
17
 
3
18
  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-BCkiZx6_.cjs");
5
+ const loadFromPath = require("./load-from-path-DVvlFI1M.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-C4axFso4.js";
4
+ import { l as loadFromPath } from "./load-from-path-CHmj8u_v.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-1Pp2rd0P.cjs");
4
- const font_plugin = require("./font.plugin-B0SKfA9r.cjs");
3
+ const loader = require("./loader-BZta4ulw.cjs");
4
+ const font_plugin = require("./font.plugin-B6HEs4Om.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, 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--tJzL1CC.js";
2
- import { F as F2, b as b2, P as P2, a as a2, d as d2 } from "./font.plugin-BReTQTWQ.js";
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-DVtdg4Xh.js";
2
+ import { F as F2, b as b2, P as P2, a as a2, d as d2 } from "./font.plugin-BorVbapj.js";
3
3
  export {
4
4
  A as API,
5
5
  a as AppContainer,
@@ -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-1Pp2rd0P.cjs");
5
+ require("./loader-BZta4ulw.cjs");
6
6
  class PluginAbstract {
7
7
  constructor(options) {
8
8
  __publicField(this, "options");
@@ -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--tJzL1CC.js";
4
+ import "./loader-DVtdg4Xh.js";
5
5
  class PluginAbstract {
6
6
  constructor(options) {
7
7
  __publicField(this, "options");
@@ -1,4 +1,4 @@
1
- import { p as loader } from "./loader--tJzL1CC.js";
1
+ import { p as loader } from "./loader-DVtdg4Xh.js";
2
2
  import * as fs from "node:fs";
3
3
  async function resolveConfig(configPath = "./theme.config") {
4
4
  const { createJiti } = await import("jiti");
@@ -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-1Pp2rd0P.cjs");
24
+ const loader = require("./loader-BZta4ulw.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-BCkiZx6_.cjs", document.baseURI).href, {
47
+ const jiti = createJiti(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("load-from-path-DVvlFI1M.cjs", document.baseURI).href, {
48
48
  debug: process.env.NODE_ENV === "development",
49
49
  fsCache: true,
50
50
  interopDefault: true
@@ -3090,10 +3090,27 @@ const surfaceContainerTone = (layer, api) => {
3090
3090
  };
3091
3091
  const highestSurface = (context, colorService) => {
3092
3092
  if (colorService instanceof ColorApi) {
3093
- return colorService.get("surface");
3093
+ return context.isDark ? colorService.get("surfaceBright") : colorService.get("surfaceDim");
3094
3094
  } else {
3095
- return colorService.get("surface");
3095
+ return context.isDark ? colorService.get("surfaceBright") : colorService.get("surfaceDim");
3096
+ }
3097
+ };
3098
+ const createMinContrastToneAdjuster = (ctx, colors, options) => {
3099
+ const { selfKey, referenceKey, minContrast = 3 } = options;
3100
+ const referenceTone = referenceKey ? colors.get(referenceKey).getTone() : highestSurface(ctx, colors).getTone();
3101
+ const baseTone = colors.get(selfKey).options.tone;
3102
+ let selfTone = baseTone;
3103
+ console.log("contrast ratio2", referenceTone, selfTone);
3104
+ if (materialColorUtilities.Contrast.ratioOfTones(referenceTone, selfTone) < minContrast) {
3105
+ const ratio = calculateToneAdjustmentPercentage(
3106
+ referenceTone,
3107
+ selfTone,
3108
+ minContrast
3109
+ );
3110
+ const inverseT = inverseTone(baseTone);
3111
+ selfTone = selfTone + (inverseT - selfTone) * ratio;
3096
3112
  }
3113
+ return selfTone;
3097
3114
  };
3098
3115
  const udixioVariant = variant({
3099
3116
  name: "udixio",
@@ -3153,19 +3170,20 @@ const udixioVariant = variant({
3153
3170
  [colorKey]: {
3154
3171
  palette: () => palettes.get(colorKey),
3155
3172
  tone: () => {
3156
- return ctx.isDark ? 80 : tMaxC(palettes.get(colorKey));
3173
+ return colors2.get("primary").getTone();
3157
3174
  },
3158
- isBackground: true,
3159
- background: () => highestSurface(ctx, colors2),
3160
- contrastCurve: () => getCurve(4.5),
3161
- adjustTone: () => toneDeltaPair(
3162
- colors2.get(colorContainerKey),
3163
- colors2.get(colorKey),
3164
- 5,
3165
- "relative_lighter",
3166
- true,
3167
- "farther"
3168
- )
3175
+ isBackground: true
3176
+ // background: () => highestSurface(ctx, colors),
3177
+ // contrastCurve: () => getCurve(4.5),
3178
+ // adjustTone: () =>
3179
+ // toneDeltaPair(
3180
+ // colors.get(colorContainerKey),
3181
+ // colors.get(colorKey),
3182
+ // 5,
3183
+ // 'relative_lighter',
3184
+ // true,
3185
+ // 'farther',
3186
+ // ),
3169
3187
  },
3170
3188
  // [colorDimKey]: {
3171
3189
  // palette: () => palettes.get(colorKey),
@@ -3207,7 +3225,14 @@ const udixioVariant = variant({
3207
3225
  },
3208
3226
  isBackground: true,
3209
3227
  background: () => highestSurface(ctx, colors2),
3210
- adjustTone: () => void 0,
3228
+ adjustTone: () => toneDeltaPair(
3229
+ colors2.get(colorKey),
3230
+ colors2.get(colorContainerKey),
3231
+ 15,
3232
+ "relative_darker",
3233
+ true,
3234
+ "farther"
3235
+ ),
3211
3236
  contrastCurve: () => ctx.contrastLevel > 0 ? getCurve(1.5) : void 0
3212
3237
  },
3213
3238
  [onColorContainerKey]: {
@@ -3403,19 +3428,9 @@ const udixioVariant = variant({
3403
3428
  background: () => highestSurface(ctx, colors),
3404
3429
  contrastCurve: () => getCurve(4.5),
3405
3430
  adjustTone: () => () => {
3406
- const surfaceTone = colors.get("surface").getTone();
3407
- const primaryTone = colors.get("primary").options.tone;
3408
- let selfTone = primaryTone;
3409
- if (materialColorUtilities.Contrast.ratioOfTones(surfaceTone, selfTone) < 3) {
3410
- const ratio = calculateToneAdjustmentPercentage(
3411
- surfaceTone,
3412
- selfTone,
3413
- 3
3414
- );
3415
- const inverseT = inverseTone(primaryTone);
3416
- selfTone = selfTone + (inverseT - selfTone) * ratio;
3417
- }
3418
- return selfTone;
3431
+ return createMinContrastToneAdjuster(ctx, colors, {
3432
+ selfKey: "primary"
3433
+ });
3419
3434
  }
3420
3435
  },
3421
3436
  // primaryDim: {
@@ -3523,19 +3538,20 @@ const udixioVariant = variant({
3523
3538
  secondary: {
3524
3539
  palette: () => palettes.get("secondary"),
3525
3540
  tone: () => {
3526
- return ctx.isDark ? 80 : tMaxC(palettes.get("secondary"));
3541
+ return colors.get("primary").getTone();
3527
3542
  },
3528
- isBackground: true,
3529
- background: () => highestSurface(ctx, colors),
3530
- contrastCurve: () => getCurve(4.5),
3531
- adjustTone: () => toneDeltaPair(
3532
- getColor("secondaryContainer"),
3533
- getColor("secondary"),
3534
- 5,
3535
- "relative_lighter",
3536
- true,
3537
- "farther"
3538
- )
3543
+ isBackground: true
3544
+ // background: () => highestSurface(ctx, colors),
3545
+ // contrastCurve: () => getCurve(4.5),
3546
+ // adjustTone: () =>
3547
+ // toneDeltaPair(
3548
+ // getColor('secondaryContainer'),
3549
+ // getColor('secondary'),
3550
+ // 5,
3551
+ // 'relative_lighter',
3552
+ // true,
3553
+ // 'farther',
3554
+ // ),
3539
3555
  },
3540
3556
  // secondaryDim: {
3541
3557
  // palette: () => palettes.get('secondary'),
@@ -3571,7 +3587,14 @@ const udixioVariant = variant({
3571
3587
  },
3572
3588
  isBackground: true,
3573
3589
  background: () => highestSurface(ctx, colors),
3574
- adjustTone: () => void 0,
3590
+ adjustTone: () => toneDeltaPair(
3591
+ colors.get("secondary"),
3592
+ colors.get("secondaryContainer"),
3593
+ 15,
3594
+ "relative_darker",
3595
+ true,
3596
+ "farther"
3597
+ ),
3575
3598
  contrastCurve: () => ctx.contrastLevel > 0 ? getCurve(1.5) : void 0
3576
3599
  },
3577
3600
  onSecondaryContainer: {
@@ -3627,19 +3650,21 @@ const udixioVariant = variant({
3627
3650
  tertiary: {
3628
3651
  palette: () => palettes.get("tertiary"),
3629
3652
  tone: () => {
3630
- return ctx.isDark ? tMaxC(palettes.get("tertiary"), 0, 98) : tMaxC(palettes.get("tertiary"));
3653
+ const tone = colors.get("primary").getTone();
3654
+ return Math.max(20, Math.min(80, tone));
3631
3655
  },
3632
- isBackground: true,
3633
- background: () => highestSurface(ctx, colors),
3634
- contrastCurve: () => getCurve(4.5),
3635
- adjustTone: () => toneDeltaPair(
3636
- getColor("tertiaryContainer"),
3637
- getColor("tertiary"),
3638
- 5,
3639
- "relative_lighter",
3640
- true,
3641
- "farther"
3642
- )
3656
+ isBackground: true
3657
+ // background: () => highestSurface(ctx, colors),
3658
+ // contrastCurve: () => getCurve(4.5),
3659
+ // adjustTone: () =>
3660
+ // toneDeltaPair(
3661
+ // getColor('tertiaryContainer'),
3662
+ // getColor('tertiary'),
3663
+ // 5,
3664
+ // 'relative_lighter',
3665
+ // true,
3666
+ // 'farther',
3667
+ // ),
3643
3668
  },
3644
3669
  // tertiaryDim: {
3645
3670
  // palette: () => palettes.get('tertiary'),
@@ -3675,7 +3700,14 @@ const udixioVariant = variant({
3675
3700
  },
3676
3701
  isBackground: true,
3677
3702
  background: () => highestSurface(ctx, colors),
3678
- adjustTone: () => void 0,
3703
+ adjustTone: () => toneDeltaPair(
3704
+ colors.get("tertiary"),
3705
+ colors.get("tertiaryContainer"),
3706
+ 15,
3707
+ "relative_darker",
3708
+ true,
3709
+ "farther"
3710
+ ),
3679
3711
  contrastCurve: () => ctx.contrastLevel > 0 ? getCurve(1.5) : void 0
3680
3712
  },
3681
3713
  onTertiaryContainer: {
@@ -3089,10 +3089,27 @@ const surfaceContainerTone = (layer, api) => {
3089
3089
  };
3090
3090
  const highestSurface = (context, colorService) => {
3091
3091
  if (colorService instanceof ColorApi) {
3092
- return colorService.get("surface");
3092
+ return context.isDark ? colorService.get("surfaceBright") : colorService.get("surfaceDim");
3093
3093
  } else {
3094
- return colorService.get("surface");
3094
+ return context.isDark ? colorService.get("surfaceBright") : colorService.get("surfaceDim");
3095
+ }
3096
+ };
3097
+ const createMinContrastToneAdjuster = (ctx, colors, options) => {
3098
+ const { selfKey, referenceKey, minContrast = 3 } = options;
3099
+ const referenceTone = referenceKey ? colors.get(referenceKey).getTone() : highestSurface(ctx, colors).getTone();
3100
+ const baseTone = colors.get(selfKey).options.tone;
3101
+ let selfTone = baseTone;
3102
+ console.log("contrast ratio2", referenceTone, selfTone);
3103
+ if (Contrast.ratioOfTones(referenceTone, selfTone) < minContrast) {
3104
+ const ratio = calculateToneAdjustmentPercentage(
3105
+ referenceTone,
3106
+ selfTone,
3107
+ minContrast
3108
+ );
3109
+ const inverseT = inverseTone(baseTone);
3110
+ selfTone = selfTone + (inverseT - selfTone) * ratio;
3095
3111
  }
3112
+ return selfTone;
3096
3113
  };
3097
3114
  const udixioVariant = variant({
3098
3115
  name: "udixio",
@@ -3152,19 +3169,20 @@ const udixioVariant = variant({
3152
3169
  [colorKey]: {
3153
3170
  palette: () => palettes.get(colorKey),
3154
3171
  tone: () => {
3155
- return ctx.isDark ? 80 : tMaxC(palettes.get(colorKey));
3172
+ return colors2.get("primary").getTone();
3156
3173
  },
3157
- isBackground: true,
3158
- background: () => highestSurface(ctx, colors2),
3159
- contrastCurve: () => getCurve(4.5),
3160
- adjustTone: () => toneDeltaPair(
3161
- colors2.get(colorContainerKey),
3162
- colors2.get(colorKey),
3163
- 5,
3164
- "relative_lighter",
3165
- true,
3166
- "farther"
3167
- )
3174
+ isBackground: true
3175
+ // background: () => highestSurface(ctx, colors),
3176
+ // contrastCurve: () => getCurve(4.5),
3177
+ // adjustTone: () =>
3178
+ // toneDeltaPair(
3179
+ // colors.get(colorContainerKey),
3180
+ // colors.get(colorKey),
3181
+ // 5,
3182
+ // 'relative_lighter',
3183
+ // true,
3184
+ // 'farther',
3185
+ // ),
3168
3186
  },
3169
3187
  // [colorDimKey]: {
3170
3188
  // palette: () => palettes.get(colorKey),
@@ -3206,7 +3224,14 @@ const udixioVariant = variant({
3206
3224
  },
3207
3225
  isBackground: true,
3208
3226
  background: () => highestSurface(ctx, colors2),
3209
- adjustTone: () => void 0,
3227
+ adjustTone: () => toneDeltaPair(
3228
+ colors2.get(colorKey),
3229
+ colors2.get(colorContainerKey),
3230
+ 15,
3231
+ "relative_darker",
3232
+ true,
3233
+ "farther"
3234
+ ),
3210
3235
  contrastCurve: () => ctx.contrastLevel > 0 ? getCurve(1.5) : void 0
3211
3236
  },
3212
3237
  [onColorContainerKey]: {
@@ -3402,19 +3427,9 @@ const udixioVariant = variant({
3402
3427
  background: () => highestSurface(ctx, colors),
3403
3428
  contrastCurve: () => getCurve(4.5),
3404
3429
  adjustTone: () => () => {
3405
- const surfaceTone = colors.get("surface").getTone();
3406
- const primaryTone = colors.get("primary").options.tone;
3407
- let selfTone = primaryTone;
3408
- if (Contrast.ratioOfTones(surfaceTone, selfTone) < 3) {
3409
- const ratio = calculateToneAdjustmentPercentage(
3410
- surfaceTone,
3411
- selfTone,
3412
- 3
3413
- );
3414
- const inverseT = inverseTone(primaryTone);
3415
- selfTone = selfTone + (inverseT - selfTone) * ratio;
3416
- }
3417
- return selfTone;
3430
+ return createMinContrastToneAdjuster(ctx, colors, {
3431
+ selfKey: "primary"
3432
+ });
3418
3433
  }
3419
3434
  },
3420
3435
  // primaryDim: {
@@ -3522,19 +3537,20 @@ const udixioVariant = variant({
3522
3537
  secondary: {
3523
3538
  palette: () => palettes.get("secondary"),
3524
3539
  tone: () => {
3525
- return ctx.isDark ? 80 : tMaxC(palettes.get("secondary"));
3540
+ return colors.get("primary").getTone();
3526
3541
  },
3527
- isBackground: true,
3528
- background: () => highestSurface(ctx, colors),
3529
- contrastCurve: () => getCurve(4.5),
3530
- adjustTone: () => toneDeltaPair(
3531
- getColor("secondaryContainer"),
3532
- getColor("secondary"),
3533
- 5,
3534
- "relative_lighter",
3535
- true,
3536
- "farther"
3537
- )
3542
+ isBackground: true
3543
+ // background: () => highestSurface(ctx, colors),
3544
+ // contrastCurve: () => getCurve(4.5),
3545
+ // adjustTone: () =>
3546
+ // toneDeltaPair(
3547
+ // getColor('secondaryContainer'),
3548
+ // getColor('secondary'),
3549
+ // 5,
3550
+ // 'relative_lighter',
3551
+ // true,
3552
+ // 'farther',
3553
+ // ),
3538
3554
  },
3539
3555
  // secondaryDim: {
3540
3556
  // palette: () => palettes.get('secondary'),
@@ -3570,7 +3586,14 @@ const udixioVariant = variant({
3570
3586
  },
3571
3587
  isBackground: true,
3572
3588
  background: () => highestSurface(ctx, colors),
3573
- adjustTone: () => void 0,
3589
+ adjustTone: () => toneDeltaPair(
3590
+ colors.get("secondary"),
3591
+ colors.get("secondaryContainer"),
3592
+ 15,
3593
+ "relative_darker",
3594
+ true,
3595
+ "farther"
3596
+ ),
3574
3597
  contrastCurve: () => ctx.contrastLevel > 0 ? getCurve(1.5) : void 0
3575
3598
  },
3576
3599
  onSecondaryContainer: {
@@ -3626,19 +3649,21 @@ const udixioVariant = variant({
3626
3649
  tertiary: {
3627
3650
  palette: () => palettes.get("tertiary"),
3628
3651
  tone: () => {
3629
- return ctx.isDark ? tMaxC(palettes.get("tertiary"), 0, 98) : tMaxC(palettes.get("tertiary"));
3652
+ const tone = colors.get("primary").getTone();
3653
+ return Math.max(20, Math.min(80, tone));
3630
3654
  },
3631
- isBackground: true,
3632
- background: () => highestSurface(ctx, colors),
3633
- contrastCurve: () => getCurve(4.5),
3634
- adjustTone: () => toneDeltaPair(
3635
- getColor("tertiaryContainer"),
3636
- getColor("tertiary"),
3637
- 5,
3638
- "relative_lighter",
3639
- true,
3640
- "farther"
3641
- )
3655
+ isBackground: true
3656
+ // background: () => highestSurface(ctx, colors),
3657
+ // contrastCurve: () => getCurve(4.5),
3658
+ // adjustTone: () =>
3659
+ // toneDeltaPair(
3660
+ // getColor('tertiaryContainer'),
3661
+ // getColor('tertiary'),
3662
+ // 5,
3663
+ // 'relative_lighter',
3664
+ // true,
3665
+ // 'farther',
3666
+ // ),
3642
3667
  },
3643
3668
  // tertiaryDim: {
3644
3669
  // palette: () => palettes.get('tertiary'),
@@ -3674,7 +3699,14 @@ const udixioVariant = variant({
3674
3699
  },
3675
3700
  isBackground: true,
3676
3701
  background: () => highestSurface(ctx, colors),
3677
- adjustTone: () => void 0,
3702
+ adjustTone: () => toneDeltaPair(
3703
+ colors.get("tertiary"),
3704
+ colors.get("tertiaryContainer"),
3705
+ 15,
3706
+ "relative_darker",
3707
+ true,
3708
+ "farther"
3709
+ ),
3678
3710
  contrastCurve: () => ctx.contrastLevel > 0 ? getCurve(1.5) : void 0
3679
3711
  },
3680
3712
  onTertiaryContainer: {
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-1Pp2rd0P.cjs");
26
- const font_plugin = require("./font.plugin-B0SKfA9r.cjs");
27
- const loadFromPath = require("./load-from-path-BCkiZx6_.cjs");
25
+ const loader = require("./loader-BZta4ulw.cjs");
26
+ const font_plugin = require("./font.plugin-B6HEs4Om.cjs");
27
+ const loadFromPath = require("./load-from-path-DVvlFI1M.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, 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--tJzL1CC.js";
2
- import { F as F2, b as b2, P as P2, a as a2, d as d2 } from "./font.plugin-BReTQTWQ.js";
3
- import { l as loadFromPath } from "./load-from-path-C4axFso4.js";
4
- import { r as r2 } from "./load-from-path-C4axFso4.js";
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-DVtdg4Xh.js";
2
+ import { F as F2, b as b2, P as P2, a as a2, d as d2 } from "./font.plugin-BorVbapj.js";
3
+ import { l as loadFromPath } from "./load-from-path-CHmj8u_v.js";
4
+ import { r as r2 } from "./load-from-path-CHmj8u_v.js";
5
5
  let unpluginInstance = null;
6
6
  const createUnpluginTheme = async () => {
7
7
  if (unpluginInstance) {
@@ -1,3 +1,11 @@
1
1
  import { Variant } from '../variant';
2
+ import { DynamicColorKey } from '../../color/color.utils';
3
+ import { ColorApi, ColorManager } from '../../color';
4
+ import { Context } from '../../context';
5
+ export declare const createMinContrastToneAdjuster: (ctx: Context, colors: ColorManager | ColorApi, options: {
6
+ selfKey: DynamicColorKey;
7
+ referenceKey?: DynamicColorKey;
8
+ minContrast?: number;
9
+ }) => number;
2
10
  export declare const udixioVariant: Variant;
3
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;AAuD9E,eAAO,MAAM,aAAa,EAAE,OAovB1B,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;AAyCxC,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;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,WAwBF,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,OAiwB1B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@udixio/theme",
3
- "version": "2.1.10",
3
+ "version": "2.1.12",
4
4
  "type": "module",
5
5
  "main": "./dist/node.js",
6
6
  "module": "./dist/node.js",
@@ -47,12 +47,51 @@ const highestSurface = (
47
47
  colorService: ColorManager | ColorApi,
48
48
  ): Color => {
49
49
  if (colorService instanceof ColorApi) {
50
- return colorService.get('surface');
50
+ return context.isDark
51
+ ? colorService.get('surfaceBright')
52
+ : colorService.get('surfaceDim');
51
53
  } else {
52
- return colorService.get('surface');
54
+ return context.isDark
55
+ ? colorService.get('surfaceBright')
56
+ : colorService.get('surfaceDim');
53
57
  }
54
58
  };
55
59
 
60
+ // Permet de réutiliser la logique "si contraste < minContrast, pousser le tone vers l'inverse"
61
+ // pour n'importe quelle couleur (pas seulement `primary`), et avec une référence configurable.
62
+ export const createMinContrastToneAdjuster = (
63
+ ctx: Context,
64
+ colors: ColorManager | ColorApi,
65
+ options: {
66
+ selfKey: DynamicColorKey;
67
+ referenceKey?: DynamicColorKey; // par défaut: la surface la plus "haute"
68
+ minContrast?: number; // par défaut: 3
69
+ },
70
+ ) => {
71
+ const { selfKey, referenceKey, minContrast = 3 } = options;
72
+
73
+ const referenceTone = referenceKey
74
+ ? colors.get(referenceKey).getTone()
75
+ : highestSurface(ctx, colors).getTone();
76
+
77
+ // On part du tone "source" défini dans les options (comme ton code `primary`).
78
+ const baseTone = (colors.get(selfKey) as ColorFromPalette).options.tone;
79
+
80
+ let selfTone = baseTone;
81
+ console.log('contrast ratio2', referenceTone, selfTone);
82
+ if (Contrast.ratioOfTones(referenceTone, selfTone) < minContrast) {
83
+ const ratio = calculateToneAdjustmentPercentage(
84
+ referenceTone,
85
+ selfTone,
86
+ minContrast,
87
+ );
88
+ const inverseT = inverseTone(baseTone);
89
+ selfTone = selfTone + (inverseT - selfTone) * ratio;
90
+ }
91
+
92
+ return selfTone;
93
+ };
94
+
56
95
  export const udixioVariant: Variant = variant({
57
96
  name: 'udixio',
58
97
  palettes: {
@@ -124,20 +163,21 @@ export const udixioVariant: Variant = variant({
124
163
  [colorKey]: {
125
164
  palette: () => palettes.get(colorKey),
126
165
  tone: () => {
127
- return ctx.isDark ? 80 : tMaxC(palettes.get(colorKey));
166
+ return colors.get('primary').getTone();
167
+ // return ctx.isDark ? 80 : tMaxC(palettes.get(colorKey));
128
168
  },
129
169
  isBackground: true,
130
- background: () => highestSurface(ctx, colors),
131
- contrastCurve: () => getCurve(4.5),
132
- adjustTone: () =>
133
- toneDeltaPair(
134
- colors.get(colorContainerKey),
135
- colors.get(colorKey),
136
- 5,
137
- 'relative_lighter',
138
- true,
139
- 'farther',
140
- ),
170
+ // background: () => highestSurface(ctx, colors),
171
+ // contrastCurve: () => getCurve(4.5),
172
+ // adjustTone: () =>
173
+ // toneDeltaPair(
174
+ // colors.get(colorContainerKey),
175
+ // colors.get(colorKey),
176
+ // 5,
177
+ // 'relative_lighter',
178
+ // true,
179
+ // 'farther',
180
+ // ),
141
181
  },
142
182
  // [colorDimKey]: {
143
183
  // palette: () => palettes.get(colorKey),
@@ -181,7 +221,15 @@ export const udixioVariant: Variant = variant({
181
221
  },
182
222
  isBackground: true,
183
223
  background: () => highestSurface(ctx, colors),
184
- adjustTone: () => undefined,
224
+ adjustTone: () =>
225
+ toneDeltaPair(
226
+ colors.get(colorKey),
227
+ colors.get(colorContainerKey),
228
+ 15,
229
+ 'relative_darker',
230
+ true,
231
+ 'farther',
232
+ ),
185
233
  contrastCurve: () =>
186
234
  ctx.contrastLevel > 0 ? getCurve(1.5) : undefined,
187
235
  },
@@ -380,20 +428,9 @@ export const udixioVariant: Variant = variant({
380
428
  background: () => highestSurface(ctx, colors),
381
429
  contrastCurve: () => getCurve(4.5),
382
430
  adjustTone: () => () => {
383
- const surfaceTone = colors.get('surface').getTone();
384
- const primaryTone = (colors.get('primary') as ColorFromPalette)
385
- .options.tone;
386
- let selfTone = primaryTone;
387
- if (Contrast.ratioOfTones(surfaceTone, selfTone) < 3) {
388
- const ratio = calculateToneAdjustmentPercentage(
389
- surfaceTone,
390
- selfTone,
391
- 3,
392
- );
393
- const inverseT = inverseTone(primaryTone);
394
- selfTone = selfTone + (inverseT - selfTone) * ratio;
395
- }
396
- return selfTone;
431
+ return createMinContrastToneAdjuster(ctx, colors, {
432
+ selfKey: 'primary',
433
+ });
397
434
  },
398
435
  },
399
436
  // primaryDim: {
@@ -510,20 +547,20 @@ export const udixioVariant: Variant = variant({
510
547
  secondary: {
511
548
  palette: () => palettes.get('secondary'),
512
549
  tone: () => {
513
- return ctx.isDark ? 80 : tMaxC(palettes.get('secondary'));
550
+ return colors.get('primary').getTone();
514
551
  },
515
552
  isBackground: true,
516
- background: () => highestSurface(ctx, colors),
517
- contrastCurve: () => getCurve(4.5),
518
- adjustTone: () =>
519
- toneDeltaPair(
520
- getColor('secondaryContainer'),
521
- getColor('secondary'),
522
- 5,
523
- 'relative_lighter',
524
- true,
525
- 'farther',
526
- ),
553
+ // background: () => highestSurface(ctx, colors),
554
+ // contrastCurve: () => getCurve(4.5),
555
+ // adjustTone: () =>
556
+ // toneDeltaPair(
557
+ // getColor('secondaryContainer'),
558
+ // getColor('secondary'),
559
+ // 5,
560
+ // 'relative_lighter',
561
+ // true,
562
+ // 'farther',
563
+ // ),
527
564
  },
528
565
  // secondaryDim: {
529
566
  // palette: () => palettes.get('secondary'),
@@ -559,7 +596,15 @@ export const udixioVariant: Variant = variant({
559
596
  },
560
597
  isBackground: true,
561
598
  background: () => highestSurface(ctx, colors),
562
- adjustTone: () => undefined,
599
+ adjustTone: () =>
600
+ toneDeltaPair(
601
+ colors.get('secondary'),
602
+ colors.get('secondaryContainer'),
603
+ 15,
604
+ 'relative_darker',
605
+ true,
606
+ 'farther',
607
+ ),
563
608
  contrastCurve: () =>
564
609
  ctx.contrastLevel > 0 ? getCurve(1.5) : undefined,
565
610
  },
@@ -621,22 +666,21 @@ export const udixioVariant: Variant = variant({
621
666
  tertiary: {
622
667
  palette: () => palettes.get('tertiary'),
623
668
  tone: () => {
624
- return ctx.isDark
625
- ? tMaxC(palettes.get('tertiary'), 0, 98)
626
- : tMaxC(palettes.get('tertiary'));
669
+ const tone = colors.get('primary').getTone();
670
+ return Math.max(20, Math.min(80, tone));
627
671
  },
628
672
  isBackground: true,
629
- background: () => highestSurface(ctx, colors),
630
- contrastCurve: () => getCurve(4.5),
631
- adjustTone: () =>
632
- toneDeltaPair(
633
- getColor('tertiaryContainer'),
634
- getColor('tertiary'),
635
- 5,
636
- 'relative_lighter',
637
- true,
638
- 'farther',
639
- ),
673
+ // background: () => highestSurface(ctx, colors),
674
+ // contrastCurve: () => getCurve(4.5),
675
+ // adjustTone: () =>
676
+ // toneDeltaPair(
677
+ // getColor('tertiaryContainer'),
678
+ // getColor('tertiary'),
679
+ // 5,
680
+ // 'relative_lighter',
681
+ // true,
682
+ // 'farther',
683
+ // ),
640
684
  },
641
685
  // tertiaryDim: {
642
686
  // palette: () => palettes.get('tertiary'),
@@ -672,7 +716,15 @@ export const udixioVariant: Variant = variant({
672
716
  },
673
717
  isBackground: true,
674
718
  background: () => highestSurface(ctx, colors),
675
- adjustTone: () => undefined,
719
+ adjustTone: () =>
720
+ toneDeltaPair(
721
+ colors.get('tertiary'),
722
+ colors.get('tertiaryContainer'),
723
+ 15,
724
+ 'relative_darker',
725
+ true,
726
+ 'farther',
727
+ ),
676
728
  contrastCurve: () =>
677
729
  ctx.contrastLevel > 0 ? getCurve(1.5) : undefined,
678
730
  },