Skip to content

Commit

Permalink
feat(overlay): add overlay container & styles
Browse files Browse the repository at this point in the history
  • Loading branch information
jelbourn committed Mar 25, 2016
1 parent abefaf5 commit 74e3edf
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 12 deletions.
3 changes: 2 additions & 1 deletion ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ var Angular2App = require('angular-cli/lib/broccoli/angular2-app');
var BroccoliSass = require('broccoli-sass');
var broccoliAutoprefixer = require('broccoli-autoprefixer');

const BroccoliTypescript = require('./tools/broccoli/broccoli-typescript').default;
const BroccoliTs2Dart = require('./tools/broccoli/broccoli-ts2dart').default;
const BroccoliDestCopy = require('./tools/broccoli/broccoli-dest-copy').default;
const BroccoliDartFmt = require('./tools/broccoli/broccoli-dartfmt').default;
Expand All @@ -24,13 +23,15 @@ module.exports = function(defaults) {
var demoAppCssTree = new BroccoliSass(['src/demo-app'], './demo-app.scss', 'demo-app/demo-app.css');
var demoCssTree = getCssTree('demo-app');
var componentCssTree = getCssTree('components');
var mainCssTree = new BroccoliSass(['src', 'src/core/style'], './main.scss', 'main.css');
var angularAppTree = new Angular2App(defaults);

var dartAppTree = getDartTree('src/');

return mergeTrees([
angularAppTree.toTree(),
componentCssTree,
mainCssTree,
demoAppCssTree,
demoCssTree,
].concat(dartAppTree || []));
Expand Down
14 changes: 14 additions & 0 deletions src/core/overlay/overlay-container.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {DOM} from '../platform/dom/dom_adapter';


/**
* Create the overlay container element, which is simply a div
* with the 'md-overlay-container' class on the document body.
*/
export function createOverlayContainer(): Element {
let documentBody = DOM.getGlobalEventTarget('body');
let container = DOM.createElement('div');
DOM.addClass(container, 'md-overlay-container');
DOM.appendChild(documentBody, container);
return container;
}
18 changes: 18 additions & 0 deletions src/core/overlay/overlay.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/** The overlay-container is an invisible element which contains all individual overlays. */
.md-overlay-container {
position: absolute;

// Disable events from being captured on the overlay container.
pointer-events: none;

// The container should be the size of the viewport.
top: 0;
left: 0;
height: 100%;
width: 100%;
}

/** A single overlay pane. */
.md-overlay-pane {
position: absolute;
}
3 changes: 2 additions & 1 deletion src/core/overlay/overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import {DomPortalHost} from '../portal/dom-portal-host';
import {OverlayRef} from './overlay-ref';
import {DOM} from '../platform/dom/dom_adapter';

// Re-export OverlayState and OverlayRef so they can be imported directly from here.
// Re-export overlay-related modules so they can be imported directly from here.
export {OverlayState} from './overlay-state';
export {OverlayRef} from './overlay-ref';
export {createOverlayContainer} from './overlay-container';

/** Token used to inject the DOM element that serves as the overlay container. */
export const OVERLAY_CONTAINER_TOKEN = CONST_EXPR(new OpaqueToken('overlayContainer'));
Expand Down
10 changes: 3 additions & 7 deletions src/demo-app/overlay/overlay-demo.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {Component, provide, ElementRef, ViewChildren, QueryList} from 'angular2/core';
import {Overlay, OVERLAY_CONTAINER_TOKEN} from '../../core/overlay/overlay';
import {Component, ElementRef, ViewChildren, QueryList} from 'angular2/core';
import {Overlay} from '../../core/overlay/overlay';
import {ComponentPortal, Portal} from '../../core/portal/portal';
import {BrowserDomAdapter} from '../../core/platform/browser/browser_adapter';
import {TemplatePortalDirective} from '../../core/portal/portal-directives';


Expand All @@ -12,15 +11,12 @@ import {TemplatePortalDirective} from '../../core/portal/portal-directives';
directives: [TemplatePortalDirective],
providers: [
Overlay,
provide(OVERLAY_CONTAINER_TOKEN, {useValue: document.body})
]
})
export class OverlayDemo {
@ViewChildren(TemplatePortalDirective) templatePortals: QueryList<Portal<any>>;

constructor(public overlay: Overlay, public elementRef: ElementRef) {
BrowserDomAdapter.makeCurrent();
}
constructor(public overlay: Overlay, public elementRef: ElementRef) { }

openRotiniPanel() {
this.overlay.create().then(ref => {
Expand Down
4 changes: 2 additions & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<script src="vendor/angular2/bundles/angular2-polyfills.js"></script>
{{content-for 'head'}}
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="main.css" rel="stylesheet">
</head>
<body>
<demo-app>Loading...</demo-app>
Expand Down
2 changes: 2 additions & 0 deletions src/main.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import "package:angular2/platform/browser.dart" show bootstrap;
import "./demo-app/demo-app.dart" show DemoApp;
import "package:angular2/router.dart" show ROUTER_PROVIDERS;
import "./core/platform/browser/browser_adapter.dart" show BrowserDomAdapter;

void main() {
BrowserDomAdapter.makeCurrent();
bootstrap(DemoApp, [ROUTER_PROVIDERS]);
}
5 changes: 5 additions & 0 deletions src/main.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Main library CSS file that will eventually be delivered as angular2-material.css.
// Contains CSS rules that users will consume throughout their application as well as rules
// that are consumed across multiple components (and thus shouldn't be scoped).

@import "core/overlay/overlay";
9 changes: 8 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import {bootstrap} from 'angular2/platform/browser';
import {DemoApp} from './demo-app/demo-app';
import {ROUTER_PROVIDERS} from 'angular2/router';
import {BrowserDomAdapter} from './core/platform/browser/browser_adapter';
import {OVERLAY_CONTAINER_TOKEN} from './core/overlay/overlay';
import {provide} from 'angular2/core';
import {createOverlayContainer} from './core/overlay/overlay-container';

BrowserDomAdapter.makeCurrent();

bootstrap(DemoApp, [
ROUTER_PROVIDERS
ROUTER_PROVIDERS,
provide(OVERLAY_CONTAINER_TOKEN, {useValue: createOverlayContainer()}),
]);

0 comments on commit 74e3edf

Please sign in to comment.