Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit d370eb2

Browse files
Splaktarjelbourn
authored andcommitted
menu(dense): add demo and docs. fix min-height when scrollable (#11602)
Fixes #11278. Closes #11279.
1 parent 704e259 commit d370eb2

File tree

7 files changed

+82
-3
lines changed

7 files changed

+82
-3
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<div class="md-menu-demo" ng-controller="DensityDemoCtrl as ctrl" style="min-height: 350px" ng-cloak>
2+
<div class="menu-demo-container" layout-align="start center" layout="column">
3+
<div layout-align="start center" layout="column" style="min-height: 70px;">
4+
<h2 class="md-title">Different Densities</h2>
5+
<p>
6+
You can add the <code>md-dense</code> class to the <code>md-menu-content</code> element
7+
in order to reduce the size of menu items as described in the
8+
<a ng-href="{{ctrl.menuHref}}" target="_blank">Menu Specs</a>.
9+
</p>
10+
</div>
11+
<div layout-wrap layout="row" layout-fill layout-align="space-between center"
12+
style="min-height: 100px;">
13+
<div layout="column" flex="50" flex-sm="100" flex-xs="100" layout-align="center center">
14+
<p>Normal density menu</p>
15+
<md-menu>
16+
<md-button aria-label="Open demo menu" class="md-icon-button"
17+
ng-click="$mdMenu.open($event)">
18+
<md-icon md-menu-origin md-svg-icon="call:phone"></md-icon>
19+
</md-button>
20+
<md-menu-content>
21+
<md-menu-item ng-repeat="item in [1, 2, 3]">
22+
<md-button ng-click="ctrl.announceClick($index)"><span
23+
md-menu-align-target>Option</span> {{item}}
24+
</md-button>
25+
</md-menu-item>
26+
</md-menu-content>
27+
</md-menu>
28+
</div>
29+
<div layout="column" flex="50" flex-sm="100" flex-xs="100" layout-align="center center">
30+
<p>Dense menu</p>
31+
<md-menu>
32+
<md-button aria-label="Open demo menu" class="md-icon-button"
33+
ng-click="$mdMenu.open($event)">
34+
<md-icon md-menu-origin md-svg-icon="call:email"></md-icon>
35+
</md-button>
36+
<md-menu-content class="md-dense">
37+
<md-menu-item ng-repeat="item in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]">
38+
<md-button ng-click="ctrl.announceClick($index)"><span
39+
md-menu-align-target>Option</span> {{item}}
40+
</md-button>
41+
</md-menu-item>
42+
</md-menu-content>
43+
</md-menu>
44+
</div>
45+
</div>
46+
</div>
47+
</div>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
angular.module('menuDemoDensity', ['ngMaterial']).config(function($mdIconProvider) {
2+
$mdIconProvider
3+
.iconSet("call", 'img/icons/sets/communication-icons.svg', 24)
4+
.iconSet("social", 'img/icons/sets/social-icons.svg', 24);
5+
}).controller('DensityDemoCtrl', function($mdDialog) {
6+
var ctrl = this;
7+
ctrl.menuHref = "https://material.io/archive/guidelines/components/menus.html#menus-specs";
8+
9+
this.announceClick = function(index) {
10+
$mdDialog.show(
11+
$mdDialog.alert()
12+
.title('You clicked!')
13+
.textContent('You clicked the menu item at index ' + index)
14+
.ok('Nice')
15+
);
16+
};
17+
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.md-menu-demo {
2+
padding: 24px;
3+
}
4+
.menu-demo-container {
5+
min-height: 200px;
6+
}

src/components/menu/demoMenuWidth/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<h2 class="md-title">Different Widths</h2>
55
<p>
66
<code>md-menu-content</code> may specify a <code>width</code> attribute which will follow
7-
the <a ng-href="{{ctrl.menuHref}}" class="md-accent" target="_blank">official spec</a>.
7+
the <a ng-href="{{ctrl.menuHref}}" target="_blank">Menu Specs</a>.
88
</p>
99
</div>
1010
<div class="menus" layout-wrap layout="row" layout-fill layout-align="space-between center" style="min-height:100px;">

src/components/menu/demoMenuWidth/script.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ angular.module('menuDemoWidth', ['ngMaterial']).config(function($mdIconProvider)
44
.iconSet("social", 'img/icons/sets/social-icons.svg', 24);
55
}).controller('WidthDemoCtrl', function($mdDialog) {
66
var ctrl = this;
7-
ctrl.menuHref = "https://material.io/design/components/menus.html#specs";
7+
ctrl.menuHref = "https://material.io/archive/guidelines/components/menus.html#menus-specs";
88

99
this.announceClick = function(index) {
1010
$mdDialog.show(

src/components/menu/js/menuDirective.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@
3838
* See the [Material Design Spec](https://material.io/archive/guidelines/components/menus.html#menus-simple-menus)
3939
* for more information.
4040
*
41+
* ## Menu Density
42+
*
43+
* You can use dense menus by adding the `md-dense` class to the `md-menu-content` element.
44+
* This reduces the height of menu items, their top and bottom padding, and default font size.
45+
* Without the `md-dense` class, we use the "mobile" height of `48px`. With the `md-dense` class,
46+
* we use the "desktop" height of `32px`. We do not support the "dense desktop" option in the spec,
47+
* which uses a height of `24px`, at this time.
48+
* See the [Menu Specs](https://material.io/archive/guidelines/components/menus.html#menus-specs)
49+
* section of the Material Design Spec for more information.
4150
*
4251
* ## Aligning Menus
4352
*

src/components/menu/menu.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ md-menu-content {
6363
max-height: $max-dense-menu-height;
6464
md-menu-item {
6565
height: $dense-menu-item-height;
66-
min-height: 0px;
66+
min-height: $dense-menu-item-height;
6767
}
6868
}
6969
}

0 commit comments

Comments
 (0)