Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

docs(cb-barrels): Add barrels cookbook recipe #1419

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
b2c2c3d
docs(cb-example): Add barrels cookbook docs
jmcooper May 16, 2016
cdea51c
Remove unused files
jmcooper May 17, 2016
035d80d
docs(cb-barrels): Clean up copy/paste
jmcooper May 17, 2016
0a6b138
Add // #docregion
jmcooper May 17, 2016
53f97bf
docs(cb-barrels): Add #docregions and finish recipe
jmcooper May 17, 2016
d8ab627
Update imports to use /index for now
jmcooper May 17, 2016
beb3fe5
docs(cb-barrels): Add heroes package to systemjs config
jmcooper May 17, 2016
91bb9d8
fix(resources): use title key from firebase. Adjust layout a bit
May 17, 2016
e855de5
docs(cb-barrels): Fix typo and use .filetree
jmcooper May 17, 2016
0646ada
docs(cb-barrels): reorganize into multiple barrels
jmcooper May 18, 2016
d152ea2
docs(cb-dependency-injection): Fix typos
apai4 May 17, 2016
5b1a84b
chore(docs): revise makeExcerpt mixin, add makeProjExample mixin
chalin May 18, 2016
a595eb8
docs(dart): update BASICS intro (#1410)
kwalrath May 18, 2016
31fe01e
docs: SystemJS to use @angular umd bundles
wardbell May 18, 2016
e4db340
docs:(TOH chapter on Http) New Tour of Hero Chapter on Http
thelgevold Apr 9, 2016
e91659a
docs(tutorial/ts): delete tutorial sample in favor of toh-6
wardbell May 19, 2016
a4bc455
docs(toh): remove unneeded directive from heroes.component
wardbell May 19, 2016
2951183
docs(server-communication): heavily refactored (TS & Dart)
wardbell May 18, 2016
2dc6018
docs(dart): convert toh-5 to Dart (#1426)
kwalrath May 19, 2016
ba02c40
docs: switch from es6-shim to core-js shim
wardbell May 19, 2016
3324bd9
docs(toh-6): fix broken 'Add Hero' and fill in instructional gaps
wardbell May 20, 2016
bd52aa3
docs: complete es6-shim to core-js migration
Foxandxss May 20, 2016
a42f3bf
api-builder: fix githublinks
petebacondarwin May 19, 2016
0cb0bd7
api-builder: fix class github link formatting
petebacondarwin May 19, 2016
16dccb6
api-builder: consolidate readTypescriptProcessor configuration
petebacondarwin May 19, 2016
3a6d223
chore: translate inline system config for plunker
Foxandxss May 19, 2016
efbe3bb
docs(quickstart): fix broken region
Foxandxss May 19, 2016
feec37b
docs(webpack): fix a typo in the dev guide
ramzysa May 19, 2016
f01869d
docs(cb-barrels): Replace tabs with spaces
jmcooper May 20, 2016
9652554
docs(cb-barrel): Create hero-detail barrel
jmcooper May 20, 2016
a599c86
docs(cb-example): Add barrels cookbook docs
jmcooper May 16, 2016
97bc0d0
Remove unused files
jmcooper May 17, 2016
f20941b
docs(cb-barrels): Clean up copy/paste
jmcooper May 17, 2016
2b1e2ea
Add // #docregion
jmcooper May 17, 2016
f3f2a7e
docs(cb-barrels): Add #docregions and finish recipe
jmcooper May 17, 2016
edf7dc5
Update imports to use /index for now
jmcooper May 17, 2016
623b747
docs(cb-barrels): Add heroes package to systemjs config
jmcooper May 17, 2016
9018788
docs(cb-barrels): Fix typo and use .filetree
jmcooper May 17, 2016
0d58578
docs(cb-barrels): reorganize into multiple barrels
jmcooper May 18, 2016
68a3b56
docs(cb-barrels): Replace tabs with spaces
jmcooper May 20, 2016
f4376b8
docs(cb-barrel): Create hero-detail barrel
jmcooper May 20, 2016
cdc278e
Merge branch 'cb-barrels' of github.com:jmcooper/angular.io into cb-b…
jmcooper May 20, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 44 additions & 10 deletions public/_includes/_util-fns.jade
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//- _docsFor: used to identify the language this version of the docs if for;
//- Should be one of: 'ts', 'dart' or 'js'. Set in lang specific _util-fns file.
- var _docsFor = '';
- var _docsFor = '';

//- Should match `_docsFor`, but in this case provides the full capitalized
//- name of the language.
Expand All @@ -29,6 +29,10 @@
- var _Promise = 'Promise';
- var _Observable = 'Observable';

//- Location of sample code
- var _liveLink = 'live link';


//- Used to prefix identifiers that are private. In Dart this will be '_'.
- var _priv = '';

Expand All @@ -46,7 +50,7 @@ mixin adjExPath(path)
| #{adjustExamplePath(path)}
else
| #{path}

mixin includeShared(filePath, region)
- var newPath = translatePath(filePath, region);
!=partial(newPath)
Expand All @@ -68,13 +72,43 @@ mixin makeExample(_filePath, region, _title, stylePatterns)
.example-title #{title}
code-example(language="#{language}" format="#{format}")
!= styleString(frag, stylePatterns)

//- Like makeExample, but doesn't show line numbers and
//- title is appened with `(excerpt)` if it doesn't already
//- end with a parenthetical remark.
mixin makeExcerpt(_filePath, region, _title, stylePatterns)
- if (_title && !_title.match(/\([\w ]+\)$/)) _title = _title + ' (excerpt)';
+makeExample(_filePath, region, _title, stylePatterns)(format='.')

//- Like makeExample, but the first argument is a path that is
//- relative to the project root. Unless title is defined,
//- the project relative path will be used.
mixin makeProjExample(projRootRelativePath, region, title, stylePatterns)
- var relPath = projRootRelativePath.trim();
- var filePath = getExampleName() + '/ts/' + relPath;
- if (!title) {
- // Is path like styles.1.css? Then drop the '.1' qualifier:
- var matches = relPath.match(/^(.*)\.\d(\.\w+)$/);
- title = matches ? matches[1] + matches[2] : relPath;
- }
+makeExample(filePath, region, title, stylePatterns)

//- Like makeExample, but doesn't show line numbers, and the first
//- argument is a path that is relative to the example project root.
//- Unless title is defined, the project relative path will be used.
//- Title will always end with a phrase in parentheses; if no such
//- ending is given, then the title will be suffixed with
//- either "(excerpt)", or "(#{region})" when region is defined.
mixin makeExcerpt(projRootRelativePath, region, title, stylePatterns)
- var relPath = projRootRelativePath.trim();
- var filePath = getExampleName() + '/ts/' + relPath;
- if (!title) {
- // Is path like styles.1.css? Then drop the '.1' qualifier:
- var matches = relPath.match(/^(.*)\.\d(\.\w+)$/);
- title = matches ? matches[1] + matches[2] : relPath;
- }
- var excerpt = region || 'excerpt';
- if (title && !title.match(/\([\w ]+\)$/)) title = title + ' (' + excerpt + ')';
+makeExample(filePath, region, title, stylePatterns)(format='.')

//- Extract the doc example name from `current`.
- var getExampleName = function() {
- var dir = current.path[current.path.length - 1];
- return dir == 'latest' ? current.source : dir;
- };

mixin makeTabs(filePaths, regions, tabNames, stylePatterns)
- filePaths = strSplit(filePaths);
Expand Down Expand Up @@ -134,7 +168,7 @@ script.
el.style.display = isVerbose ? 'block' : 'none';
var el = document.querySelector('button.verbose.on');
el.style.display = isVerbose ? 'none' : 'block';

CCSStylesheetRuleStyle('main','.l-verbose-section', 'display',
isVerbose ? 'block' : 'none');
}
Expand Down
2 changes: 1 addition & 1 deletion public/docs/_examples/architecture/ts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link rel="stylesheet" href="styles.css">

<!-- Polyfill(s) for older browsers -->
<script src="node_modules/es6-shim/es6-shim.min.js"></script>
<script src="node_modules/core-js/client/shim.min.js"></script>

<script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/reflect-metadata/Reflect.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion public/docs/_examples/attribute-directives/ts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<link rel="stylesheet" href="styles.css">

<!-- Polyfill(s) for older browsers -->
<script src="node_modules/es6-shim/es6-shim.min.js"></script>
<script src="node_modules/core-js/client/shim.min.js"></script>

<script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/reflect-metadata/Reflect.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<!-- #enddocregion style -->

<!-- Polyfill(s) for older browsers -->
<script src="node_modules/es6-shim/es6-shim.min.js"></script>
<script src="node_modules/core-js/client/shim.min.js"></script>

<script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/reflect-metadata/Reflect.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ describe('Tutorial', function () {
browser.get('');
});


function getPageStruct() {
hrefEles = element.all(by.css('my-app a'));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// #docregion imports
import { Component } from '@angular/core';
import { RouteConfig, ROUTER_DIRECTIVES } from '@angular/router-deprecated';

import { HeroesComponent } from './heroes.component';
import { HeroDetailComponent } from './hero-detail.component';
import { HeroesComponent, HeroDetailComponent, HeroService } from './heroes';
import { DashboardComponent } from './dashboard.component';
import { HeroService } from './hero.service';

@Component({
// #enddocregion
selector: 'my-app',
template: `
<h1>{{title}}</h1>
Expand All @@ -27,5 +26,5 @@ import { HeroService } from './hero.service';
{path: '/detail/:id', name: 'HeroDetail', component: HeroDetailComponent}
])
export class AppComponent {
title = 'Tour of Heroes';
title = 'Tour of Heroes - Barrels';
}
60 changes: 60 additions & 0 deletions public/docs/_examples/cb-barrels/ts/app/dashboard.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[class*='col-'] {
float: left;
}
*, *:after, *:before {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
h3 {
text-align: center; margin-bottom: 0;
}
[class*='col-'] {
padding-right: 20px;
padding-bottom: 20px;
}
[class*='col-']:last-of-type {
padding-right: 0;
}
.grid {
margin: 0;
}
.col-1-4 {
width: 25%;
}
.module {
padding: 20px;
text-align: center;
color: #eee;
max-height: 120px;
min-width: 120px;
background-color: #607D8B;
border-radius: 2px;
}
h4 {
position: relative;
}
.module:hover {
background-color: #EEE;
cursor: pointer;
color: #607d8b;
}
.grid-pad {
padding: 10px 0;
}
.grid-pad > [class*='col-']:last-of-type {
padding-right: 20px;
}
@media (max-width: 600px) {
.module {
font-size: 10px;
max-height: 75px; }
}
@media (max-width: 1024px) {
.grid {
margin: 0;
}
.module {
min-width: 60px;
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// #docregion imports
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router-deprecated';

import { Hero } from './hero';
import { HeroService } from './hero.service';
import { Hero, HeroService } from './heroes';

@Component({
// #enddocregion
selector: 'my-dashboard',
templateUrl: 'app/dashboard.component.html',
styleUrls: ['app/dashboard.component.css']
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div *ngIf="hero">
<h2>{{hero.name}} details!</h2>
<div>
<label>id: </label>{{hero.id}}</div>
<div>
<label>name: </label>
<input [(ngModel)]="hero.name" placeholder="name"/>
</div>
<button (click)="goBack()">Back</button>
</div>
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// #docregion imports
import { Component, OnInit } from '@angular/core';
import { RouteParams } from '@angular/router-deprecated';

import { Hero } from './hero';
import { HeroService } from './hero.service';
import { HeroService, Hero } from '../shared';

@Component({
// #enddocregion
selector: 'my-hero-detail',
templateUrl: 'app/hero-detail.component.html',
styleUrls: ['app/hero-detail.component.css']
templateUrl: 'app/heroes/hero-detail/hero-detail.component.html',
styleUrls: ['app/heroes/hero-detail/hero-detail.component.css']
})
export class HeroDetailComponent implements OnInit {
hero: Hero;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// #docregion
export * from './hero-detail.component';
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// #docregion imports
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router-deprecated';
import { HeroService } from './hero.service';
import { HeroDetailComponent } from './hero-detail.component';
import { Hero } from './hero';
import { HeroService, Hero } from './shared';
import { HeroDetailComponent } from './hero-detail'

@Component({
// #enddocregion
selector: 'my-heroes',
templateUrl: 'app/heroes.component.html',
styleUrls: ['app/heroes.component.css'],
templateUrl: 'app/heroes/heroes.component.html',
styleUrls: ['app/heroes/heroes.component.css'],
directives: [HeroDetailComponent]
})
export class HeroesComponent implements OnInit {
Expand Down
4 changes: 4 additions & 0 deletions public/docs/_examples/cb-barrels/ts/app/heroes/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// #docregion
export * from './hero-detail';
export * from './heroes.component';
export * from './shared';
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class Hero {
id: number;
name: string;
}

Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// #docregion imports
import { Injectable } from '@angular/core';

import { HEROES } from './mock-heroes';

@Injectable()
export class HeroService {
// #enddocregion
getHeroes() {
return Promise.resolve(HEROES);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// #docregion
export * from './hero.model';
export * from './hero.service';
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// #docregion imports
import { Hero } from './hero.model';

export var HEROES: Hero[] = [
// #enddocregion

{"id": 11, "name": "Mr. Nice"},
{"id": 12, "name": "Narco"},
{"id": 13, "name": "Bombasto"},
{"id": 14, "name": "Celeritas"},
{"id": 15, "name": "Magneta"},
{"id": 16, "name": "RubberMan"},
{"id": 17, "name": "Dynama"},
{"id": 18, "name": "Dr IQ"},
{"id": 19, "name": "Magma"},
{"id": 20, "name": "Tornado"}
];
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// #docregion imports
import { bootstrap } from '@angular/platform-browser-dynamic';
import { ROUTER_PROVIDERS } from '@angular/router-deprecated';

import { HeroService } from './hero.service';
import { HeroService } from './heroes';
import { AppComponent } from './app.component';

bootstrap(AppComponent, [
// #enddocregion
ROUTER_PROVIDERS,
HeroService
]);
35 changes: 35 additions & 0 deletions public/docs/_examples/cb-barrels/ts/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html>
<head>
<base href="/">
<title>Angular 2 Tour of Heroes - Barrels</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css">

<!-- Polyfill(s) for older browsers -->
<script src="node_modules/es6-shim/es6-shim.min.js"></script>

<script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/reflect-metadata/Reflect.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>

<!--#docregion packages -->
<script src="systemjs.config.js"></script>
<script>
System.config({
packages: {
'app/heroes': {main: 'index.js', defaultExtension: 'js'},
'app/heroes/hero-detail': {main: 'index.js', defaultExtension: 'js'},
'app/heroes/shared': {main: 'index.js', defaultExtension: 'js'}
}
});
System.import('app').catch(function(err){ console.error(err); });
</script>
<!--#enddocregion packages -->
</head>

<body>
<my-app>Loading...</my-app>
</body>
</html>
8 changes: 8 additions & 0 deletions public/docs/_examples/cb-barrels/ts/plnkr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"description": "Cookbook: Barrels",
"files":[
"!**/*.d.ts",
"!**/*.js"
],
"tags": ["cookbook", "barrels"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<link rel="stylesheet" href="demo.css">

<!-- Polyfill(s) for older browsers -->
<script src="node_modules/es6-shim/es6-shim.min.js"></script>
<script src="node_modules/core-js/client/shim.min.js"></script>

<script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/reflect-metadata/Reflect.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<!-- #enddocregion style -->

<!-- Polyfill(s) for older browsers -->
<script src="node_modules/es6-shim/es6-shim.min.js"></script>
<script src="node_modules/core-js/client/shim.min.js"></script>

<script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/reflect-metadata/Reflect.js"></script>
Expand Down
Loading