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.
- package/dist/components/NavItem/index.js +34 -20
- package/package.json +1 -1
|
@@ -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 =
|
|
43
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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:
|
|
95
|
+
className: linkClassList,
|
|
82
96
|
onClick: onClick
|
|
83
97
|
}, name)));
|
|
84
98
|
};
|