File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
88## [ Unreleased]
99
10+ ### Fixed
11+
12+ - Fixed a problem where menu-open would be added to menu items without children
13+ - Menu styling is now using different colors for hovering and normal state
14+
15+ ### Added
16+
17+ - Added an option to provide additional classes to a menu item
18+ - Added an option to set the "active" class on menu items from the outside
19+
1020## [ 2.6.0] - 2023-08-16
1121
1222### Added
Original file line number Diff line number Diff line change @@ -5,12 +5,24 @@ export interface ISideBarMenuItem {
55 title : string ;
66 icon ?: IconProp ;
77 children ?: ISideBarMenuItem [ ] ;
8+
89 /**
910 * Whether the item is expanded.
1011 */
1112 expanded ?: boolean ;
13+
1214 /**
1315 * Whether the item should be displayed.
1416 */
1517 display ?: boolean ;
18+
19+ /**
20+ * classes that can be added by the user
21+ */
22+ className ?: string ;
23+
24+ /**
25+ * adds the active class to the element
26+ */
27+ isActive ?: boolean ;
1628}
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ const SideBarMenuProvider = (props: SideBarMenuProviderProps) => {
2424 const [ itemState , setItemState ] = useState ( items ) ;
2525
2626 const toggleItemInternal = ( item : ISideBarMenuItem , id : string ) => {
27- if ( item . id === id ) {
27+ if ( item . id === id && ( item . children ?. length ?? 0 ) > 0 ) {
2828 item . expanded = ! item . expanded ;
2929 }
3030
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import classNames from "classnames";
22import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" ;
33import { ISideBarMenuItem } from "./ISideBarMenuItem" ;
44import { IconProp } from "@fortawesome/fontawesome-svg-core" ;
5- import { NavItem , Collapse } from "reactstrap" ;
5+ import { Collapse } from "reactstrap" ;
66import { useSideBarMenuContext } from "./SideBarMenuContext" ;
77
88interface SideBarMenuItemProps {
@@ -22,10 +22,10 @@ const SideBarMenuItem = ({ item, depth = 0 }: SideBarMenuItemProps) => {
2222
2323 return (
2424 < >
25- < div >
26- < NavItem
25+ < div className = { classNames ( item . className , { "menu-open" : isOpen , active : item . isActive } ) } >
26+ < div
2727 onClick = { ( ) => toggleItem ( item . id ) }
28- className = { classNames ( { "menu-open" : isOpen } ) }
28+ className = { classNames ( "nav-item" , { "menu-open" : isOpen } ) }
2929 style = { { paddingLeft : `${ 0.5 * depth } rem` } }
3030 >
3131 { hasChildren ? (
@@ -49,7 +49,7 @@ const SideBarMenuItem = ({ item, depth = 0 }: SideBarMenuItemProps) => {
4949 </ LinkRenderer >
5050 </ >
5151 ) }
52- </ NavItem >
52+ </ div >
5353 { hasChildren && (
5454 < Collapse isOpen = { isOpen } navbar className = { classNames ( "items-menu" , { "mb-1" : isOpen } ) } >
5555 { item . children ?. map ( ( item , index ) => (
Original file line number Diff line number Diff line change @@ -34,8 +34,8 @@ $sidenav-dark-footer-bg: $gray-800;
3434$sidenav-light-bg : $gray-100 ;
3535$sidenav-light-color : $gray-900 ;
3636$sidenav-light-heading-color : $gray-500 ;
37- $sidenav-light-link-color : $sidenav-light-color ;
38- $sidenav-light-link-active-color : $primary ;
37+ $sidenav-light-link-color : $gray-600 ;
38+ $sidenav-light-link-active-color : $black ;
3939$sidenav-light-icon-color : $gray-500 ;
4040$sidenav-light-footer-bg : $gray-200 ;
4141
@@ -335,6 +335,25 @@ $topnav-light-toggler-color: $gray-900;
335335 color : $sidenav-dark-link-active-color ;
336336 }
337337 }
338+
339+ div .active {
340+ position : relative ;
341+
342+ .nav-item ::before {
343+ content : " " ;
344+ position : absolute ;
345+ top : 0 ;
346+ left : 0 ;
347+ width : 3px ;
348+ height : 100% ;
349+ background-color : $primary ;
350+ }
351+
352+ .nav-item .nav-link {
353+ color : $sidenav-dark-link-active-color ;
354+ font-weight : 600 ;
355+ }
356+ }
338357 }
339358 .sb-sidenav-menu {
340359 & ::-webkit-scrollbar {
@@ -382,3 +401,42 @@ $topnav-light-toggler-color: $gray-900;
382401 background-color : $sidenav-dark-footer-bg ;
383402 }
384403}
404+
405+ .sb-sidenav-light {
406+ .sb-sidenav-menu {
407+ .nav {
408+ .nav-item .nav-link {
409+ color : $sidenav-light-link-color ;
410+
411+ & :hover {
412+ color : $sidenav-light-link-active-color ;
413+ }
414+ }
415+
416+ .nav-item.menu-open .nav-link {
417+ & ::after ,
418+ div {
419+ color : $sidenav-light-link-active-color ;
420+ }
421+ }
422+ div .active {
423+ position : relative ;
424+
425+ .nav-item ::before {
426+ content : " " ;
427+ position : absolute ;
428+ top : 0 ;
429+ left : 0 ;
430+ width : 3px ;
431+ height : 100% ;
432+ background-color : $primary ;
433+ }
434+
435+ .nav-item .nav-link {
436+ color : $sidenav-light-link-active-color ;
437+ font-weight : 600 ;
438+ }
439+ }
440+ }
441+ }
442+ }
You can’t perform that action at this time.
0 commit comments