Просмотр исходного кода

append custom class to GlobalItem

Yuki Takei 6 лет назад
Родитель
Сommit
44e06052fe
1 измененных файлов с 13 добавлено и 4 удалено
  1. 13 4
      src/client/js/components/Sidebar/SidebarNav.jsx

+ 13 - 4
src/client/js/components/Sidebar/SidebarNav.jsx

@@ -5,6 +5,7 @@ import { withTranslation } from 'react-i18next';
 
 
 import {
 import {
   GlobalNav,
   GlobalNav,
+  GlobalItem,
 } from '@atlaskit/navigation-next';
 } from '@atlaskit/navigation-next';
 
 
 import { createSubscribedElement } from '../UnstatedUtils';
 import { createSubscribedElement } from '../UnstatedUtils';
@@ -29,12 +30,20 @@ class SidebarNav extends React.Component {
   }
   }
 
 
   generateSidebarItemObj(id, label, icon) {
   generateSidebarItemObj(id, label, icon) {
+    const isSelected = this.props.currentContentsId === id;
+
     return {
     return {
       id,
       id,
-      icon,
-      label,
-      isSelected: this.props.currentContentsId === id,
-      onClick: () => this.itemSelectedHandler(id),
+      component: ({ className, onClick }) => (
+        <div className={`${className} grw-global-item-container ${isSelected ? 'active' : ''}`}>
+          <GlobalItem
+            icon={icon}
+            label={label}
+            isSelected={isSelected}
+            onClick={onClick}
+          />
+        </div>
+      ),
     };
     };
   }
   }