Skip to content

Commit 2a86270

Browse files
jelbournkara
authored andcommitted
feat(menu): add md-menu standalone component
1 parent 991364e commit 2a86270

File tree

27 files changed

+332
-49
lines changed

27 files changed

+332
-49
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"deploy": "firebase deploy",
2323
"webdriver-manager": "webdriver-manager"
2424
},
25-
"version": "2.0.0-alpha.6",
25+
"version": "2.0.0-alpha.6-2",
2626
"license": "MIT",
2727
"engines": {
2828
"node": ">= 4.2.1 < 5"
@@ -43,6 +43,7 @@
4343
"zone.js": "0.6.12"
4444
},
4545
"devDependencies": {
46+
"@angular/compiler-cli": "^0.4.1",
4647
"add-stream": "^1.0.0",
4748
"angular-cli": "^1.0.0-beta.9",
4849
"broccoli-autoprefixer": "^4.1.0",

scripts/release/enact-release.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/usr/bin/env bash
22

3+
# Run this script after running `stage-release.sh` to publish the packages staged to deploy/
4+
# Optionally uses the first argument as the tag for the release (such as "next").
5+
# This script should be run from the root of the material2 repo.
6+
7+
38
# `npm whoami` errors and dies if you're not logged in,
49
# so we redirect the stderr output to /dev/null since we don't care.
510
NPM_USER=$(npm whoami 2> /dev/null)
@@ -9,11 +14,15 @@ if [ "${NPM_USER}" != "angular2-material" ]; then
914
exit
1015
fi
1116

17+
NPM_TAG="latest"
18+
if [ "$1" ] ; then
19+
NPM_TAG=${1}
20+
fi
21+
1222
set -ex
1323

14-
for package in ./deploy/*
15-
do
16-
npm publish --access public ${package}
24+
for package in ./deploy/* ; do
25+
npm publish --access public ${package} --tag ${NPM_TAG}
1726
done
1827

1928
# Always log out of npm when publish is complete.

scripts/release/stage-release.sh

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
set -exu
2+
set -xu
33

44
# Stages a release by putting everything that should be packaged and released
55
# into the ./deploy folder. This script should be run from the root of the
@@ -12,19 +12,55 @@ set -exu
1212
rm -rf ./dist
1313
rm -rf ./deploy
1414

15-
# Perform a build with the modified tsconfig.json.
15+
# deploy/ serves as a working directory to stage the release.
16+
mkdir deploy
17+
18+
# Start off by building normally.
19+
ng build
20+
21+
# We need to remove moduleId for the ngc build. We do this by simply commenting out with a
22+
# distinguishing marker and then undoing those lines after we've generated the .metadata.json files.
23+
grep -lr "moduleId:" ./src/ | xargs sed -i 's|moduleId:|//MODULE moduleId:|g'
24+
25+
# Run tsc directly first so that the output directories match what ngc is expecting. This is
26+
# different from what the CLI will output for *demo-app*, but we don't care about the output for
27+
# demo-app when we're staging a release (only components/ and core/).
28+
tsc -p ./src/demo-app
29+
30+
# Now run ngc to generate the .metadata.json files. Our tsconfig is configred with
31+
# skipTemplateCodegen, so only the metadata files are actually generated.
32+
./node_modules/.bin/ngc -p ./src/demo-app
33+
34+
# Restore the moduleIds.
35+
grep -lr "//MODULE " ./src/ | xargs sed -i 's|//MODULE ||g'
36+
37+
# At this point, we have all of our .metadata.json files, which is all we care about from ngc.
38+
# Temporarily copy them over to deploy/ so we can cut a clean build.
39+
# Use rsync since we want to preserve the directory structure and `cp --parents` won't work on OSX.
40+
find ./dist/{components,core} -iname "*.metadata.json" | xargs -i rsync -Rq {} ./deploy/
41+
42+
# Wipe away dist and perform a clean build.
43+
rm -rf ./dist
1644
ng build
1745

1846
# Inline the css and html into the component ts files.
1947
npm run inline-resources
2048

21-
# deploy/ serves as a working directory to stage the release.
22-
mkdir deploy
49+
# Move the .metadata.json files back to where we want them.
50+
(cd ./deploy ; find ./ -iname "*.metadata.json" | xargs -i rsync -Rq {} ../)
51+
52+
# Clear the deploy/ directory again now that we've pulled the metadata out of it.
53+
rm -rf ./deploy/*
2354

2455
# Copy all components/ to deploy/
2556
cp -R ./dist/components/* ./deploy/
2657

2758
# Copy the core/ directory directly into ./deploy
2859
cp -R ./dist/core/ ./deploy/core/
2960

61+
# Remove test files from deploy/
62+
find ./deploy -iname "*.spec.d.ts" | xargs rm
63+
find ./deploy -iname "*.spec.js" | xargs rm
64+
find ./deploy -iname "*.spec.js.map" | xargs rm
65+
3066
# To test the packages, simply `npm install` the package directories.

src/components/button/_button-base.scss

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
@import 'variables';
33
@import 'elevation';
4+
@import 'mixins';
45

56
// TODO(jelbourn): This goes away.
67
@import 'default-theme';
@@ -34,12 +35,7 @@ $md-mini-fab-padding: 8px !default;
3435
position: relative;
3536

3637
// Reset browser <button> styles.
37-
background: transparent;
38-
text-align: center;
39-
cursor: pointer;
40-
user-select: none;
41-
outline: none;
42-
border: none;
38+
@include md-button-reset();
4339

4440
// Make anchors render like buttons.
4541
display: inline-block;
@@ -52,6 +48,7 @@ $md-mini-fab-padding: 8px !default;
5248
font-family: $md-font-family;
5349
font-weight: 500;
5450
color: currentColor;
51+
text-align: center;
5552

5653
// Sizing.
5754
margin: $md-button-margin;

src/components/button/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular2-material/button",
3-
"version": "2.0.0-alpha.6",
3+
"version": "2.0.0-alpha.6-2",
44
"description": "Angular 2 Material button",
55
"main": "./button.js",
66
"typings": "./button.d.ts",
@@ -23,6 +23,6 @@
2323
},
2424
"homepage": "https://github.com/angular/material2#readme",
2525
"peerDependencies": {
26-
"@angular2-material/core": "2.0.0-alpha.6"
26+
"@angular2-material/core": "2.0.0-alpha.6-2"
2727
}
2828
}

src/components/card/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular2-material/card",
3-
"version": "2.0.0-alpha.6",
3+
"version": "2.0.0-alpha.6-2",
44
"description": "Angular 2 Material card",
55
"main": "./card.js",
66
"typings": "./card.d.ts",
@@ -21,6 +21,6 @@
2121
},
2222
"homepage": "https://github.com/angular/material2#readme",
2323
"peerDependencies": {
24-
"@angular2-material/core": "2.0.0-alpha.6"
24+
"@angular2-material/core": "2.0.0-alpha.6-2"
2525
}
2626
}

src/components/checkbox/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular2-material/checkbox",
3-
"version": "2.0.0-alpha.6",
3+
"version": "2.0.0-alpha.6-2",
44
"description": "Angular 2 Material checkbox",
55
"main": "./checkbox.js",
66
"typings": "./checkbox.d.ts",
@@ -21,7 +21,7 @@
2121
},
2222
"homepage": "https://github.com/angular/material2#readme",
2323
"peerDependencies": {
24-
"@angular2-material/core": "2.0.0-alpha.6",
24+
"@angular2-material/core": "2.0.0-alpha.6-2",
2525
"@angular/forms": "^0.1.0"
2626
}
2727
}

src/components/grid-list/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular2-material/grid-list",
3-
"version": "2.0.0-alpha.6",
3+
"version": "2.0.0-alpha.6-2",
44
"description": "Angular 2 Material grid list",
55
"main": "./grid-list.js",
66
"typings": "./grid-list.d.ts",
@@ -23,6 +23,6 @@
2323
},
2424
"homepage": "https://github.com/angular/material2#readme",
2525
"peerDependencies": {
26-
"@angular2-material/core": "2.0.0-alpha.6"
26+
"@angular2-material/core": "2.0.0-alpha.6-2"
2727
}
2828
}

src/components/icon/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular2-material/icon",
3-
"version": "2.0.0-alpha.6",
3+
"version": "2.0.0-alpha.6-2",
44
"description": "Angular 2 Material icon",
55
"main": "./icon.js",
66
"typings": "./icon.d.ts",
@@ -22,6 +22,6 @@
2222
"homepage": "https://github.com/angular/material2#readme",
2323
"peerDependencies": {
2424
"@angular/http": "2.0.0-rc.4",
25-
"@angular2-material/core": "2.0.0-alpha.6"
25+
"@angular2-material/core": "2.0.0-alpha.6-2"
2626
}
2727
}

src/components/input/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular2-material/input",
3-
"version": "2.0.0-alpha.6",
3+
"version": "2.0.0-alpha.6-2",
44
"description": "Angular 2 Material input",
55
"main": "./input.js",
66
"typings": "./input.d.ts",
@@ -23,7 +23,7 @@
2323
},
2424
"homepage": "https://github.com/angular/material2#readme",
2525
"peerDependencies": {
26-
"@angular2-material/core": "2.0.0-alpha.6",
26+
"@angular2-material/core": "2.0.0-alpha.6-2",
2727
"@angular/forms": "^0.1.0"
2828
}
2929
}

src/components/list/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular2-material/list",
3-
"version": "2.0.0-alpha.6",
3+
"version": "2.0.0-alpha.6-2",
44
"description": "Angular 2 Material list",
55
"main": "./list.js",
66
"typings": "./list.d.ts",
@@ -21,6 +21,6 @@
2121
},
2222
"homepage": "https://github.com/angular/material2#readme",
2323
"peerDependencies": {
24-
"@angular2-material/core": "2.0.0-alpha.6"
24+
"@angular2-material/core": "2.0.0-alpha.6-2"
2525
}
2626
}

src/components/menu/menu.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<div class="md-menu">
2+
<ng-content></ng-content>
3+
</div>
4+

src/components/menu/menu.scss

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// TODO(kara): update vars for desktop when MD team responds
2+
3+
@import 'variables';
4+
@import 'elevation';
5+
@import 'default-theme';
6+
@import 'mixins';
7+
8+
// menu width must be a multiple of 56px
9+
$md-menu-overlay-min-width: 112px !default; // 56 * 2
10+
$md-menu-overlay-max-width: 280px !default; // 56 * 5
11+
12+
$md-menu-overlay-max-height: calc(100vh + $md-menu-item-height) !default;
13+
$md-menu-item-height: 48px !default;
14+
$md-menu-font-size: 16px !default;
15+
$md-menu-side-padding: 16px !default;
16+
17+
.md-menu {
18+
@include md-elevation(2);
19+
min-width: $md-menu-overlay-min-width;
20+
max-width: $md-menu-overlay-max-width;
21+
max-height: $md-menu-overlay-max-height;
22+
23+
background: md-color($md-background, 'background');
24+
}
25+
26+
[md-menu-item] {
27+
@include md-button-reset();
28+
29+
display: block;
30+
width: 100%;
31+
height: $md-menu-item-height;
32+
padding: 0 $md-menu-side-padding;
33+
34+
font-size: $md-menu-font-size;
35+
font-family: $md-font-family;
36+
text-align: start;
37+
color: md-color($md-foreground, 'text');
38+
39+
&[disabled] {
40+
color: md-color($md-foreground, 'disabled');
41+
}
42+
43+
&:hover:not([disabled]) {
44+
background: md-color($md-background, 'hover');
45+
}
46+
}
47+

src/components/menu/menu.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
1-
import {Component, ViewEncapsulation} from '@angular/core';
1+
import {Component, Directive, ViewEncapsulation} from '@angular/core';
22

33
@Component({
44
moduleId: module.id,
55
selector: 'md-menu',
6+
host: {'role': 'menu'},
67
templateUrl: 'menu.html',
78
styleUrls: ['menu.css'],
8-
encapsulation: ViewEncapsulation.None
9+
encapsulation: ViewEncapsulation.None,
10+
exportAs: 'mdMenu'
911
})
1012
export class MdMenu {}
1113

12-
export const MD_MENU_DIRECTIVES = [MdMenu];
14+
@Directive({
15+
selector: '[md-menu-item]',
16+
host: {'role': 'menuitem'}
17+
})
18+
export class MdMenuItem {}
19+
20+
export const MD_MENU_DIRECTIVES = [MdMenu, MdMenuItem];
1321

src/components/menu/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular2-material/menu",
3-
"version": "2.0.0-alpha.6",
3+
"version": "2.0.0-alpha.6-2",
44
"description": "Angular 2 Material menu",
55
"main": "./menu.js",
66
"typings": "./menu.d.ts",
@@ -21,6 +21,6 @@
2121
},
2222
"homepage": "https://github.com/angular/material2#readme",
2323
"peerDependencies": {
24-
"@angular2-material/core": "2.0.0-alpha.6"
24+
"@angular2-material/core": "2.0.0-alpha.6-2"
2525
}
2626
}

src/components/progress-bar/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular2-material/progress-bar",
3-
"version": "2.0.0-alpha.6",
3+
"version": "2.0.0-alpha.6-2",
44
"description": "Angular 2 Material progress-bar",
55
"main": "./progress-bar.js",
66
"typings": "./progress-bar.d.ts",
@@ -23,6 +23,6 @@
2323
},
2424
"homepage": "https://github.com/angular/material2#readme",
2525
"peerDependencies": {
26-
"@angular2-material/core": "2.0.0-alpha.6"
26+
"@angular2-material/core": "2.0.0-alpha.6-2"
2727
}
2828
}

src/components/progress-circle/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular2-material/progress-circle",
3-
"version": "2.0.0-alpha.6",
3+
"version": "2.0.0-alpha.6-2",
44
"description": "Angular 2 Material progress-circle",
55
"main": "./progress-circle.js",
66
"typings": "./progress-circle.d.ts",
@@ -22,6 +22,6 @@
2222
},
2323
"homepage": "https://github.com/angular/material2#readme",
2424
"peerDependencies": {
25-
"@angular2-material/core": "2.0.0-alpha.6"
25+
"@angular2-material/core": "2.0.0-alpha.6-2"
2626
}
2727
}

src/components/radio/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular2-material/radio",
3-
"version": "2.0.0-alpha.6",
3+
"version": "2.0.0-alpha.6-2",
44
"description": "Angular 2 Material radio",
55
"main": "./radio.js",
66
"typings": "./radio.d.ts",
@@ -21,7 +21,7 @@
2121
},
2222
"homepage": "https://github.com/angular/material2#readme",
2323
"peerDependencies": {
24-
"@angular2-material/core": "2.0.0-alpha.6",
24+
"@angular2-material/core": "2.0.0-alpha.6-2",
2525
"@angular/forms": "^0.1.0"
2626
}
2727
}

0 commit comments

Comments
 (0)