material-foundation / material-color-utilities

Color libraries for Material You
Apache License 2.0
1.57k stars 134 forks source link

`DynamicScheme` is impossible to construct in TypeScript #151

Closed JoshuaBrest closed 3 days ago

JoshuaBrest commented 1 month ago

In the current TypeScript implementation, it is impossible to construct a DynamicScheme. The constructor for DynamicScheme requires the Variant enum, which is not a const enum. This enum is not exported. Additionally, no functionality is available to auto-generate a DynamicScheme from a given color or image, which limits dynamic usability.

Fix

File: typescript/index.ts

  export * from './dynamiccolor/dynamic_color.js';
  export * from './dynamiccolor/dynamic_scheme.js';
  export * from './dynamiccolor/material_dynamic_colors.js';
+ export * from './dynamiccolor/variant.js';
anh2111htdd commented 3 days ago

I've exported variant as you suggested. To construct a DynamicScheme in most case, you can use one of the constructors in https://github.com/material-foundation/material-color-utilities/tree/main/typescript/scheme.