TComponents. Hamburger

new Hamburger(parent, props)

Represents a Hamburger menu component.

Parameters:
NameTypeDescription
parentHTMLElement

The parent element to which the hamburger menu is attached..

propsTComponents.HamburgerProps

The properties of the hamburger menu.

Example
const hamburgerInstance = new TComponents.Hamburger(document.body, {
  position: 'absolute',
  width: 200,
  height: 200,
  zIndex: 1000,
  views: [
    {
      name: 'View 1',
      icon: 'abb-icon abb-icon-home-house_32',
      content: `view_${API.generateUUID()}`,
      children: [],
    },
  ],
  activeViewIndex: 0,
});

// Render the hamburger menu
await hamburgerInstance.render();

Extends

Members

activeView :string

Gets the currently active view.

Type:
  • string
Deprecated
Example
const hamburgerInstance = new TComponents.Hamburger(document.body, {
  position: 'absolute',
  width: 200,
  height: 200,
  zIndex: 1000,
  views: [
    {
      name: 'View 1',
      icon: 'abb-icon abb-icon-home-house_32',
      content: `view_${API.generateUUID()}`,
      children: [],
    },
  ],
  activeViewIndex: 0,
});

// Render the hamburger menu
await hamburgerInstance.render();

// Get the current active view
const currentActiveView = hamburgerInstance.activeView;
console.log(currentActiveView); // 'View 1'

activeViewIndex :number

Sets the active view index and updates the active view in the Hamburger component.

Type:
  • number
Example
const hamburgerInstance = new TComponents.Hamburger(document.body, {
  position: 'absolute',
  width: 200,
  height: 200,
  zIndex: 1000,
  views: [
    {
      name: 'View 1',
      icon: 'abb-icon abb-icon-home-house_32',
      content: `view_${API.generateUUID()}`,
      children: [],
    },
  ],
  activeViewIndex: 0,
});

// Render the hamburger menu
await hamburgerInstance.render();

// Get the current active view index
const currentActiveViewIndex = hamburgerInstance.activeViewIndex;
console.log(currentActiveViewIndex); // 0

activeViewIndex :number

Sets the active view index and updates the active view in the Hamburger component. This will update the hamburger menu but will NOT trigger the onchange event. Recommended for internal or programmatic updates, where change notification is not desired.

Type:
  • number
Example
const hamburgerInstance = new TComponents.Hamburger(document.body, {
  position: 'absolute',
  width: 200,
  height: 200,
  zIndex: 1000,
  views: [
    {
      name: 'View 0',
      icon: 'abb-icon abb-icon-home-house_32',
      content: `view_${API.generateUUID()}`,
      children: [],
    },
    {
      name: 'View 1',
      icon: 'abb-icon abb-icon-home-house_32',
      content: `view_${API.generateUUID()}`,
      children: [],
    },
  ],
  activeViewIndex: 1,
});

// Render the hamburger menu
await hamburgerInstance.render();

hamburgerInstance.activeViewIndexX = 0;

activeViewName :string

Sets the active view by its display name. The comparison is performed against the resolved text from Component_A.tParse.

Type:
  • string
Example
const hamburgerInstance = new TComponents.Hamburger(document.body, {
  position: 'absolute',
  width: 200,
  height: 200,
  zIndex: 1000,
  views: [
    {
      name: 'View 1',
      icon: 'abb-icon abb-icon-home-house_32',
      content: `view_${API.generateUUID()}`,
      children: [],
    },
  ],
  activeViewIndex: 0,
});

// Render the hamburger menu
await hamburgerInstance.render();

// Get the current active view name
const currentActiveView = hamburgerInstance.activeViewName;
console.log(currentActiveView); // 'View 1'

alwaysVisible :boolean

The visibility state of the hamburger menu.

Type:
  • boolean
Example
const hamburgerInstance = new TComponents.Hamburger(document.body, {
  position: 'absolute',
  width: 200,
  height: 200,
  zIndex: 1000,
  views: [
    {
      name: 'View 1',
      icon: 'abb-icon abb-icon-home-house_32',
      content: `view_${API.generateUUID()}`,
      children: [],
    },
  ],
  activeViewIndex: 0,
});

// Render the hamburger menu
await hamburgerInstance.render();

// Get the current visibility state
const isAlwaysVisible = hamburgerInstance.alwaysVisible;
console.log(isAlwaysVisible); // true

// Set the visibility state to false
hamburgerInstance.alwaysVisible = false;

views :Array.<any>

An array of Hamburger's views, each containing properties like id, name, content, active, and child.

Type:
  • Array.<any>
Example
const hamburgerInstance = new TComponents.Hamburger(document.body, {
  position: 'absolute',
  width: 200,
  height: 200,
  zIndex: 1000,
  views: [
    {
      name: 'View 1',
      icon: 'abb-icon abb-icon-home-house_32',
      content: `view_${API.generateUUID()}`,
      children: [],
    },
    {
      name: 'View 2',
      icon: 'abb-icon abb-icon-folder-open_32',
      content: `view_${API.generateUUID()}`,
      children: [],
    },
  ],
  activeViewIndex: 0,
});

// Render the hamburger menu
await hamburgerInstance.render();

// Get the views
const views = hamburgerInstance.views;
console.log(views);

Methods

addMenu(menu, idopt) → {void}

Adds a new menu item to the hamburger menu.

Parameters:
NameTypeAttributesDefaultDescription
menuobject

The menu definition

Properties
NameTypeDescription
namestring

Display name of the menu item

contentstring | HTMLElement

Content of the menu view

idstring<optional>
null

ID of the menu view

Returns:
Type: 
void
Examples
const hamburgerInstance = new TComponents.Hamburger(document.body, {
  position: 'absolute',
  width: 200,
  height: 200,
  zIndex: 1000,
  views: [
    {
      name: 'View 1',
      icon: 'abb-icon abb-icon-home-house_32',
      content: `view_${API.generateUUID()}`,
      children: [],
    },
  ],
  activeViewIndex: 0,
});

// Render the hamburger menu
await hamburgerInstance.render();

const v1 = {
  name: 'Menu 1',
  content: 'view-001',
  icon: 'abb-icon abb-icon-abb_tree-view_16',
  children: []
}

hamburgerInstance.addMenu(v1);
const div1 = document.createElement('div');
div1.textContent = 'Hello world';
div1.style.fontSize = '96px';
div1.style.fontWeight = 'bold';
div1.style.textAlign = 'center';

const v2 = {name: 'Menu 2', content: div1};

hamburgerInstance.addMenu(v2);

(protected) defaultProps() → {TComponents.HamburgerProps}

Returns default properties for the hamburger menu.

Returns:

The default properties.

Type: 
TComponents.HamburgerProps

hideMenu(options) → {void}

Hides a menu item and its associated view.

Parameters:
NameTypeDescription
optionsobject
Properties
NameTypeAttributesDescription
idstring<optional>

Menu id

contentstring | HTMLElement<optional>

Menu content

namestring<optional>

Menu display name

Returns:
Type: 
void
Example
hamburgerInstance.hideMenu({ name: 'Menu 2' });

hideMenuByIndex(index) → {void}

Hides a hamburger menu by its index.

Parameters:
NameTypeDescription
indexnumber

Zero-based menu index.

Returns:
Type: 
void
Example
// Hide the menu 1.
hamburgerInstance.hideMenuByIndex(0);

mapComponents() → {object}

Maps components to their identifiers.

Returns:
Type: 
object

markup() → {string}

Generates the HTML markup for the hamburger menu.

Returns:

The HTML markup.

Type: 
string

onInit() → {void}

Initializes the hamburger menu.

Returns:
Type: 
void

onRender() → {void}

Renders the hamburger menu.

Returns:
Type: 
void

removeMenu(options) → {void}

Removes a menu item by id, content, or name. Lookup priority:

  1. id
  2. content
  3. name
Parameters:
NameTypeDescription
optionsobject
Properties
NameTypeAttributesDescription
idstring<optional>

Menu id

contentstring | HTMLElement<optional>

Menu content

namestring<optional>

Menu display name

Returns:
Type: 
void
Example
hamburgerInstance.removeMenu({ name: 'Menu 1' });

removeMenuByIndex(index) → {void}

Removes a hamburger menu by its index in the views array.

Parameters:
NameTypeDescription
indexnumber

Zero-based hamburger menu index.

Returns:
Type: 
void
Example
hamburgerInstance.removeMenuByIndex(1);

(protected) setActiveView() → {void}

Removes the “active” style from all hamburger menu buttons, then activates the view at the specified index.

Throws:

If the hamburger menu is not initialized or the target view cannot be found.

Type
Error
Returns:
Type: 
void

showMenu(options) → {void}

Shows a menu item and its associated view.

Parameters:
NameTypeDescription
optionsobject
Properties
NameTypeAttributesDescription
idstring<optional>

Menu id

contentstring | HTMLElement<optional>

Menu content

namestring<optional>

Menu display name

Returns:
Type: 
void
Example
hamburgerInstance.showMenu({ name: 'Menu 2' });

showMenuByIndex(index) → {void}

Shows a hamburger menu by its index.

Parameters:
NameTypeDescription
indexnumber

Zero-based menu index.

Returns:
Type: 
void
Example
// Hide the menu 1;
hamburgerInstance.hideMenuByIndex(0);

// Show the menu 1;
hamburgerInstance.showMenuByIndex(0);

(static) loadCssClassFromString(css)

Add css properties to the component

Parameters:
NameTypeDescription
cssstring

The css string to be loaded into style tag

Example
TComponents.Hamburger.loadCssClassFromString(/*css* / `
  .tc-hamburger {
    height: 100%;
    width: 100%;
  }`
);