Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ant-design/colors

Package Overview
Dependencies
Maintainers
10
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ant-design/colors - npm Package Compare versions

Comparing version 7.0.0 to 7.0.1-0

67

es/generate.js
import { inputToRGB, rgbToHex, rgbToHsv } from '@ctrl/tinycolor';
var hueStep = 2; // 色相阶梯
var saturationStep = 0.16; // 饱和度阶梯,浅色部分
var saturationStep2 = 0.05; // 饱和度阶梯,深色部分
var brightnessStep1 = 0.05; // 亮度阶梯,浅色部分
var brightnessStep2 = 0.15; // 亮度阶梯,深色部分
var lightColorCount = 5; // 浅色数量,主色上
var darkColorCount = 4; // 深色数量,主色下
// 暗色主题颜色映射关系表
var darkColorMap = [{

@@ -48,3 +41,2 @@ index: 7,

}];
// Wrapper function ported from TinyColor.prototype.toHsv

@@ -54,4 +46,4 @@ // Keep it here because of `hsv.h * 360`

var r = _ref.r,
g = _ref.g,
b = _ref.b;
g = _ref.g,
b = _ref.b;
var hsv = rgbToHsv(r, g, b);

@@ -63,16 +55,16 @@ return {

};
} // Wrapper function ported from TinyColor.prototype.toHexString
}
// Wrapper function ported from TinyColor.prototype.toHexString
// Keep it here because of the prefix `#`
function toHex(_ref2) {
var r = _ref2.r,
g = _ref2.g,
b = _ref2.b;
g = _ref2.g,
b = _ref2.b;
return "#".concat(rgbToHex(r, g, b, false));
} // Wrapper function ported from TinyColor.prototype.mix, not treeshakable.
}
// Wrapper function ported from TinyColor.prototype.mix, not treeshakable.
// Amount in range [0, 1]
// Assume color1 & color2 has no alpha, since the following src code did so.
function mix(rgb1, rgb2, amount) {

@@ -87,6 +79,5 @@ var p = amount / 100;

}
function getHue(hsv, i, light) {
var hue; // 根据色相不同,色相转向不同
var hue;
// 根据色相不同,色相转向不同
if (Math.round(hsv.h) >= 60 && Math.round(hsv.h) <= 240) {

@@ -97,3 +88,2 @@ hue = light ? Math.round(hsv.h) - hueStep * i : Math.round(hsv.h) + hueStep * i;

}
if (hue < 0) {

@@ -104,6 +94,4 @@ hue += 360;

}
return hue;
}
function getSaturation(hsv, i, light) {

@@ -114,5 +102,3 @@ // grey color don't change saturation

}
var saturation;
if (light) {

@@ -124,24 +110,18 @@ saturation = hsv.s - saturationStep * i;

saturation = hsv.s + saturationStep2 * i;
} // 边界值修正
}
// 边界值修正
if (saturation > 1) {
saturation = 1;
} // 第一格的 s 限制在 0.06-0.1 之间
}
// 第一格的 s 限制在 0.06-0.1 之间
if (light && i === lightColorCount && saturation > 0.1) {
saturation = 0.1;
}
if (saturation < 0.06) {
saturation = 0.06;
}
return Number(saturation.toFixed(2));
}
function getValue(hsv, i, light) {
var value;
if (light) {

@@ -152,10 +132,7 @@ value = hsv.v + brightnessStep1 * i;

}
if (value > 1) {
value = 1;
}
return Number(value.toFixed(2));
}
export default function generate(color) {

@@ -165,3 +142,2 @@ var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

var pColor = inputToRGB(color);
for (var i = lightColorCount; i > 0; i -= 1) {

@@ -176,8 +152,5 @@ var hsv = toHsv(pColor);

}
patterns.push(toHex(pColor));
for (var _i = 1; _i <= darkColorCount; _i += 1) {
var _hsv = toHsv(pColor);
var _colorString = toHex(inputToRGB({

@@ -188,11 +161,10 @@ h: getHue(_hsv, _i),

}));
patterns.push(_colorString);
} // dark theme patterns
}
// dark theme patterns
if (opts.theme === 'dark') {
return darkColorMap.map(function (_ref3) {
var index = _ref3.index,
opacity = _ref3.opacity;
opacity = _ref3.opacity;
var darkColorString = toHex(mix(inputToRGB(opts.backgroundColor || '#141414'), inputToRGB(patterns[index]), opacity * 100));

@@ -202,4 +174,3 @@ return darkColorString;

}
return patterns;
}

@@ -47,3 +47,3 @@ import generate from './generate';

};
export declare type PalettesProps = Record<string, string[] & {
export type PalettesProps = Record<string, string[] & {
primary?: string;

@@ -50,0 +50,0 @@ }>;

@@ -21,4 +21,5 @@ import generate from "./generate";

presetPalettes[key] = generate(presetPrimaryColors[key]);
presetPalettes[key].primary = presetPalettes[key][5]; // dark presetPalettes
presetPalettes[key].primary = presetPalettes[key][5];
// dark presetPalettes
presetDarkPalettes[key] = generate(presetPrimaryColors[key], {

@@ -25,0 +26,0 @@ theme: 'dark',

@@ -7,20 +7,11 @@ "use strict";

exports.default = generate;
var _tinycolor = require("@ctrl/tinycolor");
var hueStep = 2; // 色相阶梯
var saturationStep = 0.16; // 饱和度阶梯,浅色部分
var saturationStep2 = 0.05; // 饱和度阶梯,深色部分
var brightnessStep1 = 0.05; // 亮度阶梯,浅色部分
var brightnessStep2 = 0.15; // 亮度阶梯,深色部分
var lightColorCount = 5; // 浅色数量,主色上
var darkColorCount = 4; // 深色数量,主色下
// 暗色主题颜色映射关系表
var darkColorMap = [{

@@ -57,3 +48,2 @@ index: 7,

}];
// Wrapper function ported from TinyColor.prototype.toHsv

@@ -63,4 +53,4 @@ // Keep it here because of `hsv.h * 360`

var r = _ref.r,
g = _ref.g,
b = _ref.b;
g = _ref.g,
b = _ref.b;
var hsv = (0, _tinycolor.rgbToHsv)(r, g, b);

@@ -72,16 +62,16 @@ return {

};
} // Wrapper function ported from TinyColor.prototype.toHexString
}
// Wrapper function ported from TinyColor.prototype.toHexString
// Keep it here because of the prefix `#`
function toHex(_ref2) {
var r = _ref2.r,
g = _ref2.g,
b = _ref2.b;
g = _ref2.g,
b = _ref2.b;
return "#".concat((0, _tinycolor.rgbToHex)(r, g, b, false));
} // Wrapper function ported from TinyColor.prototype.mix, not treeshakable.
}
// Wrapper function ported from TinyColor.prototype.mix, not treeshakable.
// Amount in range [0, 1]
// Assume color1 & color2 has no alpha, since the following src code did so.
function mix(rgb1, rgb2, amount) {

@@ -96,6 +86,5 @@ var p = amount / 100;

}
function getHue(hsv, i, light) {
var hue; // 根据色相不同,色相转向不同
var hue;
// 根据色相不同,色相转向不同
if (Math.round(hsv.h) >= 60 && Math.round(hsv.h) <= 240) {

@@ -106,3 +95,2 @@ hue = light ? Math.round(hsv.h) - hueStep * i : Math.round(hsv.h) + hueStep * i;

}
if (hue < 0) {

@@ -113,6 +101,4 @@ hue += 360;

}
return hue;
}
function getSaturation(hsv, i, light) {

@@ -123,5 +109,3 @@ // grey color don't change saturation

}
var saturation;
if (light) {

@@ -133,24 +117,18 @@ saturation = hsv.s - saturationStep * i;

saturation = hsv.s + saturationStep2 * i;
} // 边界值修正
}
// 边界值修正
if (saturation > 1) {
saturation = 1;
} // 第一格的 s 限制在 0.06-0.1 之间
}
// 第一格的 s 限制在 0.06-0.1 之间
if (light && i === lightColorCount && saturation > 0.1) {
saturation = 0.1;
}
if (saturation < 0.06) {
saturation = 0.06;
}
return Number(saturation.toFixed(2));
}
function getValue(hsv, i, light) {
var value;
if (light) {

@@ -161,10 +139,7 @@ value = hsv.v + brightnessStep1 * i;

}
if (value > 1) {
value = 1;
}
return Number(value.toFixed(2));
}
function generate(color) {

@@ -174,3 +149,2 @@ var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

var pColor = (0, _tinycolor.inputToRGB)(color);
for (var i = lightColorCount; i > 0; i -= 1) {

@@ -185,8 +159,5 @@ var hsv = toHsv(pColor);

}
patterns.push(toHex(pColor));
for (var _i = 1; _i <= darkColorCount; _i += 1) {
var _hsv = toHsv(pColor);
var _colorString = toHex((0, _tinycolor.inputToRGB)({

@@ -197,11 +168,10 @@ h: getHue(_hsv, _i),

}));
patterns.push(_colorString);
} // dark theme patterns
}
// dark theme patterns
if (opts.theme === 'dark') {
return darkColorMap.map(function (_ref3) {
var index = _ref3.index,
opacity = _ref3.opacity;
opacity = _ref3.opacity;
var darkColorString = toHex(mix((0, _tinycolor.inputToRGB)(opts.backgroundColor || '#141414'), (0, _tinycolor.inputToRGB)(patterns[index]), opacity * 100));

@@ -211,4 +181,3 @@ return darkColorString;

}
return patterns;
}

@@ -47,3 +47,3 @@ import generate from './generate';

};
export declare type PalettesProps = Record<string, string[] & {
export type PalettesProps = Record<string, string[] & {
primary?: string;

@@ -50,0 +50,0 @@ }>;

@@ -14,8 +14,5 @@ "use strict";

exports.yellow = exports.volcano = exports.red = exports.purple = exports.presetPrimaryColors = exports.presetPalettes = exports.presetDarkPalettes = exports.orange = exports.magenta = exports.lime = exports.grey = exports.green = exports.gray = exports.gold = void 0;
var _generate = _interopRequireDefault(require("./generate"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var presetPrimaryColors = {
var presetPrimaryColors = exports.presetPrimaryColors = {
red: '#F5222D',

@@ -35,11 +32,9 @@ volcano: '#FA541C',

};
exports.presetPrimaryColors = presetPrimaryColors;
var presetPalettes = {};
exports.presetPalettes = presetPalettes;
var presetDarkPalettes = {};
exports.presetDarkPalettes = presetDarkPalettes;
var presetPalettes = exports.presetPalettes = {};
var presetDarkPalettes = exports.presetDarkPalettes = {};
Object.keys(presetPrimaryColors).forEach(function (key) {
presetPalettes[key] = (0, _generate.default)(presetPrimaryColors[key]);
presetPalettes[key].primary = presetPalettes[key][5]; // dark presetPalettes
presetPalettes[key].primary = presetPalettes[key][5];
// dark presetPalettes
presetDarkPalettes[key] = (0, _generate.default)(presetPrimaryColors[key], {

@@ -51,29 +46,15 @@ theme: 'dark',

});
var red = presetPalettes.red;
exports.red = red;
var volcano = presetPalettes.volcano;
exports.volcano = volcano;
var gold = presetPalettes.gold;
exports.gold = gold;
var orange = presetPalettes.orange;
exports.orange = orange;
var yellow = presetPalettes.yellow;
exports.yellow = yellow;
var lime = presetPalettes.lime;
exports.lime = lime;
var green = presetPalettes.green;
exports.green = green;
var cyan = presetPalettes.cyan;
exports.cyan = cyan;
var blue = presetPalettes.blue;
exports.blue = blue;
var geekblue = presetPalettes.geekblue;
exports.geekblue = geekblue;
var purple = presetPalettes.purple;
exports.purple = purple;
var magenta = presetPalettes.magenta;
exports.magenta = magenta;
var grey = presetPalettes.grey;
exports.grey = grey;
var gray = presetPalettes.grey;
exports.gray = gray;
var red = exports.red = presetPalettes.red;
var volcano = exports.volcano = presetPalettes.volcano;
var gold = exports.gold = presetPalettes.gold;
var orange = exports.orange = presetPalettes.orange;
var yellow = exports.yellow = presetPalettes.yellow;
var lime = exports.lime = presetPalettes.lime;
var green = exports.green = presetPalettes.green;
var cyan = exports.cyan = presetPalettes.cyan;
var blue = exports.blue = presetPalettes.blue;
var geekblue = exports.geekblue = presetPalettes.geekblue;
var purple = exports.purple = presetPalettes.purple;
var magenta = exports.magenta = presetPalettes.magenta;
var grey = exports.grey = presetPalettes.grey;
var gray = exports.gray = presetPalettes.grey;
{
"name": "@ant-design/colors",
"version": "7.0.0",
"version": "7.0.1-0",
"description": "Color palettes calculator of Ant Design",

@@ -24,3 +24,3 @@ "homepage": "https://github.com/ant-design/ant-design-colors#readme",

"compile": "father build",
"coverage": "npm test -- --coverage && coveralls < coverage/lcov.info",
"coverage": "npm test -- --coverage",
"lint": "eslint src --ext .ts",

@@ -32,3 +32,3 @@ "prepublishOnly": "npm run compile && np --no-cleanup --no-publish",

"dependencies": {
"@ctrl/tinycolor": "^3.4.0"
"@ctrl/tinycolor": "^4.0.2"
},

@@ -38,3 +38,2 @@ "devDependencies": {

"@umijs/fabric": "^3.0.0",
"coveralls": "^3.1.1",
"eslint": "^7.1.0",

@@ -41,0 +40,0 @@ "father": "^4.1.2",

@@ -7,6 +7,20 @@ <h1 align="center">Ant Design Colors</h1>

[![Travis](https://img.shields.io/travis/ant-design/ant-design-colors/master.svg?style=flat-square)](https://travis-ci.org/ant-design/ant-design-colors) [![Test coverage](https://img.shields.io/coveralls/ant-design/ant-design-colors.svg?style=flat-square)](https://coveralls.io/r/ant-design/ant-design-colors?branch=master) [![npm package](https://img.shields.io/npm/v/@ant-design/colors.svg?style=flat-square)](https://www.npmjs.org/package/@ant-design/colors) [![NPM downloads](http://img.shields.io/npm/dm/@ant-design/colors.svg?style=flat-square)](http://npmjs.com/@ant-design/colors)
[![CI status][github-action-image]][github-action-url]
[![codecov][codecov-image]][codecov-url]
[![NPM version][npm-image]][npm-url]
[![NPM downloads][download-image]][download-url]
[![][bundlephobia-image]][bundlephobia-url]
[![Dependencies](https://img.shields.io/david/ant-design/ant-design-colors.svg?style=flat-square)](https://david-dm.org/ant-design/ant-design-colors) [![DevDependencies](https://img.shields.io/david/dev/ant-design/ant-design-colors.svg?style=flat-square)](https://david-dm.org/ant-design/ant-design-colors?type=dev) [![Greenkeeper badge](https://badges.greenkeeper.io/ant-design/ant-design-colors.svg)](https://greenkeeper.io/)
![](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/rainbow.png)
[npm-image]: http://img.shields.io/npm/v/@ant-design/colors.svg?style=flat-square
[npm-url]: http://npmjs.org/package/@ant-design/colors
[github-action-image]: https://github.com/ant-design/ant-design-colors/actions/workflows/ci.yml/badge.svg
[github-action-url]: https://github.com/ant-design/ant-design-colors/actions/workflows/ci.yml
[codecov-image]: https://img.shields.io/codecov/c/github/ant-design/ant-design-colors/main.svg?style=flat-square
[codecov-url]: https://codecov.io/gh/ant-design/ant-design-colors/tree/main
[download-image]: https://img.shields.io/npm/dm/@ant-design/colors.svg?style=flat-square
[download-url]: https://npmjs.org/package/@ant-design/colors
[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/@ant-design/colors?style=flat-square
[bundlephobia-url]: https://bundlephobia.com/package/@ant-design/colors
</div>

@@ -13,0 +27,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc