adobe / adobe/leonardo

backgroundcolor.js is using depreciated `colorspace`

Open
#280 2 comments 1 reaction 1 assignee Claimed by @karim-semmoud View on GitHub
bug
Dominant language
JavaScript
Stars
2.1k
Forks
130
PR merge metrics
No merged PRs in 30d

Description

## 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:**

```js
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:
```js
createScale({ ..., colorspace, colorSpace = ... })
// logs warning when colorspace !== undefined
```
- `lib/backgroundcolor.js` calls `createScale()` with the **deprecated** key:
```js
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`:

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.