Finalise menu refactor, add typedocs and tests

This commit is contained in:
Yana De Pauw
2024-11-15 18:25:37 +01:00
parent 5a7ebd4ba9
commit a105131b2b
50 changed files with 668 additions and 2155 deletions

View File

@@ -1,4 +1,3 @@
import { MenuItemType } from './menu-item-type.model';
import { AltmetricMenuItemModel } from './menu-item/models/altmetric.model';
import { ExternalLinkMenuItemModel } from './menu-item/models/external-link.model';
import { LinkMenuItemModel } from './menu-item/models/link.model';
@@ -14,26 +13,6 @@ export type MenuItemModels =
| SearchMenuItemModel
| TextMenuItemModel;
function itemModelFactory(type: MenuItemType): MenuItemModels {
switch (type) {
case MenuItemType.TEXT:
return new TextMenuItemModel();
case MenuItemType.LINK:
return new LinkMenuItemModel();
case MenuItemType.ALTMETRIC:
return new AltmetricMenuItemModel();
case MenuItemType.SEARCH:
return new SearchMenuItemModel();
case MenuItemType.ONCLICK:
return new OnClickMenuItemModel();
case MenuItemType.EXTERNAL:
return new ExternalLinkMenuItemModel();
default: {
throw new Error(`No such menu item type: ${type}`);
}
}
}
export interface MenuSection {
/**
* The identifier for this section
@@ -80,5 +59,9 @@ export interface MenuSection {
*/
icon?: string;
/**
* When true, the current section will be assumed to be a parent section with children
* This section will not be rendered when it has no visible children
*/
alwaysRenderExpandable?: boolean;
}