From 3070a719be4b03e12d1e8d178304f8b53f2f8feb Mon Sep 17 00:00:00 2001 From: Jeremy Elbourn Date: Wed, 17 Feb 2016 19:22:17 -0800 Subject: [PATCH] feat(portal): add initial portal foundation --- src/core/portal/README.md | 72 ++++++++ src/core/portal/portal-directives.ts | 104 +++++++++++ src/core/portal/portal.spec.ts | 265 +++++++++++++++++++++++++++ src/core/portal/portal.ts | 198 ++++++++++++++++++++ src/demo-app/demo-app.html | 30 +-- src/demo-app/demo-app.scss | 4 +- src/demo-app/demo-app.ts | 3 + src/demo-app/portal/portal-demo.html | 31 ++++ src/demo-app/portal/portal-demo.scss | 7 + src/demo-app/portal/portal-demo.ts | 42 +++++ src/index.html | 2 +- src/main.ts | 7 +- test/karma.config.ts | 2 + 13 files changed, 749 insertions(+), 18 deletions(-) create mode 100644 src/core/portal/README.md create mode 100644 src/core/portal/portal-directives.ts create mode 100644 src/core/portal/portal.spec.ts create mode 100644 src/core/portal/portal.ts create mode 100644 src/demo-app/portal/portal-demo.html create mode 100644 src/demo-app/portal/portal-demo.scss create mode 100644 src/demo-app/portal/portal-demo.ts diff --git a/src/core/portal/README.md b/src/core/portal/README.md new file mode 100644 index 00000000000..dadd650f397 --- /dev/null +++ b/src/core/portal/README.md @@ -0,0 +1,72 @@ +# Portals + +### Overview + +A `Portal `is a piece of UI that can be dynamically rendered to an open slot on the page. + +The "piece of UI" can be either a `Component` or a `TemplateRef`. + +The "open slot" is a `PortalHost`. + +Portals and PortalHosts are low-level building blocks that other concepts, such as overlays, can +be built upon. + +##### `Portal` +| Method | Description | +| --- | --- | +| `attach(PortalHost): Promise` | Attaches the portal to a host. | +| `detach(): Promise` | Detaches the portal from its host. | +| `isAttached: boolean` | Whether the portal is attached. | + +##### `PortalHost` +| Method | Description | +| --- | --- | +| `attach(Portal): Promise` | Attaches a portal to the host. | +| `detach(): Promise` | Detaches the portal from the host. | +| `dispose(): Promise` | Permanently dispose the host. | +| `hasAttached: boolean` | Whether a portal is attached to the host. | + + + + +### Using portals + + + +##### `TemplatePortalDirective` +Used to get a portal from a `