This repository has been archived by the owner on Oct 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(menu): Menu Improvements - Complete overhaul
* New mdc-menu-divider component * New mdc-menu-anchor directive * New mdc-menu-item directive * Update MDC Menu for MDC v0.13.0 BREAKING CHANGE: Removed [items] property. You'll need to start using the new mdc-menu-item directive.
- Loading branch information
Showing
9 changed files
with
104 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { | ||
Directive, | ||
HostBinding, | ||
} from '@angular/core'; | ||
|
||
@Directive({ | ||
selector: '[mdc-menu-anchor]' | ||
}) | ||
export class MenuAnchorDirective { | ||
@HostBinding('class') className: string = 'mdc-menu-anchor'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { | ||
Component | ||
} from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'mdc-menu-divider', | ||
template: '<li class="mdc-list-divider" role="seperator"><ng-content></ng-content></li>' | ||
}) | ||
export class MenuDividerComponent { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { | ||
Directive, | ||
ElementRef, | ||
HostBinding, | ||
Input, | ||
Renderer2, | ||
} from '@angular/core'; | ||
|
||
@Directive({ | ||
selector: 'mdc-menu-item' | ||
}) | ||
export class MenuItemDirective { | ||
private disabled_: boolean = false; | ||
|
||
@Input() id: string; | ||
@Input() label: string; | ||
@Input() icon: string; | ||
@Input() | ||
get disabled() { | ||
return this.disabled_; | ||
} | ||
set disabled(value: boolean) { | ||
this.disabled_ = value; | ||
if (value) { | ||
this._renderer.setAttribute(this._root.nativeElement, 'aria-disabled', 'true'); | ||
this.tabindex = -1; | ||
} else { | ||
this._renderer.removeAttribute(this._root.nativeElement, 'aria-disabled'); | ||
this.tabindex = 0; | ||
} | ||
} | ||
@HostBinding('class') className: string = 'mdc-list-item'; | ||
@HostBinding('attr.role') role: string = 'menuitem'; | ||
@HostBinding('tabindex') tabindex: number = 0; | ||
itemEl: ElementRef = this._root; | ||
|
||
constructor( | ||
private _renderer: Renderer2, | ||
private _root: ElementRef) { } | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<ul #menuContainer class="mdc-simple-menu__items mdc-list" role="menu" aria-hidden="true"> | ||
<ng-content select="mdc-menu-item, mdc-menu-divider"></ng-content> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.