@uxf/ui 1.0.0-beta.67 → 1.0.0-beta.68
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { CSSProperties } from "react";
|
|
2
2
|
import { FormControlProps } from "../types";
|
|
3
|
-
import { HexCodeString } from "
|
|
3
|
+
import { HexCodeString } from "../utils/isLightBackground";
|
|
4
4
|
export declare type ColorRadioGroupOptionValue = HexCodeString;
|
|
5
5
|
export interface ColorRadioGroupOption {
|
|
6
6
|
label: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { FormControlProps } from "../types";
|
|
3
|
-
|
|
3
|
+
import { HexCodeString } from "../utils/isLightBackground";
|
|
4
4
|
export interface ColorRadioProps extends FormControlProps<boolean> {
|
|
5
5
|
color: HexCodeString;
|
|
6
6
|
colorLabel: string;
|
|
@@ -8,13 +8,7 @@ const classes_1 = require("@uxf/core/constants/classes");
|
|
|
8
8
|
const cx_1 = require("@uxf/core/utils/cx");
|
|
9
9
|
const react_1 = __importDefault(require("react"));
|
|
10
10
|
const forwardRef_1 = require("@uxf/core/utils/forwardRef");
|
|
11
|
-
|
|
12
|
-
const color = bgColor.substring(1, 7);
|
|
13
|
-
const r = parseInt(color.substring(0, 2), 16); // hexToR
|
|
14
|
-
const g = parseInt(color.substring(2, 4), 16); // hexToG
|
|
15
|
-
const b = parseInt(color.substring(4, 6), 16); // hexToB
|
|
16
|
-
return r * 0.299 + g * 0.587 + b * 0.114 > 146;
|
|
17
|
-
}
|
|
11
|
+
const isLightBackground_1 = require("../utils/isLightBackground");
|
|
18
12
|
function CheckIcon() {
|
|
19
13
|
return (react_1.default.createElement("svg", { fill: "none", viewBox: "0 0 16 16" },
|
|
20
14
|
react_1.default.createElement("path", { d: "M13.333 4 6 11.333 2.667 8", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2" })));
|
|
@@ -23,6 +17,6 @@ exports.ColorRadio = (0, forwardRef_1.forwardRef)("ColorRadio", (props, ref) =>
|
|
|
23
17
|
const colorRadioStyle = { "--bg-color": props.color };
|
|
24
18
|
return (react_1.default.createElement("div", { className: (0, cx_1.cx)("uxf-color-radio", props.value && classes_1.CLASSES.IS_SELECTED), onClick: () => { var _a; return (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, !props.value); }, ref: ref, style: colorRadioStyle },
|
|
25
19
|
react_1.default.createElement("span", { className: "uxf-color-radio__label" }, props.colorLabel),
|
|
26
|
-
react_1.default.createElement("span", { className: `uxf-color-radio__icon ${isLightBackground(props.color) ? "uxf-color-radio__icon--dark" : ""}` },
|
|
20
|
+
react_1.default.createElement("span", { className: `uxf-color-radio__icon ${(0, isLightBackground_1.isLightBackground)(props.color) ? "uxf-color-radio__icon--dark" : ""}` },
|
|
27
21
|
react_1.default.createElement(CheckIcon, null))));
|
|
28
22
|
});
|
package/package.json
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isLightBackground = void 0;
|
|
4
|
+
function isLightBackground(bgColor) {
|
|
5
|
+
const color = bgColor.substring(1, 7);
|
|
6
|
+
const r = parseInt(color.substring(0, 2), 16); // hexToR
|
|
7
|
+
const g = parseInt(color.substring(2, 4), 16); // hexToG
|
|
8
|
+
const b = parseInt(color.substring(4, 6), 16); // hexToB
|
|
9
|
+
return r * 0.299 + g * 0.587 + b * 0.114 > 146;
|
|
10
|
+
}
|
|
11
|
+
exports.isLightBackground = isLightBackground;
|