@orfium/ictinus 4.11.0 → 4.12.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.
- package/dist/theme/palette.d.ts +2 -1
- package/dist/theme/palette.js +16 -24
- package/package.json +1 -1
package/dist/theme/palette.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ export declare type Palette = {
|
|
|
44
44
|
export declare type formFieldStyles = 'filled' | 'outlined' | 'elevated';
|
|
45
45
|
/**
|
|
46
46
|
* this function picks either white or black color based on the background that is passed
|
|
47
|
-
* swatches are calculated based on accessibility by
|
|
47
|
+
* swatches are calculated based on accessibility by getAATextColor function and splited to those two colors
|
|
48
48
|
**/
|
|
49
49
|
export declare const pickTextColorFromSwatches: (color: typeof flatColors[number], shade: typeof colorShades[number]) => string;
|
|
50
|
+
export declare const getAATextColor: (color: string) => string;
|
package/dist/theme/palette.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.pickTextColorFromSwatches = exports.mainTypes = exports.colorShades = exports.paleColors = exports.flatColors = exports.BASE_SHADE = exports.neutralColors = void 0;
|
|
4
|
+
exports.getAATextColor = exports.pickTextColorFromSwatches = exports.mainTypes = exports.colorShades = exports.paleColors = exports.flatColors = exports.BASE_SHADE = exports.neutralColors = void 0;
|
|
5
|
+
|
|
6
|
+
var _polished = require("polished");
|
|
5
7
|
|
|
6
8
|
var _index = require("./index");
|
|
7
9
|
|
|
@@ -48,31 +50,21 @@ exports.mainTypes = mainTypes;
|
|
|
48
50
|
|
|
49
51
|
/**
|
|
50
52
|
* this function picks either white or black color based on the background that is passed
|
|
51
|
-
* swatches are calculated based on accessibility by
|
|
53
|
+
* swatches are calculated based on accessibility by getAATextColor function and splited to those two colors
|
|
52
54
|
**/
|
|
53
55
|
var pickTextColorFromSwatches = function pickTextColorFromSwatches(color, shade) {
|
|
54
|
-
var colors950To750 = ['greyScale', 'darkGrey', 'lightGrey', 'red', 'magenta', 'purple', 'darkBlue', 'blue', 'lightBlue', 'teal', 'green', 'yellow', 'orange', 'darkOrange', 'neutralBlack'];
|
|
55
|
-
var colorsForWhiteText = {
|
|
56
|
-
950: colors950To750,
|
|
57
|
-
900: colors950To750,
|
|
58
|
-
850: colors950To750,
|
|
59
|
-
800: colors950To750,
|
|
60
|
-
750: colors950To750,
|
|
61
|
-
700: ['greyScale', 'darkGrey', 'lightGrey', 'red', 'magenta', 'purple', 'darkBlue', 'blue', 'lightBlue', 'green', 'orange', 'darkOrange'],
|
|
62
|
-
650: ['greyScale', 'darkGrey', 'lightGrey', 'red', 'magenta', 'purple', 'darkBlue', 'blue', 'green', 'orange', 'darkOrange'],
|
|
63
|
-
600: ['greyScale', 'darkGrey', 'red', 'magenta', 'purple', 'darkBlue', 'blue', 'darkOrange'],
|
|
64
|
-
550: ['greyScale', 'darkGrey', 'red', 'magenta', 'purple', 'darkBlue', 'blue', 'darkOrange'],
|
|
65
|
-
500: ['darkGrey', 'magenta', 'purple', 'darkBlue', 'blue', 'darkOrange'],
|
|
66
|
-
450: ['darkGrey', 'purple', 'darkBlue', 'blue', 'darkOrange'],
|
|
67
|
-
400: ['darkGrey', 'darkOrange'],
|
|
68
|
-
350: ['darkGrey', 'darkOrange']
|
|
69
|
-
};
|
|
70
|
-
var pickedShade = colorsForWhiteText[shade];
|
|
71
|
-
var pickedColor = pickedShade && (pickedShade == null ? void 0 : pickedShade.find(function (item) {
|
|
72
|
-
return item === color;
|
|
73
|
-
})) || color === 'neutralBlack';
|
|
74
56
|
var palette = (0, _utils.enhancePaletteWithShades)(_palette.lightPaletteConfig);
|
|
75
|
-
|
|
57
|
+
var hexColorCode = (0, _index.getColor)(palette)(color, shade);
|
|
58
|
+
return getAATextColor(hexColorCode);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
exports.pickTextColorFromSwatches = pickTextColorFromSwatches;
|
|
62
|
+
|
|
63
|
+
var getAATextColor = function getAATextColor(color) {
|
|
64
|
+
var palette = (0, _utils.enhancePaletteWithShades)(_palette.lightPaletteConfig);
|
|
65
|
+
var white = palette.white;
|
|
66
|
+
var black = palette.black;
|
|
67
|
+
return (0, _polished.getContrast)(color, black) > (0, _polished.getContrast)(color, white) ? black : white;
|
|
76
68
|
};
|
|
77
69
|
|
|
78
|
-
exports.
|
|
70
|
+
exports.getAATextColor = getAATextColor;
|