-
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 overlay (#855)
- Loading branch information
Showing
8 changed files
with
99 additions
and
14 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,53 @@ | ||
// TODO(kara): update vars for desktop when MD team responds | ||
|
||
@import 'variables'; | ||
@import 'elevation'; | ||
@import 'default-theme'; | ||
@import 'button-mixins'; | ||
@import 'list-shared'; | ||
|
||
// 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-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 must be 100% of the viewport height + one row height | ||
max-height: calc(100vh + 48px); | ||
overflow: scroll; | ||
-webkit-overflow-scrolling: touch; // for momentum scroll on mobile | ||
|
||
background: md-color($md-background, 'background'); | ||
} | ||
|
||
[md-menu-item] { | ||
@include md-button-reset(); | ||
@include md-truncate-line(); | ||
|
||
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'); | ||
cursor: default; | ||
} | ||
|
||
&: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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* This mixin overrides default button styles like the gray background, | ||
* the border, and the outline. | ||
*/ | ||
@mixin md-button-reset { | ||
background: transparent; | ||
cursor: pointer; | ||
user-select: none; | ||
outline: none; | ||
border: none; | ||
} |
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> |
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