@skbkontur/colors 1.1.2-75bba.0 → 1.1.2-b2742.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ interface InteractionColors {
2
+ light: string;
3
+ dark: string;
4
+ }
5
+ export declare function getHover(hex: string): InteractionColors;
6
+ export declare function getPressed(hex: string): InteractionColors;
7
+ export {};
@@ -0,0 +1,35 @@
1
+ import { converter } from 'culori';
2
+ import { HOVER_LIGHT_L, HOVER_LIGHT_C, HOVER_DARK_L, HOVER_DARK_C, PRESSED_LIGHT_L, PRESSED_LIGHT_C, PRESSED_DARK_L, PRESSED_DARK_C, } from '../constants/interaction-settings';
3
+ function applyOklchDelta(oklchColor, dL, dC) {
4
+ var _a = oklchColor.l, l = _a === void 0 ? 0 : _a, _b = oklchColor.c, c = _b === void 0 ? 0 : _b, _c = oklchColor.h, h = _c === void 0 ? 0 : _c;
5
+ var safeH = h === undefined || isNaN(h) ? 0 : h;
6
+ var newL = Math.max(0, Math.min(1, l + dL / 100));
7
+ var newC = Math.max(0, c + dC);
8
+ return "oklch(".concat(newL.toFixed(3), " ").concat(newC.toFixed(3), " ").concat(safeH.toFixed(0), ")");
9
+ }
10
+ export function getHover(hex) {
11
+ var toOklch = converter('oklch');
12
+ var oklchColor = toOklch(hex);
13
+ if (!oklchColor) {
14
+ return { light: hex, dark: hex };
15
+ }
16
+ var lightHoverColor = applyOklchDelta(oklchColor, HOVER_LIGHT_L, HOVER_LIGHT_C);
17
+ var darkHoverColor = applyOklchDelta(oklchColor, HOVER_DARK_L, HOVER_DARK_C);
18
+ return {
19
+ light: lightHoverColor,
20
+ dark: darkHoverColor,
21
+ };
22
+ }
23
+ export function getPressed(hex) {
24
+ var toOklch = converter('oklch');
25
+ var oklchColor = toOklch(hex);
26
+ if (!oklchColor) {
27
+ return { light: hex, dark: hex };
28
+ }
29
+ var lightPressedColor = applyOklchDelta(oklchColor, PRESSED_LIGHT_L, PRESSED_LIGHT_C);
30
+ var darkPressedColor = applyOklchDelta(oklchColor, PRESSED_DARK_L, PRESSED_DARK_C);
31
+ return {
32
+ light: lightPressedColor,
33
+ dark: darkPressedColor,
34
+ };
35
+ }
@@ -22,6 +22,7 @@ export declare function calculateBaseHueAndCorrectionRange(inputColorString: str
22
22
  } | null;
23
23
  export declare function calcOnBrand(hex: string): {
24
24
  4: string;
25
+ 6: string;
25
26
  8: string;
26
27
  12: string;
27
28
  16: string;
@@ -45,5 +46,6 @@ export declare function calcOnBrand(hex: string): {
45
46
  88: string;
46
47
  92: string;
47
48
  96: string;
49
+ 100: string;
48
50
  };
49
51
  export {};
@@ -1,8 +1,8 @@
1
1
  export interface BaseTokens {
2
- brandLogo: ThemedValue;
3
- brandPromo: ThemedValue;
4
2
  brand: {
5
- original: ThemedValue;
3
+ logo: ThemedValue;
4
+ original: string;
5
+ promo: string;
6
6
  interactions: {
7
7
  hover: ThemedValue;
8
8
  pressed: ThemedValue;
@@ -33,6 +33,7 @@ export interface BaseTokens {
33
33
  blueDeep: ColorPalette;
34
34
  violet: ColorPalette;
35
35
  purple: ColorPalette;
36
+ yellow: ColorPalette;
36
37
  };
37
38
  }
38
39
  export interface ColorPalette {
@@ -41,8 +42,8 @@ export interface ColorPalette {
41
42
  dim: ColorWithScale<ChromaScale>;
42
43
  }
43
44
  type ChromaScale = 20 | 24 | 28 | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | 96;
44
- type AlphaScale = 4 | 8 | 12 | 16 | 20 | 24 | 28 | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | 96;
45
- type GrayScale = 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | 96 | 98 | 100;
45
+ type AlphaScale = 4 | 6 | 8 | 12 | 16 | 20 | 24 | 28 | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | 96 | 100;
46
+ type GrayScale = 0 | 16 | 20 | 24 | 28 | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | 96 | 98 | 100;
46
47
  type ColorWithScale<T extends string | number> = {
47
48
  [K in T]: string;
48
49
  };
package/package.json CHANGED
@@ -1,17 +1,18 @@
1
1
  {
2
2
  "name": "@skbkontur/colors",
3
- "version": "1.1.2-75bba.0",
3
+ "version": "1.1.2-b2742.0",
4
4
  "author": "Kontur",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "registry": "https://registry.npmjs.org/"
8
8
  },
9
- "module": "dist/esm/get-tokens.js",
10
- "main": "dist/cjs/get-tokens.js",
9
+ "module": "dist/esm/get-colors.js",
10
+ "main": "dist/cjs/get-colors.js",
11
11
  "license": "UNLICENSED",
12
12
  "scripts": {
13
13
  "clean": "git clean -fdxqe node_modules",
14
- "generate": "rimraf dist && node --require ./scripts/babel-register -- scripts/generate.ts && prettier ./tokens * --write",
14
+ "extract-tokens": "node --require ./scripts/babel-register -- scripts/extract-tokens-from-figma.ts",
15
+ "generate": "rimraf dist && node --require ./scripts/babel-register -- scripts/generate.ts && prettier ./tokens * --write && npx stylelint \"**/*.{css,scss,less}\" --fix",
15
16
  "build": "npm run build:cjs && npm run build:esm",
16
17
  "build:cjs": "tsc -p tsconfig.cjs.json",
17
18
  "build:esm": "tsc -p tsconfig.esm.json"
@@ -1,15 +0,0 @@
1
- import { type ConfigOptions } from './get-base-tokens';
2
- import { getDefaultTokens } from './get-default-tokens';
3
- import type { BaseTokens } from './types/base-tokens';
4
- export interface Themed<T> {
5
- light: T;
6
- dark: T;
7
- }
8
- export type DefaultTokens = ReturnType<typeof getDefaultTokens>;
9
- export interface SemanticConfigOptions<DefaultTokens> extends ConfigOptions {
10
- overrides?: (base: BaseTokens) => Themed<DefaultTokens>;
11
- }
12
- export declare function getTokens(params: SemanticConfigOptions<DefaultTokens>): DefaultTokens;
13
- export declare function getTokens<T>(params: SemanticConfigOptions<T> & {
14
- overrides: (base: BaseTokens) => Themed<T>;
15
- }): Themed<T>;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTokens = void 0;
4
- var get_base_tokens_1 = require("./get-base-tokens");
5
- var get_default_tokens_1 = require("./get-default-tokens");
6
- function getTokens(params) {
7
- var base = (0, get_base_tokens_1.getBaseTokens)(params);
8
- if (params.overrides) {
9
- return params.overrides(base);
10
- }
11
- return (0, get_default_tokens_1.getDefaultTokens)(base);
12
- }
13
- exports.getTokens = getTokens;
@@ -1,15 +0,0 @@
1
- import { type ConfigOptions } from './get-base-tokens';
2
- import { getDefaultTokens } from './get-default-tokens';
3
- import type { BaseTokens } from './types/base-tokens';
4
- export interface Themed<T> {
5
- light: T;
6
- dark: T;
7
- }
8
- export type DefaultTokens = ReturnType<typeof getDefaultTokens>;
9
- export interface SemanticConfigOptions<DefaultTokens> extends ConfigOptions {
10
- overrides?: (base: BaseTokens) => Themed<DefaultTokens>;
11
- }
12
- export declare function getTokens(params: SemanticConfigOptions<DefaultTokens>): DefaultTokens;
13
- export declare function getTokens<T>(params: SemanticConfigOptions<T> & {
14
- overrides: (base: BaseTokens) => Themed<T>;
15
- }): Themed<T>;
@@ -1,9 +0,0 @@
1
- import { getBaseTokens } from './get-base-tokens';
2
- import { getDefaultTokens } from './get-default-tokens';
3
- export function getTokens(params) {
4
- var base = getBaseTokens(params);
5
- if (params.overrides) {
6
- return params.overrides(base);
7
- }
8
- return getDefaultTokens(base);
9
- }