-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(menu): add md-menu standalone component
- Loading branch information
Showing
6 changed files
with
82 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<div class="md-menu"> | ||
<ng-content></ng-content> | ||
</div> | ||
|
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,47 @@ | ||
// TODO(kara): update vars for desktop when MD team responds | ||
|
||
@import 'variables'; | ||
@import 'elevation'; | ||
@import 'default-theme'; | ||
@import 'mixins'; | ||
|
||
// menu width must be a multiple of 56px | ||
$md-menu-overlay-min-width: 112px !default; // 56 * 2 | ||
$md-menu-overlay-max-width: 280px !default; // 56 * 5 | ||
|
||
$md-menu-overlay-max-height: calc(100vh + $md-menu-item-height) !default; | ||
$md-menu-item-height: 48px !default; | ||
$md-menu-font-size: 16px !default; | ||
$md-menu-side-padding: 16px !default; | ||
|
||
.md-menu { | ||
@include md-elevation(2); | ||
min-width: $md-menu-overlay-min-width; | ||
max-width: $md-menu-overlay-max-width; | ||
max-height: $md-menu-overlay-max-height; | ||
|
||
background: md-color($md-background, 'background'); | ||
} | ||
|
||
[md-menu-item] { | ||
@include md-button-reset(); | ||
|
||
display: block; | ||
width: 100%; | ||
height: $md-menu-item-height; | ||
padding: 0 $md-menu-side-padding; | ||
|
||
font-size: $md-menu-font-size; | ||
font-family: $md-font-family; | ||
text-align: start; | ||
color: md-color($md-foreground, 'text'); | ||
|
||
&[disabled] { | ||
color: md-color($md-foreground, 'disabled'); | ||
} | ||
|
||
&:hover:not([disabled]) { | ||
background: md-color($md-background, 'hover'); | ||
} | ||
} | ||
|
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 |
---|---|---|
@@ -1,13 +1,21 @@ | ||
import {Component, ViewEncapsulation} from '@angular/core'; | ||
import {Component, Directive, ViewEncapsulation} from '@angular/core'; | ||
|
||
@Component({ | ||
moduleId: module.id, | ||
selector: 'md-menu', | ||
host: {'role': 'menu'}, | ||
templateUrl: 'menu.html', | ||
styleUrls: ['menu.css'], | ||
encapsulation: ViewEncapsulation.None | ||
encapsulation: ViewEncapsulation.None, | ||
exportAs: 'mdMenu' | ||
}) | ||
export class MdMenu {} | ||
|
||
export const MD_MENU_DIRECTIVES = [MdMenu]; | ||
@Directive({ | ||
selector: '[md-menu-item]', | ||
host: {'role': 'menuitem'} | ||
}) | ||
export class MdMenuItem {} | ||
|
||
export const MD_MENU_DIRECTIVES = [MdMenu, MdMenuItem]; | ||
|
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 |
---|---|---|
@@ -1 +1,5 @@ | ||
menu | ||
<md-menu> | ||
<button md-menu-item>Refresh</button> | ||
<button md-menu-item>Settings</button> | ||
<button md-menu-item disabled>Help</button> | ||
</md-menu> |