@orfium/ictinus 4.30.1 → 4.30.2

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.
@@ -9,7 +9,7 @@ export declare const buttonSpanStyle: () => () => {
9
9
  export declare const iconStyle: () => () => {
10
10
  display: string;
11
11
  };
12
- export declare const childrenWrapperStyle: ({ iconLeft, iconRight, hasChildren, }: RequiredProperties<Omit<Props, "onClick" | "dataTestId" | "block" | "buttonType" | "isIconButton"> & {
12
+ export declare const childrenWrapperStyle: ({ iconLeft, iconRight, hasChildren, }: RequiredProperties<Omit<Props, "onClick" | "dataTestId" | "block" | "isIconButton" | "buttonType"> & {
13
13
  hasChildren: boolean;
14
14
  }>) => (theme: Theme) => {
15
15
  marginLeft: number | "8";
@@ -38,27 +38,20 @@ var buttonBaseStyle = function buttonBaseStyle(_ref) {
38
38
  return function (theme) {
39
39
  var backGroundColor = (0, _utils2.defineBackgroundColor)(theme, calculatedColor, type, childrenCount > 0);
40
40
  var isOutlined = !filled && !transparent;
41
-
42
- var calculateButtonColor = function calculateButtonColor() {
43
- if (type === 'link') {
44
- var color = _config.buttonConfig.types.link.color;
45
- return theme.utils.getColor(color.name, color.shade);
46
- }
47
-
48
- if (isOutlined || transparent) {
49
- return backGroundColor;
50
- }
51
-
52
- return theme.utils.getAAColorFromSwatches(calculatedColor.color, calculatedColor.shade);
53
- };
54
-
41
+ var isBackgroundTransparent = isOutlined || transparent;
55
42
  var borderWidth = isOutlined ? _config.buttonConfig.types.outlined.border.width : 0;
56
43
  var baseButtonStyles = {
57
44
  fontSize: fontSizeBasedOnSize(theme, size),
58
45
  fontWeight: theme.typography.weights.medium,
59
- color: calculateButtonColor(),
46
+ color: (0, _utils2.calculateButtonColor)({
47
+ type: type,
48
+ isBackgroundTransparent: isBackgroundTransparent,
49
+ backGroundColor: backGroundColor,
50
+ calculatedColor: calculatedColor,
51
+ theme: theme
52
+ }),
60
53
  width: block ? '100%' : undefined,
61
- backgroundColor: isOutlined || transparent ? 'transparent' : backGroundColor,
54
+ backgroundColor: isBackgroundTransparent ? 'transparent' : backGroundColor,
62
55
  padding: size === 'lg' ? theme.spacing.md : "0 " + theme.spacing.md,
63
56
  height: heightBasedOnSize(size),
64
57
  borderRadius: theme.spacing.xsm,
@@ -75,14 +68,14 @@ var buttonBaseStyle = function buttonBaseStyle(_ref) {
75
68
  backgroundColor: (0, _states.getHover)({
76
69
  theme: theme,
77
70
  color: calculatedColor.color,
78
- shade: isOutlined || transparent ? 0 : calculatedColor.shade
71
+ shade: isBackgroundTransparent ? 0 : calculatedColor.shade
79
72
  }).backgroundColor
80
73
  },
81
74
  ':active:not(:disabled)': {
82
75
  backgroundColor: (0, _states.getPressed)({
83
76
  theme: theme,
84
77
  color: calculatedColor.color,
85
- shade: isOutlined || transparent ? 0 : calculatedColor.shade
78
+ shade: isBackgroundTransparent ? 0 : calculatedColor.shade
86
79
  }).backgroundColor
87
80
  },
88
81
  ':disabled': (0, _states.getDisabled)()
@@ -1,8 +1,21 @@
1
1
  import { Theme } from 'theme';
2
2
  import { ColorShapeFromComponent } from '../../utils/themeFunctions';
3
+ import { Props } from './ButtonBase';
3
4
  /**
4
5
  * This function defines what background-color to show based on type or color passed
5
6
  * if color it retrieves the color directly from the palette
6
7
  * if type it gets the specific type color from the palette
7
8
  */
8
9
  export declare const defineBackgroundColor: (theme: Theme, color: ColorShapeFromComponent | undefined, type?: "primary" | "secondary" | "success" | "error" | "warning" | "info" | "light" | "link" | undefined, childrenExists?: boolean | undefined) => string;
10
+ /**
11
+ * This function defines what color to show based on type or color passed
12
+ * if type is link uses the link color
13
+ * if it's background is transparent ( transparent or Outlined ) then it uses the background color
14
+ * else it uses the calculated color
15
+ */
16
+ export declare const calculateButtonColor: ({ type, isBackgroundTransparent, backGroundColor, calculatedColor, theme, }: Pick<Props, "type"> & {
17
+ calculatedColor: ColorShapeFromComponent;
18
+ isBackgroundTransparent: boolean;
19
+ backGroundColor: string;
20
+ theme: Theme;
21
+ }) => string;
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- exports.defineBackgroundColor = void 0;
4
+ exports.calculateButtonColor = exports.defineBackgroundColor = void 0;
5
5
 
6
6
  var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
7
7
 
8
8
  var _themeFunctions = require("../../utils/themeFunctions");
9
9
 
10
+ var _config = require("./config");
11
+
10
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
13
 
12
14
  /**
@@ -29,5 +31,33 @@ var defineBackgroundColor = function defineBackgroundColor(theme, color, type, c
29
31
 
30
32
  return 'transparent';
31
33
  };
34
+ /**
35
+ * This function defines what color to show based on type or color passed
36
+ * if type is link uses the link color
37
+ * if it's background is transparent ( transparent or Outlined ) then it uses the background color
38
+ * else it uses the calculated color
39
+ */
40
+
41
+
42
+ exports.defineBackgroundColor = defineBackgroundColor;
43
+
44
+ var calculateButtonColor = function calculateButtonColor(_ref) {
45
+ var type = _ref.type,
46
+ isBackgroundTransparent = _ref.isBackgroundTransparent,
47
+ backGroundColor = _ref.backGroundColor,
48
+ calculatedColor = _ref.calculatedColor,
49
+ theme = _ref.theme;
50
+
51
+ if (type === 'link') {
52
+ var color = _config.buttonConfig.types.link.color;
53
+ return theme.utils.getColor(color.name, color.shade);
54
+ }
55
+
56
+ if (isBackgroundTransparent) {
57
+ return backGroundColor;
58
+ }
59
+
60
+ return theme.utils.getAAColorFromSwatches(calculatedColor.color, calculatedColor.shade);
61
+ };
32
62
 
33
- exports.defineBackgroundColor = defineBackgroundColor;
63
+ exports.calculateButtonColor = calculateButtonColor;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orfium/ictinus",
3
- "version": "4.30.1",
3
+ "version": "4.30.2",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "license": "MIT",