<!DOCTYPE html>
<html>

  <head>
    <base href="." />
    <title>Flex-Layout Template</title>
    <link rel="stylesheet" href="assets/style.css" />
    
    <script src="https://unpkg.com/core-js/client/shim.min.js"></script>
    <script src="https://unpkg.com/zone.js@0.8.4?main=browser"></script>
    <script src="https://unpkg.com/systemjs@0.19.41/dist/system.src.js"></script>
    <script src="lib/config.js"></script>
    <script>
    System.import('app')
      .catch(console.error.bind(console));
  </script>
  </head>

  <body>
    <test-app>
    loading...
  </test-app>
  </body>

</html>
System.config({
  //use typescript for compilation
  transpiler: 'typescript',
  //typescript compiler options
  typescriptOptions: {
      // Copy of compiler options in standard tsconfig.json
      "target": "es5",
      "module": "es2015",
      "moduleResolution": "node",
      "sourceMap": true,
      "emitDecoratorMetadata": true,
      "experimentalDecorators": true,
      "noImplicitAny": true,
      "suppressImplicitAnyIndexErrors": true
  },
  meta: {
      'typescript': {
        "exports": "ts"
      }
    },  
  paths: {
    'npm:': 'https://unpkg.com/'
  },
  //map tells the System loader where to look for things
  map: {
    
    'app': './src',

    '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
    '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
    '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
    '@angular/animations': 'npm:@angular/animations/bundles/animations.umd.js',
    '@angular/animations/browser': 'npm:@angular/animations/bundles/animations-browser.umd.js',
    '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
    '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
    '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
    '@angular/platform-browser/animations': 'npm:@angular/platform-browser/bundles/platform-browser-animations.umd.js',
    '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
    '@angular/animations': 'npm:@angular/animations/bundles/animations.umd.js',
    '@angular/animations/browser': 'npm:@angular/animations/bundles/animations-browser.umd.js',
    '@angular/material' : 'npm:@angular/material/bundles/material.umd.js',
    '@angular/cdk' : 'npm:@angular/cdk/bundles/cdk.umd.js',
    '@angular/flex-layout' : 'https://rawgit.com/angular/flex-layout-builds/master/bundles/flex-layout.umd.js',
    
    // other libraries
    'rxjs':                      'npm:rxjs',
    'typescript':                'npm:typescript@2.0.10/lib/typescript.js',    
  },
  //packages defines our app package
  packages: {
    app: {
      main: './boot.ts',
      defaultExtension: 'ts'
    },
    rxjs: {
      defaultExtension: 'js'
    }
  }
});
//main entry point
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {TestAppModule} from './app/test-app-module';

platformBrowserDynamic().bootstrapModule(TestAppModule);
//our root app component
import {Component} from '@angular/core'

@Component({
  selector: 'test-app',
  styles : [
    `.fixVertical  {
      flex: 1 1 100%;
      min-height:100vh;
    }`,
    `.yellow {
      background-color:yellow
    }`
  ],
  template: `
  <div 
    fxLayout="column"
    fxLayoutAlign="start none" 
    class="fixVertical yellow">
    
    <header 
      class="flex-container"
      fxLayout="row"
      fxLayoutAlign="center center">
        <div fxFlex="20"></div>
        <div fxFlex="60">  this is my header  </div>
        <div fxFlex ></div>
    </header>
    
    <div class="flex-container" fxFlex fxFlexFill>
      <div 
        [fxLayout]="direction" 
        (click)="toggleDirection()" 
        class="colored" >
        <div fxFlex="20">  fxFlex="20"  </div>
        <div fxFlex="60">  fxFlex="60"  </div>
        <div fxFlex >      fxFlex       </div>
      </div>
    </div>
    <footer 
      class="flex-container"
      fxLayout="row"
      fxLayoutAlign="center center">
      this footer should always stick to the bottom of the page
    </footer>
  </div>
  `,
})
export class TestApp {
  direction = "row";

   toggleDirection() {
     let next = (DIRECTIONS.indexOf(this.direction) +1 ) % DIRECTIONS.length;
     this.direction = DIRECTIONS[next];
   }
}
const DIRECTIONS = ['row', 'row-reverse', 'column', 'column-reverse'];
import {Component, NgModule} from '@angular/core'
import {BrowserModule} from '@angular/platform-browser'
import * as Rx from 'rxjs/Rx';

import {FlexLayoutModule} from "@angular/flex-layout";

import { TestApp} from "./test-app";

@NgModule({
  imports: [ 
    BrowserModule,
     FlexLayoutModule
  ],
  declarations: [ TestApp ],
  bootstrap: [ TestApp ]
})
export class TestAppModule {}
body {
  height: 100%;
}

header {
  background-color: gray;
  height: 50px;
}

footer {
  color: black;
  background-color: lightblue;
  padding: 20px;
}

.colorNested, .colored, .coloredContainerX {
  height:100%;
}

div.coloredContainerX > div, div.colorNested > div > div {
  padding: 8px;
  box-shadow: 0px 2px 5px 0 rgba(52, 47, 51, 0.63);
  opacity: 0.9;
  color: #fff;
  text-align: center;
}


div.colored > div {
  padding: 8px;
  box-shadow: 0px 2px 5px 0 rgba(52, 47, 51, 0.63);
  opacity: 0.9;
  color: #fff;
  text-align: center;
}

div.colored > div:nth-child(1), .one {
  background-color: #009688;
}

div.colored > div:nth-child(2), .two {
  background-color: #3949ab;
}

div.colored > div:nth-child(3), .three {
  background-color: #9c27b0;
}

test-app {
  
  height: 100vh;
  display: block;
  min-height: 100vh;
}



# Flex Layout

Angular Flex Layout provides a sophisticated layout API using FlexBox CSS + mediaQuery. This module provides Angular (v2.x and higher) developers with component layout features using a custom Layout API, mediaQuery observables,and injected DOM flexbox-2016 css stylings.  

The Layout engine intelligently automates the process of applying appropriate FlexBox CSS to browser view hierarchies. This automation also addresses many of the complexities and workarounds encountered with the traditional, manual, CSS-only application of Flexbox CSS. 

---

The sources for this package are in the [Flex-Layout](https://github.com/angular/flex-layout) repository. <br/>
Please file issues and pull requests against that repo.

License: MIT

---

### BREAKING CHANGE

Directive selectors are now camelCase (instead of dash-case); as specified in the Angular Style Guide (Q4, 2016):

*  @Component selectors always use dash-case
*  @Directive selectors always use camelCase
> Except when the directive is pretending to be a component (i.e, if it had a template it would be '<ng-content></ng-content>').
*  @Directive properties are prefixed with namespace info
> @Component properties are not


```html
<div class="flex-container" 
     fxLayout="row" 
     fxLayout.xs="column"
     fxLayoutAlign="center center"
     fxLayoutAlign.xs="start">
  <div class="flex-item" fxFlex="20%" fxFlex.xs="40%">  </div>
  <div class="flex-item" fxFlex>        </div>
  <div class="flex-item" fxFlex="25px"> </div>
</div> 
```

### Quick Links

*  [Wiki Docs](https://github.com/angular/flex-layout/wiki)
*  [License: MIT](https://raw.githubusercontent.com/angular/flex-layout-builds/master/LICENSE)

Developers

*  [API Overview](https://github.com/angular/flex-layout/wiki/API-Overview)
*  [Developer Setup](https://github.com/angular/flex-layout/wiki/Developer-Setup)
*  [Builds + Fast Start](https://github.com/angular/flex-layout/wiki/Fast-Starts)
*  [Integration with Angular CLI](https://github.com/angular/flex-layout/wiki/Integration-with-Angular-CLI)

Demos 

*  [Explore Online](https://tburleson-layouts-demos.firebaseapp.com/)
*  [Source Code](https://github.com/angular/flex-layout/blob/master/src/demo-app/app/demo-app-module.ts)

Templates

*  [Plunkr Template](https://plnkr.co/edit/h8hzyoEyqdCXmTBA7DfK?p=preview)

----


### Why choose Flex-Layout

While other Flexbox CSS libraries are implementations of:

* pure CSS-only implementations, or 
* the JS+CSS Stylesheets implementation of Angular Material v1.x Layouts.

Angular Flex Layout - in contrast - is a pure-Typescript UI Layout engine with an implementation that: 

*  uses HTML attributes (aka Layout API) to specify the layout configurations
*  is currently only available for Angular (v2.x or higher) Applications.
*  is independent of Angular Material (v1 or v2).
*  requires no external stylesheets.
*  requires Angular v2.x or higher.

<br/>

### Browser Support

<a href="http://caniuse.com/#feat=flexbox" target="_blank">
![caniuseflexbox](https://cloud.githubusercontent.com/assets/210413/21288118/917e3faa-c440-11e6-9b08-28aff590c7ae.png)
</a>

<br/>