This repository has been archived by the owner on Feb 22, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(platform): Make angular invoke web_component polyfills for brows…
…ers without native web_component implementations.
- Loading branch information
Showing
15 changed files
with
585 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ dependencies: | |
path: ../ | ||
browser: any | ||
unittest: any | ||
web_components: any | ||
|
||
transformers: | ||
- angular |
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,5 @@ | ||
|
||
:host { | ||
border-top: 2px solid white; | ||
border-bottom: 2px solid white; | ||
} |
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,43 @@ | ||
:host { | ||
display: block; | ||
margin-top: 5px; | ||
} | ||
|
||
/* This must be shimmed with a polymer shim rule */ | ||
polyfill-next-selector { content: ':host span:not([:host])'; } | ||
::content span { | ||
background-color: black; | ||
} | ||
|
||
my-button::shadow .custom-class { | ||
background-color: rgba(0,0,0, .5); | ||
} | ||
|
||
span { | ||
font-weight: bold; | ||
} | ||
|
||
.custom-component { | ||
color: white; | ||
padding: 5px; | ||
} | ||
|
||
.custom-component a { | ||
color: white; | ||
} | ||
|
||
.red { | ||
background-color: #FF1F1F; | ||
} | ||
|
||
.green { | ||
background-color: #1BC123; | ||
} | ||
|
||
.blue { | ||
background-color: #4D90FE; | ||
} | ||
|
||
.grey { | ||
background-color: #E0E0E0; | ||
} |
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,45 @@ | ||
import 'dart:html'; | ||
|
||
import 'package:angular/angular.dart'; | ||
import 'package:angular/animate/module.dart'; | ||
import 'package:angular/application_factory.dart'; | ||
import 'package:di/di.dart'; | ||
|
||
main() { | ||
var app = applicationFactory(); | ||
app.modules.add(new Module() | ||
..bind(MyComponent) | ||
..bind(BracketButton)); | ||
app.selector("body"); | ||
app.run(); | ||
} | ||
|
||
@Component( | ||
selector: "my-component", | ||
publishAs: "ctrl", | ||
template: """ | ||
<div class="custom-component" ng-class="ctrl.color"> | ||
<span>Shadow [</span> | ||
<content></content> | ||
<span>]</span> | ||
<a href="#" ng-click="ctrl.on=!ctrl.on"><my-button> | ||
Toggle</my-button></a> | ||
<span ng-if="ctrl.on">off</span> | ||
<span ng-if="!ctrl.on">on</span> | ||
</div> | ||
""", | ||
cssUrl: "/css/shadow_dom_components.css") | ||
class MyComponent { | ||
@NgAttr('color') | ||
String color; | ||
|
||
bool on = false; | ||
} | ||
|
||
@Component( | ||
selector: "my-button", | ||
template: """<span class="custom-bracket">[[[<content> | ||
</content>]]]</span>""", | ||
cssUrl: "/css/shadow_dom_bracket.css") | ||
class BracketButton { | ||
} |
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,75 @@ | ||
<!DOCTYPE html> | ||
|
||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Web Components test page</title> | ||
<style> | ||
body { | ||
margin: 0; | ||
/* Extra spacing at top and bottom */ | ||
padding: 20px 20px 0 20px; | ||
min-height: 100%; | ||
font-family: sans-serif; | ||
} | ||
[ng-cloak] { | ||
display: none; | ||
} | ||
</style> | ||
|
||
<script src="packages/web_components/platform.js"></script> | ||
<script src="packages/web_components/dart_support.js"></script> | ||
</head> | ||
|
||
<body> | ||
<p ng-if="false">Just waiting for this demo app to load...</p> | ||
<div class="content" ng-cloak> | ||
<h1>Hi</h1> | ||
|
||
<p>There should be <strong>three</strong> components here. One red, | ||
one green, one blue:</p> | ||
|
||
<my-component color="red">I'm a red component</my-component> | ||
<my-component color="green">I'm a green component</my-component> | ||
<my-component color="blue">I'm a blue component</my-component> | ||
|
||
<br /> | ||
<my-component color="grey">I'm a | ||
<span>content span</span></my-component> | ||
<br /> | ||
<div class="red">I'm just a div with the <code>.red</code> class</div> | ||
<div class="green">I'm just a div with the <code>.green</code> class</div> | ||
<div class="blue">I'm just a div with the <code>.blue</code> class</div> | ||
<br /> | ||
<h4>Nesting</h4> | ||
|
||
|
||
<my-component color="red"> | ||
<my-component color="green"> | ||
<my-component color="blue"> | ||
I'm a blue component. | ||
</my-component> | ||
</my-component> | ||
</my-component> | ||
|
||
<my-component color="green"> | ||
<my-component color="blue"> | ||
<my-component color="red"> | ||
I'm a red component. | ||
</my-component> | ||
</my-component> | ||
</my-component> | ||
|
||
<my-component color="blue"> | ||
<my-component color="red"> | ||
<my-component color="green"> | ||
I'm a green component. | ||
</my-component> | ||
</my-component> | ||
</my-component> | ||
</div> | ||
<script type="application/dart" src="shadow_dom_components.dart"></script> | ||
<script src="packages/browser/dart.js"></script> | ||
</body> | ||
</html> |
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
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
Oops, something went wrong.