Explorar o código

change how toolbar parsed/displays empty sections

Adam Shaw %!s(int64=6) %!d(string=hai) anos
pai
achega
a65cf13a37
Modificáronse 2 ficheiros con 18 adicións e 20 borrados
  1. 12 14
      packages/core/src/Toolbar.tsx
  2. 6 6
      packages/core/src/toolbar-parse.ts

+ 12 - 14
packages/core/src/Toolbar.tsx

@@ -37,22 +37,20 @@ export default class Toolbar extends BaseComponent<ToolbarProps> {
   }
 
 
-  renderSection(position: string, widgetGroups: ToolbarWidget[][] | null) {
+  renderSection(position: string, widgetGroups: ToolbarWidget[][]) {
     let { props } = this
 
-    if (widgetGroups) {
-      return (
-        <ToolbarSection
-          position={position}
-          widgetGroups={widgetGroups}
-          title={props.title}
-          activeButton={props.activeButton}
-          isTodayEnabled={props.isTodayEnabled}
-          isPrevEnabled={props.isPrevEnabled}
-          isNextEnabled={props.isNextEnabled}
-        />
-      )
-    }
+    return (
+      <ToolbarSection
+        position={position}
+        widgetGroups={widgetGroups}
+        title={props.title}
+        activeButton={props.activeButton}
+        isTodayEnabled={props.isTodayEnabled}
+        isPrevEnabled={props.isPrevEnabled}
+        isNextEnabled={props.isNextEnabled}
+      />
+    )
   }
 
 }

+ 6 - 6
packages/core/src/toolbar-parse.ts

@@ -3,9 +3,9 @@ import Calendar from './Calendar'
 import Theme from './theme/Theme'
 
 export interface ToolbarModel {
-  left: ToolbarWidget[][] | null
-  center: ToolbarWidget[][] | null
-  right: ToolbarWidget[][] | null
+  left: ToolbarWidget[][]
+  center: ToolbarWidget[][]
+  right: ToolbarWidget[][]
 }
 
 export interface ToolbarWidget {
@@ -25,9 +25,9 @@ export function parseToolbars(allOptions, theme: Theme, calendar: Calendar) {
 
 function parseToolbar(raw, theme: Theme, calendar: Calendar, viewsWithButtons: string[]): ToolbarModel {
   return {
-    left: raw.left ? parseSection(raw.left, theme, calendar, viewsWithButtons) : null,
-    center: raw.center ? parseSection(raw.center, theme, calendar, viewsWithButtons) : null,
-    right: raw.right ? parseSection(raw.right, theme, calendar, viewsWithButtons) : null
+    left: raw.left ? parseSection(raw.left, theme, calendar, viewsWithButtons) : [],
+    center: raw.center ? parseSection(raw.center, theme, calendar, viewsWithButtons) : [],
+    right: raw.right ? parseSection(raw.right, theme, calendar, viewsWithButtons) : []
   }
 }