material-chalk
Version:
Generate beautiful colors from namespaces based on color theory
36 lines (35 loc) • 1.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.sourceAsPrimary = sourceAsPrimary;
exports.overrideSourceAsPrimary = overrideSourceAsPrimary;
exports.buildScheme = buildScheme;
const material_color_utilities_1 = require("@material/material-color-utilities");
/**
* Overrides the primaryPalette of the DynamicScheme at constructor-time
*/
function sourceAsPrimary(baseScheme) {
class DirectScheme extends baseScheme {
constructor(...args) {
super(...args);
// cast away "readonly"
this.primaryPalette = material_color_utilities_1.TonalPalette.fromHct(this.sourceColorHct);
}
}
return DirectScheme;
}
/**
* Overrides the primaryPalette of the DynamicScheme at runtime
*/
function overrideSourceAsPrimary(dynamicScheme) {
// cast away "readonly"
dynamicScheme.primaryPalette = material_color_utilities_1.TonalPalette.fromHct(dynamicScheme.sourceColorHct);
return dynamicScheme;
}
/**
* Returns a DynamicScheme constructor with the first parameter pre-filled with the constructed color
*/
function buildScheme(Scheme, fixedValue) {
return (...args) => {
return new Scheme(fixedValue, ...args);
};
}