Creating Menu Items
  • 26 Jan 2024
  • 1 Minute to read
  • Dark
    Light
  • PDF

Creating Menu Items

  • Dark
    Light
  • PDF

Article summary

Follow these steps to create three menu items.

  • The first menu item uses a callback to trigger custom logic.

  • The second menu item uses a template as its content.

  • The final menu item uses the other menu items as sub-menu items.

Procedure

  1. To create a sub-menu item that triggers a callback function, run:

    // SidebarMenuModifier.ts
    export class SidebarMenuModifier {
      // ...
      /*** Menu Items ***/
    
      private callbackMenuItem: SidebarMenuItemInterface = {
        title: "Callback Function",
        icon: this.materialIcon,
        isVisible: () => true,
        template: "",
        items: [],
        onClick: () => { myCallbackFunction(); },
        isFullscreen: false
      };
      // ...
    
      private myCallbackFunction(): void {
        window.alert("My Callback Function");
      }
    }
  2. To create a sub-menu item that uses a template, run:

    // SidebarMenuModifier.ts
    export class SidebarMenuModifier {
      // ...
      private formattedIpseDixit: SidebarMenuItemInterface = {
        title: "Ipse Dixit Formatted",
        icon: this.dataUriIcon,
        isVisible: () => true,
        template: "./lorem-ipsum-formatted.html",
        items: [],
        isFullscreen: true
      };
      // ...
    }
  3. To create a menu item that has sub-menu items, run:

    // SidebarMenuModifier.ts
    export class SidebarMenuModifier {
      // ...
      private rootMenuItem: SidebarMenuItemInterface = {
        title: "Ipse Dixit",
        icon: this.statueFaceIcon,
        isPreviewIconVisible: () => true,
        isVisible: () => true,
        template: "",
        items: [this.callbackMenuItem, this.formattedIpseDixit], // Sub-Menu Items
        isFullscreen: false
      };
      // ...
    }


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.