Skip to content

Commit a0f3f7b

Browse files
author
Hadas Farhi
authored
export color utils as default object (for fixing error while trying to create new version) (mondaycom#387)
1 parent 87dc92e commit a0f3f7b

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/components/ColorPicker/components/ColorPickerItemComponent/ColorPickerItemComponent.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import PropTypes from "prop-types";
33
import cx from "classnames";
44
import NOOP from "lodash/noop";
55
import { COLOR_STYLES } from "../../../../general-stories/colors/colors-vars-map";
6-
import { getMondayColorAsStyle } from "../../../../utils/colors-utils";
6+
import ColorUtils from "../../../../utils/colors-utils";
77
import "./ColorPickerItemComponent.scss";
88
import Icon from "../../../Icon/Icon";
99
import Tooltip from "../../../Tooltip/Tooltip";
@@ -22,7 +22,7 @@ const ColorPickerItemComponent = ({
2222
colorSize,
2323
tooltipContent
2424
}) => {
25-
const colorAsStyle = getMondayColorAsStyle(color, colorStyle);
25+
const colorAsStyle = ColorUtils.getMondayColorAsStyle(color, colorStyle);
2626
const itemRef = useRef(null);
2727

2828
const onMouseDown = useCallback(e => e.preventDefault(), []);
@@ -33,9 +33,9 @@ const ColorPickerItemComponent = ({
3333
const item = itemRef.current;
3434
const onHover = e => {
3535
if (colorStyle === COLOR_STYLES.SELECTED) {
36-
e.target.style.background = getMondayColorAsStyle(color, COLOR_STYLES.REGULAR);
36+
e.target.style.background = ColorUtils.getMondayColorAsStyle(color, COLOR_STYLES.REGULAR);
3737
} else {
38-
e.target.style.background = getMondayColorAsStyle(color, COLOR_STYLES.SELECTED);
38+
e.target.style.background = ColorUtils.getMondayColorAsStyle(color, COLOR_STYLES.SELECTED);
3939
}
4040
};
4141
const onMouseLeave = e => {

src/utils/colors-utils.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
import { COLOR_STYLES } from "../general-stories/colors/colors-vars-map";
22

3-
export const getMondayColorAsStyle = (color, mode = COLOR_STYLES.REGULAR, withVar = true) =>
4-
`${withVar ? "var(" : ""}--color-${color}${mode !== COLOR_STYLES.REGULAR ? `-${mode}` : ""}${withVar ? ")" : ""}`;
3+
const ColorUtils = {
4+
getMondayColorAsStyle: (color, mode = COLOR_STYLES.REGULAR, withVar = true) =>
5+
`${withVar ? "var(" : ""}--color-${color}${mode !== COLOR_STYLES.REGULAR ? `-${mode}` : ""}${withVar ? ")" : ""}`
6+
};
7+
8+
export default Object.freeze(ColorUtils);

0 commit comments

Comments
 (0)