new Hamburger(parent, props)
Represents a Hamburger menu component.
| Name | Type | Description |
|---|---|---|
parent | HTMLElement | The parent element to which the hamburger menu is attached.. |
props | TComponents. | The properties of the hamburger menu. |
- Source
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.
- string
- Deprecated
- Use `activeViewName` instead TComponents.Hamburger#activeViewName.
- Source
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.
- number
- Source
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); // 0activeViewIndex :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.
- number
- Source
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.
- string
- Source
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.
- boolean
- Source
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.
- Array.<any>
- Overrides
- Source
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.
| Name | Type | Attributes | Default | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
menu | object | The menu definition Properties
| |||||||||||
id | string | <optional> | null | ID of the menu view |
- Source
- Type:
- void
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.
- Overrides
- Source
The default properties.
hideMenu(options) → {void}
Hides a menu item and its associated view.
| Name | Type | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | object | Properties
|
- Source
- Type:
- void
hamburgerInstance.hideMenu({ name: 'Menu 2' });hideMenuByIndex(index) → {void}
Hides a hamburger menu by its index.
| Name | Type | Description |
|---|---|---|
index | number | Zero-based menu index. |
- Source
- Type:
- void
// Hide the menu 1.
hamburgerInstance.hideMenuByIndex(0);mapComponents() → {object}
Maps components to their identifiers.
- Overrides
- Source
- Type:
- object
markup() → {string}
Generates the HTML markup for the hamburger menu.
- Overrides
- Source
The HTML markup.
- Type:
- string
onInit() → {void}
Initializes the hamburger menu.
- Overrides
- Source
- Type:
- void
onRender() → {void}
Renders the hamburger menu.
- Overrides
- Source
- Type:
- void
removeMenu(options) → {void}
Removes a menu item by id, content, or name. Lookup priority:
idcontentname
| Name | Type | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | object | Properties
|
- Source
- Type:
- void
hamburgerInstance.removeMenu({ name: 'Menu 1' });removeMenuByIndex(index) → {void}
Removes a hamburger menu by its index in the views array.
| Name | Type | Description |
|---|---|---|
index | number | Zero-based hamburger menu index. |
- Source
- Type:
- void
hamburgerInstance.removeMenuByIndex(1);(protected) setActiveView() → {void}
Removes the “active” style from all hamburger menu buttons, then activates the view at the specified index.
- Source
If the hamburger menu is not initialized or the target view cannot be found.
- Type
- Error
- Type:
- void
showMenu(options) → {void}
Shows a menu item and its associated view.
| Name | Type | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | object | Properties
|
- Source
- Type:
- void
hamburgerInstance.showMenu({ name: 'Menu 2' });showMenuByIndex(index) → {void}
Shows a hamburger menu by its index.
| Name | Type | Description |
|---|---|---|
index | number | Zero-based menu index. |
- Source
- Type:
- void
// Hide the menu 1;
hamburgerInstance.hideMenuByIndex(0);
// Show the menu 1;
hamburgerInstance.showMenuByIndex(0);(static) loadCssClassFromString(css)
Add css properties to the component
| Name | Type | Description |
|---|---|---|
css | string | The css string to be loaded into style tag |
- Source
TComponents.Hamburger.loadCssClassFromString(/*css* / `
.tc-hamburger {
height: 100%;
width: 100%;
}`
);