Skip to content

Commit

Permalink
feat(drop-down): add multi-level menu sample (#3389)
Browse files Browse the repository at this point in the history
* feat(drop-down): add multi-level menu sample

* refactor(drop-down): minor changes ml-menu

* fix(*): make host dropdown items non-selectable

* refactor(ml-service): add separate methods
  • Loading branch information
RivaIvanova authored Oct 17, 2023
1 parent 3af1bc8 commit 35826bb
Show file tree
Hide file tree
Showing 10 changed files with 447 additions and 1 deletion.
17 changes: 16 additions & 1 deletion live-editing/configs/DropDownConfigGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import {
import { AppModuleConfig, Config, IConfigGenerator } from 'igniteui-live-editing';
export class DropDownConfigGenerator implements IConfigGenerator {
public additionalImports = {
RemoteNWindService: '../../src/app/services/remoteNwind.service'
RemoteNWindService: '../../src/app/services/remoteNwind.service',
MultiLevelDirective: '../../src/app/data-entries/dropdown/dropdown-multi-level-menu/multi-level.directive'
};
public generateConfigs(): Config[] {
const configs = new Array<Config>();
Expand Down Expand Up @@ -101,6 +102,20 @@ export class DropDownConfigGenerator implements IConfigGenerator {
shortenComponentPathBy: '/data-entries/dropdown/'
}));

configs.push(new Config({
component: 'DropdownMultiLevelMenuComponent',
additionalFiles: ['/src/app/data-entries/dropdown/dropdown-multi-level-menu/data.ts',
'/src/app/data-entries/dropdown/dropdown-multi-level-menu/multi-level.directive.ts',
'/src/app/data-entries/dropdown/dropdown-multi-level-menu/multi-level.service.ts'],
appModuleConfig: new AppModuleConfig({
imports: ['DropdownMultiLevelMenuComponent', 'MultiLevelDirective',
'IgxDropDownModule', 'IgxIconModule', 'IgxNavbarModule', 'IgxButtonModule', 'IgxToggleModule'],
ngDeclarations: ['DropdownMultiLevelMenuComponent', 'MultiLevelDirective'],
ngImports: ['IgxDropDownModule', 'IgxIconModule', 'IgxNavbarModule', 'IgxButtonModule', 'IgxToggleModule']
}),
shortenComponentPathBy: '/data-entries/dropdown/'
}));

configs.push(new Config({
component: 'DropDownVirtualComponent',
appModuleConfig: new AppModuleConfig({
Expand Down
1 change: 1 addition & 0 deletions src/app/data-entries/data-entries-routes-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const dataEntriesRoutesData = {
"dropdown-remote": { displayName: "Virtual Dropdown - Remote Data", parentName: "Dropdown" },
"dropdown-virtual": { displayName: "Virtual Dropdown", parentName: "Dropdown" },
"dropdown-menu": { displayName: "Dropdown as Menu", parentName: "Dropdown" },
"dropdown-multi-level-menu": { displayName: "Multi-Level Dropdown Menu", parentName: "Dropdown" },
"dropdown-sample-1": { displayName: "Simple Dropdown", parentName: "Dropdown" },
"dropdown-sample-2": { displayName: "Dropdown Selection", parentName: "Dropdown" },
"dropdown-sample-3": { displayName: "Dropdown Headers", parentName: "Dropdown" },
Expand Down
6 changes: 6 additions & 0 deletions src/app/data-entries/data-entries-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { dataEntriesRoutesData } from './data-entries-routes-data';
import { DropDownRemoteComponent } from './dropdown/drop-down-remote-virtual/drop-down-remote.component';
import { DropDownVirtualComponent } from './dropdown/drop-down-virtual/drop-down-virtual.component';
import { DropdownMenuComponent } from './dropdown/dropdown-menu/dropdown-menu.component';
import { DropdownMultiLevelMenuComponent } from './dropdown/dropdown-multi-level-menu/dropdown-multi-level-menu.component';
import { DropDownSample1Component } from './dropdown/dropdown-sample-1/dropdown-sample-1.component';
import { DropDownSample2Component } from './dropdown/dropdown-sample-2/dropdown-sample-2.component';
import { DropDownSample3Component } from './dropdown/dropdown-sample-3/dropdown-sample-3.component';
Expand Down Expand Up @@ -191,6 +192,11 @@ export const dataEntriesRoutes: Routes = [
data: dataEntriesRoutesData['dropdown-menu'],
path: 'dropdown-menu'
},
{
component: DropdownMultiLevelMenuComponent,
data: dataEntriesRoutesData['dropdown-multi-level-menu'],
path: 'dropdown-multi-level-menu'
},
{
component: DropDownSample1Component,
data: dataEntriesRoutesData['dropdown-sample-1'],
Expand Down
4 changes: 4 additions & 0 deletions src/app/data-entries/data-entries.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import { DataEntriesRoutingModule } from './data-entries-routing.module';
import { DropDownRemoteComponent } from './dropdown/drop-down-remote-virtual/drop-down-remote.component';
import { DropDownVirtualComponent } from './dropdown/drop-down-virtual/drop-down-virtual.component';
import { DropdownMenuComponent } from './dropdown/dropdown-menu/dropdown-menu.component';
import { DropdownMultiLevelMenuComponent } from './dropdown/dropdown-multi-level-menu/dropdown-multi-level-menu.component';
import { MultiLevelDirective } from './dropdown/dropdown-multi-level-menu/multi-level.directive';
import { DropDownSample1Component } from './dropdown/dropdown-sample-1/dropdown-sample-1.component';
import { DropDownSample2Component } from './dropdown/dropdown-sample-2/dropdown-sample-2.component';
import { DropDownSample3Component } from './dropdown/dropdown-sample-3/dropdown-sample-3.component';
Expand Down Expand Up @@ -99,6 +101,8 @@ import { ReactiveFormCustomValidationComponent } from './input-group/reactive-fo
DropDownRemoteComponent,
DropDownVirtualComponent,
DropdownMenuComponent,
DropdownMultiLevelMenuComponent,
MultiLevelDirective,
DropDownSample1Component,
DropDownSample2Component,
DropDownSample3Component,
Expand Down
44 changes: 44 additions & 0 deletions src/app/data-entries/dropdown/dropdown-multi-level-menu/data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
export const SUPPORT_DATA = [
"Help & Support Documents",
"Blogs",
"Forums",
"Product Ideas",
"Reference Applications",
"Customer Stories",
"Webinars",
"eBook & Whitepapers"
];

export const DESKTOP_DATA = [
"Ultimate UI for Windows Forms",
"Ultimate UI for WPF"
];

export const CROSS_PLATFORM_DATA = [
"Ultimate UI for Uno",
"Ultimate UI for UWP",
"Ultimate UI for WinUI",
"Ultimate UI for Xamarin"
];

export const DESIGN_TO_CODE_DATA = [
"Indigo.Design",
"App Builder",
"Design System & UI Kits"
];

export const TESTING_TOOLS_DATA = [
"Test automation for Micro Focus UFT: Win Forms",
"Test automation for Micro Focus UFT: WPF",
"Test automation for IBM RFT: Windows Forms"
];

export const IGNITE_UI_DATA = [
"Angular",
"ASP.NET Core",
"ASP.NET MVC",
"Blazor",
"jQuery",
"React",
"Web Components"
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<div class="container">
<igx-navbar>
<div igxNavbarTitle>
<img width="160px" src="https://static.infragistics.com/marketing/Website/General/Infragistics-horizontal.svg" />
</div>

<button igxButton [igxToggleAction]="dropdown1" [overlaySettings]="overlaySettings">
<span>Design & Development</span> <igx-icon>expand_more</igx-icon>
</button>
<button igxButton [igxToggleAction]="dropdown2" [overlaySettings]="overlaySettings">
<span>UX</span> <igx-icon>expand_more</igx-icon>
</button>
<button igxButton [igxToggleAction]="dropdown3" [overlaySettings]="overlaySettings">
<span>Support</span> <igx-icon>expand_more</igx-icon>
</button>
<button igxButton [igxToggleAction]="dropdown4" [overlaySettings]="overlaySettings">
<span>Pricing</span> <igx-icon>expand_more</igx-icon>
</button>
</igx-navbar>

<div class="container">
<p>{{ selection }}</p>
</div>

<!-- Drop Down Level 1 -->
<igx-drop-down #dropdown1 [width]="'170px'">
<igx-drop-down-item [value]="'Web'" multiLevel [innerDropdown]="web">
Web <igx-icon igxSuffix>chevron_right</igx-icon>
</igx-drop-down-item>

<igx-drop-down-item [value]="'Desktop'" multiLevel [innerDropdown]="desktop">
Desktop <igx-icon igxSuffix>chevron_right</igx-icon>
</igx-drop-down-item>

<igx-drop-down-item [value]="'Cross Platform'" multiLevel [innerDropdown]="crossPlatform">
Cross Platform <igx-icon igxSuffix>chevron_right</igx-icon>
</igx-drop-down-item>

<igx-drop-down-item [value]="'Design to Code'" multiLevel [innerDropdown]="designToCode">
Design to Code <igx-icon igxSuffix>chevron_right</igx-icon>
</igx-drop-down-item>

<igx-drop-down-item [value]="'Testing Tools'" multiLevel [innerDropdown]="testingTools">
Testing Tools <igx-icon igxSuffix>chevron_right</igx-icon>
</igx-drop-down-item>
</igx-drop-down>

<igx-drop-down #dropdown2>
<igx-drop-down-item [value]="'Indigo.Design'">Indigo.Design</igx-drop-down-item>
<igx-drop-down-item [value]="'App Builder'">App Builder</igx-drop-down-item>
</igx-drop-down>

<igx-drop-down #dropdown3>
<igx-drop-down-item *ngFor="let item of supportData" [value]="item">
{{ item }}
</igx-drop-down-item>
</igx-drop-down>

<igx-drop-down #dropdown4>
<igx-drop-down-item [value]="'Product Pricing'">Product Pricing</igx-drop-down-item>
<igx-drop-down-item [value]="'Contact Us'">Contact Us</igx-drop-down-item>
</igx-drop-down>

<!-- Drop Down Level 2 -->
<igx-drop-down #web>
<igx-drop-down-item [value]="'App Builder'">
App Builder
</igx-drop-down-item>
<igx-drop-down-item [value]="'Ignite UI'" multiLevel [innerDropdown]="igniteUI">
Ignite UI <igx-icon igxSuffix>chevron_right</igx-icon>
</igx-drop-down-item>
</igx-drop-down>

<igx-drop-down #desktop>
<igx-drop-down-item *ngFor="let item of desktopData" [value]="item">
{{ item }}
</igx-drop-down-item>
</igx-drop-down>

<igx-drop-down #crossPlatform>
<igx-drop-down-item *ngFor="let item of crossPlatformData" [value]="item">
{{ item }}
</igx-drop-down-item>
</igx-drop-down>

<igx-drop-down #designToCode>
<igx-drop-down-item *ngFor="let item of designToCodeData" [value]="item">
{{ item }}
</igx-drop-down-item>
</igx-drop-down>

<igx-drop-down #testingTools>
<igx-drop-down-item *ngFor="let item of testingToolsData" [value]="item">
{{ item }}
</igx-drop-down-item>
</igx-drop-down>

<!-- Drop Down Level 3 -->
<igx-drop-down #igniteUI>
<igx-drop-down-item *ngFor="let item of igniteUIData" [value]="item">
{{ item }}
</igx-drop-down-item>
</igx-drop-down>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@use "../../../../variables" as *;

.container {
padding: 16px;
}

igx-icon {
--size: 18px;
}

[igxButton] {
margin-inline-start: 0px;
}

[multiLevel] {
cursor: default;
}

$custom-navbar-theme: navbar-theme(
$background: #f8f9fa,
);

$custom-button-theme: button-theme(
$foreground: #666,
$hover-foreground: #0099ff,
$focus-foreground: #0099ff,
$active-foreground: #0099ff,
$background: transparent,
$hover-background: transparent,
$focus-background: transparent,
$active-background: transparent,
);

:host::ng-deep {
--ig-button-font-size: 0.75rem;

@include css-vars($custom-navbar-theme);
@include css-vars($custom-button-theme);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { AfterViewInit, Component, QueryList, ViewChild, ViewChildren } from '@angular/core';
import {
IgxDropDownComponent,
OverlaySettings,
ConnectedPositioningStrategy,
HorizontalAlignment,
VerticalAlignment
} from 'igniteui-angular';
import {
CROSS_PLATFORM_DATA,
DESIGN_TO_CODE_DATA,
DESKTOP_DATA,
IGNITE_UI_DATA,
SUPPORT_DATA,
TESTING_TOOLS_DATA
} from './data';
import { MultiLevelService } from './multi-level.service';

@Component({
selector: 'app-dropdown-multi-level-menu',
templateUrl: './dropdown-multi-level-menu.component.html',
styleUrls: ['./dropdown-multi-level-menu.component.scss'],
providers: [MultiLevelService]
})
export class DropdownMultiLevelMenuComponent implements AfterViewInit {
@ViewChildren(IgxDropDownComponent, { read: IgxDropDownComponent })
private _dropdowns: QueryList<IgxDropDownComponent>;

@ViewChild('dropdown1', { read: IgxDropDownComponent })
private _multiLevelDropdown: IgxDropDownComponent;

public supportData: string[] = SUPPORT_DATA;
public desktopData: string[] = DESKTOP_DATA;
public crossPlatformData: string[] = CROSS_PLATFORM_DATA;
public designToCodeData: string[] = DESIGN_TO_CODE_DATA;
public testingToolsData: string[] = TESTING_TOOLS_DATA;
public igniteUIData: string[] = IGNITE_UI_DATA;

public overlaySettings: OverlaySettings = {
modal: false,
positionStrategy: new ConnectedPositioningStrategy({
horizontalStartPoint: HorizontalAlignment.Center,
horizontalDirection: HorizontalAlignment.Center,
verticalStartPoint: VerticalAlignment.Bottom,
closeAnimation: undefined
})
};

public selection: string = '';

constructor(private _multiLevelService: MultiLevelService) { }

public ngAfterViewInit(): void {
this._dropdowns.forEach((dropdown) => {
dropdown.selectionChanging.subscribe((args) => {
args.cancel = true;
const value = args.newSelection.value;
const categories = this._multiLevelService.categories;

if (categories.includes(value)) {
this.selection = '';
return;
}

if (this._multiLevelService.isMultiLevel(dropdown)) {
this._multiLevelService.handleSelection();
} else {
dropdown.close();
}

this.selection = value;
});
});

this._multiLevelDropdown.closing.subscribe((args) => {
this._multiLevelService.handleClosing(args);
});
}
}
Loading

0 comments on commit 35826bb

Please sign in to comment.