Skip to content

backgroundcolor.js is using depreciated colorspace #280

@karim-semmoud

Description

@karim-semmoud

Description

When using @adobe/leonardo-contrast-colors, deprecation warnings are printed repeatedly:

Leonardo: `colorspace` is deprecated. Use `colorSpace` instead.

This happens even when the caller uses the non-deprecated colorSpace API. The warning is emitted internally by the library during background scale generation.

Steps to Reproduce

  1. Install @adobe/leonardo-contrast-colors (version below).
  2. Run a minimal script that instantiates BackgroundColor / Theme and accesses generated values, or run your theme generation.

Minimal Node repro:

import { Theme, Color, BackgroundColor } from '@adobe/leonardo-contrast-colors';

const bg = new BackgroundColor({
  name: 'bg',
  colorKeys: ['#111111'],
  ratios: [2, 3, 4.5, 8],
  colorSpace: 'LCH',
});

const fg = new Color({
  name: 'fg',
  colorKeys: ['#ffffff'],
  ratios: [4.5],
  colorSpace: 'LCH',
});

const theme = new Theme({
  colors: [bg, fg],
  backgroundColor: bg,
  lightness: 20,
});

console.log(theme.contrastColors);

Expected Behavior

No deprecation warnings should be emitted when callers use colorSpace.

Actual Behavior

The library prints the deprecation warning many times during scale generation.

Package and Version

  • Package: @adobe/leonardo-contrast-colors
  • Version: 1.1.0

Environment

  • OS: Linux

Root Cause

The warning is produced inside the Leonardo package itself:

  • lib/utils.js warns when createScale() receives a colorspace argument:
    createScale({ ..., colorspace, colorSpace = ... })
    // logs warning when colorspace !== undefined
  • lib/backgroundcolor.js calls createScale() with the deprecated key:
    createScale({ ..., colorspace: this._colorspace, ... })

So even though the caller's code uses colorSpace, the library internally forwards colorspace and triggers the warning spam.

Proposed Fix

Update lib/backgroundcolor.js to pass colorSpace (camelCase) to createScale() instead of colorspace:

- colorspace: this._colorspace,
+ colorSpace: this._colorspace,

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions