<!DOCTYPE html>
<html>
<head>
<base href="." />
<title>Flex-Layout Template</title>
<link rel="stylesheet" href="assets/style.css" />
<script src="https://unpkg.com/zone.js@0.7.2?main=browser"></script>
<script src="https://unpkg.com/zone.js/dist/long-stack-trace-zone.js"></script>
<script src="https://unpkg.com/reflect-metadata@0.1.8/Reflect.js"></script>
<script src="https://unpkg.com/systemjs@0.19.31/dist/system.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/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/flex-layout' : 'npm:@angular/flex-layout/bundles/flex-layout.umd.js',
// other libraries
'rxjs': 'npm:rxjs',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
'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',
template: `
<div class="containerX">
<div [fxLayout]="direction" (click)="toggleDirection()" class="colored box" >
<div fxFlex="20"> fxFlex="20" </div>
<div fxFlex="60"> outer fxFlex="60"
<div fxLayout="row-reverse" fxLayoutAlign="center center" class="colored box" >
<div fxFlex="20"> inner fxFlex="20" </div>
<div fxFlex="60"> inner fxFlex="60" </div>
<div fxFlex > inner fxFlex </div>
</div>
</div>
<div fxFlex > fxFlex </div>
</div>
</div>
<br><br>
<div>Pure css version with inner direction corrected to show how it should be</div>
<div class="colored box" style="display: flex; box-sizing: border-box; flex-direction: row; -webkit-box-orient: horizontal; -webkit-box-direction: normal;">
<div style="flex: 1 1 100%; box-sizing: border-box; -webkit-box-flex: 1; max-width: 20%;"> fxFlex="20" </div>
<div style="flex: 1 1 100%; box-sizing: border-box; -webkit-box-flex: 1; max-width: 60%;"> outer fxFlex="60"
<div class="colored box" style="box-sizing: border-box; max-height: 100%; display: flex; flex-direction: row-reverse; -webkit-box-orient: horizontal; -webkit-box-direction: normal; justify-content: center; align-items: center; align-content: center; -webkit-box-pack: center; -webkit-box-align: center;">
<div style="flex: 1 1 100%; box-sizing: border-box; -webkit-box-flex: 1; max-width: 20%;"> inner fxFlex="20" </div>
<div style="flex: 1 1 100%; box-sizing: border-box; -webkit-box-flex: 1; max-width: 60%;"> inner fxFlex="60" </div>
<div style="flex: 1 1 1e-09px; box-sizing: border-box; -webkit-box-flex: 1;"> inner fxFlex </div>
</div>
</div>
<div style="flex: 1 1 1e-09px; box-sizing: border-box; -webkit-box-flex: 1;"> fxFlex </div>
</div>
<div class="version">@angular/flex-layout (v2.0.0-beta.0)</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.forRoot()
],
declarations: [ TestApp ],
bootstrap: [ TestApp ]
})
export class TestAppModule {}
.containerX {
margin-top: 45px;
border: solid 1px #b6b6b6;
box-sizing: content-box !important;
}
.colorNested, .colored, .coloredContainerX {
height:200px;
}
md-card {
background-color: white;
}
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.coloredContainerX > div:nth-child(1), div.colorNested > div > div:nth-child(1) {
background-color: #009688;
}
div.coloredContainerX > div:nth-child(2), div.colorNested > div > div:nth-child(2) {
background-color: #3949ab;
}
div.coloredContainerX > div:nth-child(3), div.coloredChildren > div:nth-child(3), div.colorNested > div > div:nth-child(3) {
background-color: #9c27b0;
}
div.coloredContainerX > div:nth-child(4), div.coloredChildren > div:nth-child(4), div.colorNested > div > div:nth-child(4) {
background-color: #b08752;
}
div.coloredContainerX > div:nth-child(5), div.coloredChildren > div:nth-child(5), div.colorNested > div > div:nth-child(5) {
background-color: #5ca6b0;
}
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;
}
div.colored > div:nth-child(4), .four {
background-color: #8bc34a;
}
div.colored > div:nth-child(5), .five {
background-color: #03A9F4;
}
div.colored > div:nth-child(6), .six {
background-color: #c9954e;
}
div.colored > div:nth-child(7), .seven {
background-color: #FF5722;
}
.hint {
margin:5px;
font-size:0.9em;
color: #a3a3a3;
margin-bottom:0;
}
.title {
margin:5px;
font-size:0.9em;
color: #5c5c5c;
}
.box {
border: solid 1px gray;
}
button.md-primary {
margin-left:25px;
}
.demo-content {
background-color: ghostwhite;
}
md-toolbar-row button {
min-width: 150px;
}
div.colored.box.nopad > div {
padding: 0;
}
.intro {
margin-top: -52px;
margin-left: 15px;
color: #5c5c5c;
}
.version {
font-size:0.8em;
color: #aeaeae;
margin-top:20px;
}
.blocks {
min-width: 75px;
min-height: 50px;
}
# 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">

</a>
<br/>