trepur_components 0.2.14 → 0.2.15

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.
@@ -35,38 +35,52 @@ const NavItem = _ref => {
35
35
  hoverBgColor,
36
36
  bordered,
37
37
  rounded,
38
- underlineOnHover
38
+ underlineOnHover,
39
+ isActive,
40
+ activeBorderColor,
41
+ activeTextColor,
42
+ activeBgColor
39
43
  } = _ref;
40
44
  let classList = 'w-auto list-none ';
41
45
  classList += classes ? classes : '';
42
- let linkClassList = linkClasses && linkClasses;
43
- const underline = underlineOnHover && ' hover:underline'; //---------- Styling ---------------
46
+ let linkClassList = 'px-4 mx-2 mb-4 text-center whitespace-nowrap ';
47
+ linkClassList += bordered ? 'border ' : '';
48
+ linkClassList += rounded ? 'rounded-lg ' : '';
49
+ linkClassList += underlineOnHover ? 'hover:underline ' : '';
50
+ linkClassList += linkClasses ? linkClasses : ''; //---------- Styling ---------------
44
51
 
45
52
  const [styles, setStyles] = (0, _react.useState)({
46
53
  'backgroundColor': bgColor ? bgColor : 'white',
47
54
  color: textColor ? textColor : 'black',
48
55
  'borderColor': borderColor ? borderColor : 'black'
49
56
  });
57
+ const [activeStyles, setActiveStyles] = (0, _react.useState)({
58
+ 'backgroundColor': activeBgColor ? activeBgColor : 'white',
59
+ color: activeTextColor ? activeTextColor : 'black',
60
+ 'borderColor': activeBorderColor ? activeBorderColor : 'black'
61
+ });
50
62
 
51
63
  const setHoverState = isHovering => {
52
- if (isHovering) {
53
- setStyles({
54
- 'backgroundColor': hoverBgColor ? hoverBgColor : 'black',
55
- color: hoverTextColor ? hoverTextColor : 'white',
56
- 'borderColor': hoverBorderColor ? hoverBorderColor : 'black'
57
- });
58
- } else {
59
- setStyles({
60
- 'backgroundColor': bgColor ? bgColor : 'white',
61
- color: textColor ? textColor : 'black',
62
- 'borderColor': borderColor ? borderColor : 'black'
63
- });
64
- }
64
+ isHovering ? isActive ? setActiveStyles({
65
+ 'backgroundColor': activeBgColor ? activeBgColor : 'black',
66
+ color: activeTextColor ? activeTextColor : 'white',
67
+ 'borderColor': activeBorderColor ? activeBorderColor : 'black'
68
+ }) : setStyles({
69
+ 'backgroundColor': hoverBgColor ? hoverBgColor : 'black',
70
+ color: hoverTextColor ? hoverTextColor : 'white',
71
+ 'borderColor': hoverBorderColor ? hoverBorderColor : 'black'
72
+ }) : isActive ? setActiveStyles({
73
+ 'backgroundColor': activeBgColor ? activeBgColor : 'white',
74
+ color: activeTextColor ? activeTextColor : 'black',
75
+ 'borderColor': activeBorderColor ? activeBorderColor : 'black'
76
+ }) : setStyles({
77
+ 'backgroundColor': bgColor ? bgColor : 'white',
78
+ color: textColor ? textColor : 'black',
79
+ 'borderColor': borderColor ? borderColor : 'black'
80
+ });
65
81
  }; //-----------------------------------
66
82
 
67
83
 
68
- let borderClass = bordered ? ' border ' : '';
69
- let round = rounded ? ' rounded-lg ' : '';
70
84
  return /*#__PURE__*/_react.default.createElement("div", _extends({}, id && {
71
85
  id: id
72
86
  }, {
@@ -74,11 +88,11 @@ const NavItem = _ref => {
74
88
  }), /*#__PURE__*/_react.default.createElement("a", {
75
89
  href: url
76
90
  }, /*#__PURE__*/_react.default.createElement("li", {
77
- style: styles,
91
+ style: isActive ? activeStyles : styles,
78
92
  onMouseOver: () => setHoverState(true),
79
93
  onMouseOut: () => setHoverState(false),
80
94
  key: name,
81
- className: 'px-4 mx-2 mb-4 text-center whitespace-nowrap ' + linkClassList + borderClass + round + underline,
95
+ className: linkClassList,
82
96
  onClick: onClick
83
97
  }, name)));
84
98
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "trepur_components",
3
3
  "description": "component lib",
4
4
  "author": "trepur_ttenneb",
5
- "version": "0.2.14",
5
+ "version": "0.2.15",
6
6
  "private": false,
7
7
  "keywords": [
8
8
  "react",