diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c4474b4782..918d7ac829d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,31 +57,31 @@ $mdDialog.show( | Label | Size (dp) | Attribute | |--------|--------|--------| -| Phone | 0 <= size <= 600 | layout-phone | -| Tablet | 600 > size <= 960 | layout-tablet | -| Tablet-Landscape | 960 >= size <= 1200 | layout-tablet-landscape | -| PC | > 1200 | layout-pc | +| Phone | 0 <= size <= 600 | layout-sm | +| Tablet | 600 > size <= 960 | layout-md | +| Tablet-Landscape | 960 >= size <= 1200 | layout-lg | +| PC | > 1200 | layout-gt-lg | > **Example 1**: To use a *horizontal* layout and responsively change to *vertical* for screen sizes < 600 dp: >```html -
+
> ``` > > **Example 2**: To use a *horizontal* layout and change to *vertical* for *phone* and *tablet* screen sizes: >```html -
+
``` > **Example 3**: To show an element except when on a *phone* (or smaller) screen size: >```html -
+
``` > **Example 4**: To always hide an element, but show it only on phone (or smaller) devices: >```html -
+
``` * For performance, the *disabled* attribute is no longer supported; instead the *ng-disabled* attribute is now read to check if a component is disabled. ([2ece8cd7](https://github.com/angular/material/commit/2ece8cd794c4c28df4fb6a7683492da71aa2c382)) diff --git a/docs/app/css/layout-demo.css b/docs/app/css/layout-demo.css index 212c06784c4..ddb55ee8069 100644 --- a/docs/app/css/layout-demo.css +++ b/docs/app/css/layout-demo.css @@ -1,8 +1,4 @@ -.code-view pre > code.highlight { - padding: 0; -} - .inline-demo { margin: 0 0 25px 0; padding: 5px; @@ -12,203 +8,20 @@ text-align: center; } -.inline-demo > div { - padding: 5px; - min-width: 130px; - border: 1px solid #004d40; - background: #00897b; - color: #e0f2f1; -} - -.layout-demo [layout], -.layout-demo [layout-phone], -.layout-demo [layout-tablet], -.layout-demo [layout-tablet-landscape], -.layout-demo [layout-pc], -.layout-guidelines [layout], -.layout-guidelines [layout-phone], -.layout-guidelines [layout-tablet], -.layout-guidelines [layout-tablet-landscape], -.layout-guidelines [layout-pc] { - background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAKSURBVAgdY2AAAAACAAHPyDXlAAAAAElFTkSuQmCC"); - background-position: -1px -1px; - background-repeat: no-repeat; -} - -.layout-demo [layout="row"], -.layout-guidelines [layout="row"] { - background-position: 50% 50%; - background-repeat: repeat-x; -} - -.layout-demo [layout="column"], -.layout-guidelines [layout="column"] { - background-position: 50% 50%; - background-repeat: repeat-y; -} - -iframe-code-view iframe { - margin: 0; - width: 100%; - height: 300px; - border: 1px solid #ccc; -} -iframe-code-view p { - margin: 4px 0 40px 0; -} - -body.layout-demo { - margin: 0; - padding: 0; - color: white; -} - -.demo-no-padding [layout] > div { - padding: 10px; - min-width: 30px; -} - -.demo-padding [layout-padding] > div > div, -.demo-with-padding [layout-padding] > div > div { - margin: 0; - padding: 10px; -} - -.demo-no-padding [layout]:nth-child(1) > div, -.demo-padding [layout-padding]:nth-child(1) > div > div, -.demo-color-a { - border: 1px solid #0097a7; - background: #00BCD4; -} - -.demo-no-padding [layout]:nth-child(2) > div, -.demo-padding [layout-padding]:nth-child(2) > div > div, -.demo-color-b { - border: 1px solid #689f38; - background: #8BC34A; -} - -.demo-no-padding [layout]:nth-child(3) > div, -.demo-padding [layout-padding]:nth-child(3) > div > div, -.demo-color-c { - border: 1px solid #610C2D; - background: #C2185B; -} - -.demo-no-padding [layout]:nth-child(4) > div, -.demo-padding [layout-padding]:nth-child(4) > div > div, -.demo-color-d { - border: 1px solid #ffa000; - background: #ffc107; -} - -.demo-no-padding [layout]:nth-child(5) > div, -.demo-padding [layout-padding]:nth-child(5) > div > div, -.demo-color-e { - border: 1px solid #f50057; - background: #FF4081; -} - -.demo-no-padding [layout]:nth-child(6) > div, -.demo-padding [layout-padding]:nth-child(6) > div > div, -.demo-color-f { - border: 1px solid #8e24aa; - background: #AB47BC; -} - -.demo-padding span { - padding: 5px; - background: #AB47BC; -} - -.demo-padding p { - padding: 5px 0; - color: #333; -} - -.full-layout-demo header { - background: #AB47BC; - color: white; -} - -.full-layout-demo aside { - background: #00BCD4; - color: white; -} - -.full-layout-demo main { - background: white; - color: #333; -} - -.full-layout-demo footer { - background: #8BC34A; - color: white; -} - -body.layout-demo:before { - position: fixed; - top: 4px; - right: 4px; - display: block; - padding: 3px 4px; - width: 50px; - border-radius: 2px; - background: #b0120a; - color: white; - content: 'default'; - text-align: center; - font-size: 10px; - opacity: .9; -} - -@media (min-width: 600px) { - body.layout-demo:before { - background: #4a148c; - content: 'small'; - } - .layout-demo [layout-phone="row"], - .layout-guidelines [layout-phone="row"] { - background-position: 50% 50%; - background-repeat: repeat-x; - } - .layout-demo [layout-phone="column"], - .layout-guidelines [layout-phone="column"] { - background-position: 50% 50%; - background-repeat: repeat-y; - } +.layout-guidelines demo-include [layout] > * { + padding: 8px; + min-width: 136px; + box-shadow: 0px 2px 5px 0 rgba(0,0,0,0.26); + margin: 8px; } -@media (min-width: 960px) { - body.layout-demo:before { - background: #0d5302; - content: 'medium'; - } - .layout-demo [layout-tablet="row"][layout-phone="row"], - .layout-guidelines [layout-tablet="row"][layout-phone="row"] { - background-position: 50% 50%; - background-repeat: repeat-x; - } - .layout-demo [layout-tablet="column"][layout-phone="column"], - .layout-guidelines [layout-tablet="column"][layout-phone="column"] { - background-position: 50% 50%; - background-repeat: repeat-y; - } +.layout-demo :not([layout]) { + border: 1px solid #eee; + padding: 8px; + font-size: 16px; } -@media (min-width: 1200px) { - body.layout-demo:before { - background: #01579b; - content: 'large'; - } - .layout-demo [layout-tablet-landscape="row"][layout-pc="row"], - .layout-guidelines [layout-tablet-landscape="row"][layout-pc="row"] { - background-position: 50% 50%; - background-repeat: repeat-x; - } - .layout-demo [layout-tablet-landscape="column"][layout-pc="column"], - .layout-guidelines [layout-tablet-landscape="column"][layout-pc="column"] { - background-position: 50% 50%; - background-repeat: repeat-y; - } +.layout-content .demo-box { + box-shadow: 0px 1px 3px 0 rgba(0,0,0,0.26); + padding: 16px; } diff --git a/docs/app/css/style.css b/docs/app/css/style.css index ac1f06d1f03..dbd94cccb38 100644 --- a/docs/app/css/style.css +++ b/docs/app/css/style.css @@ -159,7 +159,8 @@ code:not(.highlight) { } .demo-container { - margin-top: 30px; + border-radius: 4px; + margin-top: 16px; -webkit-transition: 0.02s padding ease-in-out; transition: 0.02s padding ease-in-out; position: relative; @@ -205,6 +206,13 @@ md-tabs.demo-source-tabs md-tab-label { display: -ms-flexbox; display: flex; } +.small-demo .demo-source-tabs:not(.ng-hide) { + min-height: 224px; + max-height: 224px; +} +.small-demo .demo-content { + min-height: 128px; +} .demo-content > * { -webkit-box-flex: 1; -webkit-flex: 1; @@ -217,6 +225,14 @@ md-tabs.demo-source-tabs md-tab-label { .demo-content > div[layout-fill] { min-height: 448px; } +.small-demo .demo-content > div[layout-fill] { + min-height: 224px; +} +.small-demo .demo-toolbar { + min-height: 48px; + max-height: 48px; + font-size: 20px; +} .show-source md-toolbar.demo-toolbar { box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.36); @@ -372,15 +388,11 @@ ul.methods li h3 { font-size: 0.95em; } - - .demo-source-container pre, .demo-source-container code { min-height: 100%; } - - md-content.demo-source-container > hljs > pre > code.highlight { position : absolute; top : 0px; diff --git a/docs/app/demo/layout/full-width-header-menu-footer.html b/docs/app/demo/layout/full-width-header-menu-footer.html index c5df17e7c9a..05a6a009fbc 100644 --- a/docs/app/demo/layout/full-width-header-menu-footer.html +++ b/docs/app/demo/layout/full-width-header-menu-footer.html @@ -11,7 +11,7 @@ Header -
+
-
+
Uno
diff --git a/docs/app/demo/layout/layout-order.html b/docs/app/demo/layout/layout-order.html index 1b851563dab..903375894dc 100644 --- a/docs/app/demo/layout/layout-order.html +++ b/docs/app/demo/layout/layout-order.html @@ -7,7 +7,7 @@ -
+
Uno
diff --git a/docs/app/demo/layout/layout-padding-offsets.html b/docs/app/demo/layout/layout-padding-offsets.html index 3bbbf104a82..244cfffb422 100644 --- a/docs/app/demo/layout/layout-padding-offsets.html +++ b/docs/app/demo/layout/layout-padding-offsets.html @@ -7,10 +7,10 @@ -
+
-
-
Uno [flex][offset-phone="0"][offset="25"]
+
+
Uno [flex][offset-sm="0"][offset="25"]
@@ -23,19 +23,19 @@
-
+
Uno [flex]
-
-
Dos [flex][flex-pc="50"][offset-pc="25"]
+
+
Dos [flex][flex-gt-lg="50"][offset-gt-lg="25"]
-
+
Uno [flex="50"][offset="25"]
@@ -43,19 +43,19 @@
-
+
Uno [flex]
-
-
Dos [flex][flex-tablet-landscape="25"][flex-pc="25"]
+
+
Dos [flex][flex-lg="25"][flex-gt-lg="25"]
-
+
Uno [flex]
diff --git a/docs/app/demo/layout/layout-padding-percents.html b/docs/app/demo/layout/layout-padding-percents.html index cf7f5e9b9fb..a5fe7fe14a8 100644 --- a/docs/app/demo/layout/layout-padding-percents.html +++ b/docs/app/demo/layout/layout-padding-percents.html @@ -7,7 +7,7 @@ -
+
Uno [flex="33"]
@@ -19,7 +19,7 @@
-
+
Uno [flex="66"]
@@ -31,7 +31,7 @@
-
+
Uno [flex]
@@ -47,10 +47,10 @@
-
+
-
-
Uno [flex][flex-phone="33"][flex-tablet="66"]
+
+
Uno [flex][flex-sm="33"][flex-md="66"]
diff --git a/docs/app/demo/layout/layout-padding.html b/docs/app/demo/layout/layout-padding.html index 57c1f66a02b..e5f2679bc3a 100644 --- a/docs/app/demo/layout/layout-padding.html +++ b/docs/app/demo/layout/layout-padding.html @@ -7,7 +7,7 @@ -
+
Uno [flex]
@@ -27,7 +27,7 @@
-
+
Uno [flex]
@@ -47,7 +47,7 @@
-
+
Uno [flex]
diff --git a/docs/app/js/app.js b/docs/app/js/app.js index 48bcddace2d..7a9507cc2e0 100644 --- a/docs/app/js/app.js +++ b/docs/app/js/app.js @@ -306,17 +306,16 @@ function($rootScope, $scope, component, demos, $http, $templateCache, $q) { .concat(demo.js || []) .concat(demo.css || []) .concat(demo.html || []); - $q.all(files.map(function(file) { - return $http.get(file.outputPath, {cache: $templateCache}) + files.forEach(function(file) { + file.httpPromise =$http.get(file.outputPath, {cache: $templateCache}) .then(function(response) { file.contents = response.data .replace('', ''); + return file.contents; }); - })).then(function() { - demo.$files = files; - demo.$selectedFile = demo.index; - $scope.demos.push(demo); }); + demo.$files = files; + $scope.demos.push(demo); }); $scope.demos = $scope.demos.sort(function(a,b) { diff --git a/docs/app/js/demo.js b/docs/app/js/demo.js new file mode 100644 index 00000000000..4da683f9ecd --- /dev/null +++ b/docs/app/js/demo.js @@ -0,0 +1,71 @@ +DocsApp.directive('docsDemo', [ + '$mdUtil', +function($mdUtil) { + return { + restrict: 'E', + scope: { + }, + templateUrl: 'partials/docs-demo.tmpl.html', + transclude: true, + controller: ['$scope', '$element', '$attrs', '$interpolate', DocsDemoCtrl], + controllerAs: 'demoCtrl', + bindToController: true + }; + + function DocsDemoCtrl($scope, $element, $attrs, $interpolate) { + var self = this; + + self.demoId = $interpolate($attrs.demoId || '')($scope.$parent); + self.demoTitle = $interpolate($attrs.demoTitle || '')($scope.$parent); + self.demoModule = $interpolate($attrs.demoModule || '')($scope.$parent); + self.files = { + css: [], js: [], html: [] + }; + + self.addFile = function(name, contentsPromise) { + var file = { + name: name, + contentsPromise: contentsPromise, + fileType: name.split('.').pop() + }; + contentsPromise.then(function(contents) { + file.contents = contents; + }); + + if (name === 'index.html') { + self.files.index = file; + } else { + self.files[file.fileType] = self.files[file.fileType] || []; + self.files[file.fileType].push(file); + } + + self.orderedFiles = [] + .concat(self.files.index || []) + .concat(self.files.js || []) + .concat(self.files.css || []) + .concat(self.files.html || []); + }; + } +}]) +.directive('demoFile', ['$q', '$interpolate', function($q, $interpolate) { + return { + restrict: 'E', + require: '^docsDemo', + compile: compile + }; + + function compile(element, attr) { + var contentsAttr = attr.contents; + var html = element.html(); + var name = attr.name; + element.contents().remove(); + + return function postLink(scope, element, attr, docsDemoCtrl) { + docsDemoCtrl.addFile( + $interpolate(name)(scope), + $q.when(scope.$eval(contentsAttr) || html) + ); + element.remove(); + }; + } +}]); diff --git a/docs/app/js/demoInclude.js b/docs/app/js/demoInclude.js index 10987a1c3f3..7655e4ff7b1 100644 --- a/docs/app/js/demoInclude.js +++ b/docs/app/js/demoInclude.js @@ -3,33 +3,38 @@ DocsApp.directive('demoInclude', [ '$http', '$compile', '$templateCache', -function($q, $http, $compile, $templateCache) { - return function postLink(scope, element, attr) { + '$timeout', +function($q, $http, $compile, $templateCache, $timeout) { + return { + restrict: 'E', + link: postLink + }; + + function postLink(scope, element, attr) { var demoContainer; // Interpret the expression given as `demo-include="something"` - var demo = scope.$eval(attr.demoInclude); + var files = scope.$eval(attr.files) || {}; + var ngModule = scope.$eval(attr.module) || ''; - handleDemoIndexFile(); + $timeout(handleDemoIndexFile); /** - * Fetch the demo's incdex file, and if it contains its own ng-app module - * then bootstrap a new angular app with that module. Otherwise, compile + * Fetch the demo's incdex file, and if it contains its own ng-app ngModule + * then bootstrap a new angular app with that ngModule. Otherwise, compile * the demo into the current demo ng-app. */ function handleDemoIndexFile() { - $http.get(demo.index.outputPath, {cache: $templateCache}) - .then(function(response) { + files.index.contentsPromise.then(function(contents) { demoContainer = angular.element( - '
' + '
' ); - var demoIndexHtml = response.data; - var isStandalone = !!demo.ngModule.module; + var isStandalone = !!ngModule; var demoScope; var demoCompileService; if (isStandalone) { - angular.bootstrap(demoContainer[0], [demo.ngModule.module]); + angular.bootstrap(demoContainer[0], [ngModule]); demoScope = demoContainer.scope(); demoCompileService = demoContainer.injector().get('$compile'); scope.$on('$destroy', function() { @@ -48,8 +53,8 @@ function($q, $http, $compile, $templateCache) { ]).finally(function() { demoScope.$evalAsync(function() { element.append(demoContainer); - demoContainer.html(demoIndexHtml); - demoCompileService( demoContainer.contents() )(demoScope); + demoContainer.html(contents); + demoCompileService(demoContainer.contents())(demoScope); }); }); }); @@ -61,9 +66,8 @@ function($q, $http, $compile, $templateCache) { * Fetch the demo styles, and append them to the DOM. */ function handleDemoStyles() { - return $q.all((demo.css || []).map(function(file) { - return $http.get(file.outputPath, {cache: $templateCache}) - .then(function(response) { return response.data; }); + return $q.all(files.css.map(function(file) { + return file.contentsPromise; })) .then(function(styles) { styles = styles.join('\n'); //join styles as one string @@ -88,12 +92,12 @@ function($q, $http, $compile, $templateCache) { * 'generated/material.components.dialog/demo/demo1/my-dialog.tmpl.html'. */ function handleDemoTemplates() { - return $q.all((demo.html || []).map(function(file) { - return $http.get(file.outputPath, {cache: $templateCache}).then(function(response) { + return $q.all(files.html.map(function(file) { + + return file.contentsPromise.then(function(contents) { // Get the $templateCache instance that goes with the demo's specific ng-app. var demoTemplateCache = demoContainer.injector().get('$templateCache'); - - demoTemplateCache.put(file.name, response.data); + demoTemplateCache.put(file.name, contents); scope.$on('$destroy', function() { demoTemplateCache.remove(file.name); @@ -105,6 +109,6 @@ function($q, $http, $compile, $templateCache) { } - }; + } }]); diff --git a/docs/app/js/highlight-angular.js b/docs/app/js/highlight-angular.js index 426786e8475..a9f819a0213 100644 --- a/docs/app/js/highlight-angular.js +++ b/docs/app/js/highlight-angular.js @@ -12,22 +12,7 @@ DocsApp } return function(scope, element, attr) { - - //var contentParent = angular.element('
'); - //var codeElement = contentParent.find('code'); - // - //// Attribute? code is the evaluation - //if (attr.code) { - // code = scope.$eval(attr.code); - //} - //if (!code) return; - //var highlightedCode = hljs.highlight(attr.language || attr.lang, code.trim()); - //highlightedCode.value = highlightedCode.value.replace(/=""<\/span>/gi, ''); - //codeElement.append(highlightedCode.value).addClass('highlight'); - // - //element.append(contentParent); - - + var contentParent; if (attr.code) { // Attribute? code is the evaluation @@ -35,57 +20,42 @@ DocsApp } if ( code ) { - var contentParent = angular.element('
'); - + contentParent = angular.element('
'); element.append(contentParent); - // Defer highlighting 1-frame to prevent GA interference... - $timeout(function() { - var codeElement = contentParent.find('code'); - var highlightedCode = hljs.highlight(attr.language || attr.lang, code.trim(), true); + $timeout(render, 0, false); + } - highlightedCode.value = highlightedCode.value - .replace(/=""<\/span>/gi, '') - .replace('', '') - .replace('', ''); + function render() { - codeElement.append(highlightedCode.value).addClass('highlight'); - },0, false); - } - }; - } - }; -}]) + var codeElement = contentParent.find('code'); + var lines = code.split('\n'); -.directive('codeView', function() { - return { - restrict: 'C', - link: function(scope, element) { - var code = element.eq(0).clone(); - code.children().removeAttr('class'); + // Remove empty lines + lines = lines.filter(function(line) { + return line.trim().length; + }); - var highlightedCode = hljs.highlight('html', code[0].innerHTML); + // Make it so each line starts at 0 whitespace + var firstLineWhitespace = lines[0].match(/^\s*/)[0] || ''; + lines = lines.map(function(line) { + return line + .replace(new RegExp('^' + firstLineWhitespace), '') + .replace(/\s+$/, ''); + }); - highlightedCode.value = highlightedCode.value.replace(/=""<\/span>/gi, ''); + var highlightedCode = hljs.highlight(attr.language || attr.lang, lines.join('\n'), true); - element.prepend('
' + highlightedCode.value + '
'); - element.find('code').addClass('highlight'); - } - }; -}) + highlightedCode.value = highlightedCode.value + .replace(/=""<\/span>/gi, '') + .replace('', '') + .replace('', ''); -.directive('iframeCodeView', function() { - return { - restrict: 'E', - link: function(scope, element) { - var iFrame = element[0].firstElementChild; - if(iFrame && iFrame.src) { - var links = angular.element( - '

Full View \ - View Source

' - ); - element.append(links); - } + codeElement.append(highlightedCode.value).addClass('highlight'); + + } + }; } }; -}); +}]) +; diff --git a/docs/app/partials/demo.tmpl.html b/docs/app/partials/demo.tmpl.html index ff6bfe16a1d..df76f3902f4 100644 --- a/docs/app/partials/demo.tmpl.html +++ b/docs/app/partials/demo.tmpl.html @@ -1,41 +1,6 @@ -
-
- -
- - -
- {{demo.label}} - - - Source - -
-
- - - - - - - - - - - - -
-
-
- -
-
+ + + + diff --git a/docs/app/partials/docs-demo.tmpl.html b/docs/app/partials/docs-demo.tmpl.html new file mode 100644 index 00000000000..c332ee640fa --- /dev/null +++ b/docs/app/partials/docs-demo.tmpl.html @@ -0,0 +1,38 @@ +
+
+ +
+ +
+ + +
+ {{demoCtrl.demoTitle}} + + + Source + +
+
+ + + + + + + + + + + + + + +
+ +
+
diff --git a/docs/app/partials/layout-alignment.tmpl.html b/docs/app/partials/layout-alignment.tmpl.html index 9dc3360ed18..cb750634dce 100644 --- a/docs/app/partials/layout-alignment.tmpl.html +++ b/docs/app/partials/layout-alignment.tmpl.html @@ -1,29 +1,40 @@

- Child elements of a layout element can be aligned using the layout-align - attribute. In each demo, the center black line represents the "main axis", - which is the primary axis along which child element are laid out. For a row layout, - child elements will line up horizontally along the main axis. For a column layout, - child elements will line up vertically along the main axis. Alternatively, the "cross axis" - is the imaginary line perpendicular to the black main axis line. + When the layout-align attribute is given on a a layout element, its value + answers two questions: +

    +
  1. + How will children be aligned in the layout's main direction (horizontally in a row layout, vertically in a column layout)? +
  2. +
  3. + How will children be aligned perpindicular to the layout's direction (vertically in a row layout, horizontally in a column layout)? +
  4. +

- - -

Main Axis: Center

+ + +
+
center
+
center
+
+
+
+ + +
+
center
+
center
+
+
+

- The layout-align="center" attribute will center the cells across the main axis. - Note that each demo's center black line represents the "main axis". Additionally, by default - each item will "stretch" the cross axis, which is explained later. + layout-align="center" will center children across the layout direction.

-
-
-
center
-
center
-
+
-
+
center
center
@@ -36,13 +47,13 @@

Main Axis: Start

The layout-align="start" attribute will position the cell to the left for a a row layout, and at the top for a column layout. (Stretches the cross axis by default)

-
+
start
start
-
+
start
start
@@ -56,13 +67,13 @@

Main Axis: End

The layout-align="end" attribute will position the cell to the right for a a row layout, and at the bottom for a column layout. (Stretches the cross axis by default)

-
+
end
end
-
+
end
end
@@ -76,14 +87,14 @@

Main Axis: Space Around

The layout-align="space-around" attribute will evenly distribute the cells and the space around them. (Stretches the cross axis by default)

-
+
Uno
Dos
Tres
-
+
Uno
Dos
@@ -92,21 +103,20 @@

Main Axis: Space Around

-

Main Axis: Space Between

The layout-align="space-between" attribute will evenly distribute the cells and the free space between them, with the first cell is aligned at the start, and the last cell aligned at the end. (Stretches the cross axis by default)

-
+
Uno
Dos
Tres
-
+
Uno
Dos
@@ -124,13 +134,13 @@

Main Axis: Flex Cells

because there is no free space between the cells for the cells to be aligned to. Since each flex cell is using up all of the free space, there's no arranging that could happen.

-
+
Uno
Dos
-
+
Uno
Dos
@@ -155,13 +165,13 @@

Centered Horizontal And Vertical

Is it possible to center a layout's child cells by both the main and cross axes? Yes. Yes it is.

-
+
center center
center center
-
+
center center
center center
@@ -176,13 +186,13 @@

Main Axis Start, Cross Axis Center

and in the "center" of the cross axis. Note that each demo's center black line represents the "main axis", which makes the imaginary perpendicular line the "cross axis".

-
+
start center
start center
-
+
start center
start center
@@ -196,13 +206,13 @@

Main Axis End, Cross Axis Center

The layout-align="end center" attribute packs up all of the cells at the "end" of the main axis, and in the "center" of the cross axis.

-
+
end center
end center
-
+
end center
end center
@@ -216,13 +226,13 @@

Main Axis Center, Cross Axis Start

The layout-align="center start" attribute packs up all of the cells at the "center" of the main axis, and at the "start" of the cross axis.

-
+
center start
center start
-
+
center start
center start
@@ -236,13 +246,13 @@

Main Axis Start, Cross Axis Start

The layout-align="start start" attribute packs up all of the cells at the "start" of the main axis, and at the "start" of the cross axis.

-
+
start start
start start
-
+
start start
start start
@@ -256,13 +266,13 @@

Main Axis End, Cross Axis Start

The layout-align="end start" attribute packs up all of the cells at the "end" of the main axis, and at the "start" of the cross axis.

-
+
end start
end start
-
+
end start
end start
@@ -276,13 +286,13 @@

Main Axis Center, Cross Axis End

The layout-align="center end" attribute packs up all of the cells at the "center" of the main axis, and at the "end" of the cross axis.

-
+
center end
center end
-
+
center end
center end
@@ -296,13 +306,13 @@

Main Axis Start, Cross Axis End

The layout-align="start end" attribute packs up all of the cells at the "start" of the main axis, and at the "end" of the cross axis.

-
+
start end
start end
-
+
start end
start end
@@ -316,13 +326,13 @@

Main Axis End, Cross Axis End

The layout-align="end end" attribute packs up all of the cells at the "end" of the main axis, and at the "end" of the cross axis.

-
+
end end
end end
-
+
end end
end end
diff --git a/docs/app/partials/layout-container.tmpl.html b/docs/app/partials/layout-container.tmpl.html index 9f98b809bd1..85548e0fec0 100644 --- a/docs/app/partials/layout-container.tmpl.html +++ b/docs/app/partials/layout-container.tmpl.html @@ -2,82 +2,74 @@

Overview

- Angular Md uses a responsive CSS layout based on - flexbox, rather than - using CSS floats. Traditionally, floats proved to be the best solution for CSS - layouts, but with flexbox now available in a majority of browsers, - we're moving onto a new era with improved layout capabilities and features. + Angular Material's responsive CSS layout is based on + flexbox, rather than traditional + CSS floats. With flexbox now available in + major browsers, + flexbox is the best bet.

- The layout system uses element attributes, rather than CSS classes. - By doing so we're able to simplify creating layouts and make it easier to quickly generate - the structure required at various viewport sizes. The attribute system allows - assigning values following standard HTML conventions, which makes it easier to read and - understand compared to long strung together CSS classes. Additionally, the layout attributes - help to separate custom app styles from the core structure, which further simplifies code. + The layout system is based upon element attributes rather than CSS classes. + Attributes provide an easy way to set a value (eg `layout="row"`), and additionally + helps us separate concerns: attributes define layout, and classes define styling.

Layout Attribute

- Use the layout attribute on an element to arrange its children + Use the layout attribute on an element to align its children horizontally in a row (layout="row"), or vertically in - a column (layout="column"). The layout attribute's value - describes what the "main axis" is for its children. It uses words that adhere - to the flexbox specification. + a column (layout="column").

-
-
I'm left.
-
I'm right.
-
- -
-
I'm above.
-
I'm below.
-
+
+
I'm left.
+
I'm right.
+
+
+
I'm above.
+
I'm below.
+
- -

Responsive Layout

-

- From the ground up the layout system is built around being responsive to viewport size. - Out of the box it comes with useful, which can be easily reused. - The layout attribute used with "row" or "column" values define arrangement on all device sizes. - If you wish to define a layout depending upon the device size, there are - other layout attributes available: + See Layout Options for information on responsive layouts and other options.

-
    -
  • - layout sets the default layout on all devices. -
  • -
  • - layout-phone sets the layout on device <=600px wide. -
  • -
  • - layout-tablet sets the layout on devices >600px and <=960px wide. -
  • -
  • - layout-tablet-landscape sets the layout on devices >960 and <=1200px wide. -
  • -
  • - layout-pc sets the layout on devices >=1200px wide. -
  • -
+ + + +
+
+ Header +
- -
-
- I'm above on tiny devices, and to the left on devices wider than 600px. -
-
- I'm below on tiny devices, and to the right on devices wider than 600px. -
+
+ +
+ Main
flex +
+
+ +
+ Footer +
+
+ + +

+ In this layout, the header and footer are both using their normal height, while the main + content area is flexing, or stretching, to fill the remaining area. +
+ The app container is a vertical layout, while the main area is a responsive row/column + layout, depending upon the screen size. + The aside menu is above on mobile, and to the left on larger devices. +

-
diff --git a/docs/app/partials/layout-grid.tmpl.html b/docs/app/partials/layout-grid.tmpl.html index 78abb32bfbf..56b5058f758 100644 --- a/docs/app/partials/layout-grid.tmpl.html +++ b/docs/app/partials/layout-grid.tmpl.html @@ -1,111 +1,120 @@

- The grid system is different than most because of its use of the - CSS Flexible Box Layout Module standard. With flexbox - you have the power to simply add in the columns and rows required, and they'll evenly take up the - available space of their parent layout container. There's no restriction to a 12 column grid, or - having to explicitly state how large each column should be. + To customize the size and position of elements in a layout, use the + flex, offset, and flex-order attributes.

- -

Flex Attribute

-

- Child elements of a layout container with the flex - attribute will "flex", or stretch, to fill the available area within its parent layout container. - If a design requires three evenly spaced elements, simply add three elements with a - flex attribute. Elements without the flex attribute will take up their natural size, - whereas elements with the flex attribute will evenly fill in the available area. -

- - - - - -

Layout Padding

+ + +
+ + One
[flex] +
+ + Two
[flex] +
+ + Three
[flex] +
+
+
+

- This layout has padding, or gutters, between each cell by adding the - layout-padding attribute. The previous examples added in their own - margins/padding manually, whereas the layout-padding attribute spaces it all out - evenly. + Add the flex attribute to a layout's child element, and it + will flex (stretch) to fill the available area.

- - - - -

Layout Padding with Available Space Percents

-

- Flex attributes can be given integers to represent the percentage of the available space - it should take up. Note that elements which are not given a percentage still - fill up the available area. Adjust the window size to see - the demo's responsive layout attributes at work. -

+ + + +
+ + flex="33" + + + flex="40" + + + flex + +
+
+

- Note that flex attributes are only defined in increments of 5, with the exception of - 33 and 66. (ie. flex=5, flex=10, flex=15, ... flex=33, flex=35, ... flex=66, etc) - This avoids needlessly including extra css in the framework. If you need more - specificity than what is provided by our breakpoints, use stylesheets to set the - flex-basis: x%; max-width: x%; properties. + A layout child's flex attribute can be given an integer value from 0-100. + The element will stretch to the percentage of available space matching the value. +

+ The flex attribute value is restricted to 33, 66, and multiples + of five. +
+ For example: flex="5", flex="20", "flex="33", flex="50", flex="66", flex="75", ....

- - - - - - - -

Layout Padding with Offsets

- Elements can be offset from the left, but still allow the gutters to line up correctly. - Adjust the window size to see the demo's responsive layout attributes at work. + See the layout options page for more information on responsive flex attributes.

- - - - -

Layout Order

+ + +
+ + flex
offset="10" +
+ + flex
offset="33" +
+ + flex + +
+
+

- Child elements of a layout container can have their order changed through the use of the - layout-order attribute, and respective responsive - attributes such as: layout-order-sm, layout-order-md, and layout-order-lg. Reordering elements - is useful when the placement of a cell should be changed depending on the viewport size. + Add the offset attribute with a value from 0-100 to + make a layout child be offset by the given percent. The offset + attribute has the same restrictions as the flex attribute: It is defined only at 33, 66, and multiples of five.

- In the demo, notice how the default size (the smallest) has each of the elements in their - natural order determined by its markup. However, as the viewport changes size then each - individual cell can change their order using the layout-order attribute. + See the layout options page for more information on responsive offset attributes.

- - - - - -

Header, Menu, Main, Footer, no padding

-

- This layout lets each of the header and footer tracks height be the size of their - respective content, and the middle track (menu and main) flex vertically to fill the - space of the entire layout. This is also an example of nested layouts, where the entire - body is a vertical layout (header/content/footer), and the content row is its own layout - (menu/main), and each layout has their own settings. -

+ + +
+ + One + + + Two + + + Three + +
+
+

- The body element has the layout="column" attribute. - By default the middle track has the menu and main elements stacked vertically. However, - the elements line up horizontally starting at the "small" size, which is determined by the - media query. + Add the flex-order attribute to a layout child to set its + position within the layout.

- - - -
+ diff --git a/docs/app/partials/layout-options.tmpl.html b/docs/app/partials/layout-options.tmpl.html index 739f935c4ea..2119fc9539e 100644 --- a/docs/app/partials/layout-options.tmpl.html +++ b/docs/app/partials/layout-options.tmpl.html @@ -1,13 +1,23 @@
- -

Responsive Layout

+ + +
+
+ I'm above on mobile, and to the left on larger devices. +
+
+ I'm below on mobile, and to the right on larger devices. +
+
+
+

- From the ground up the layout system is built around being responsive to viewport size. - Out of the box it comes with useful and customizable breakpoints, which can be easily reused. - The layout attribute used with "row" or "column" values define arrangement on all device sizes. - If you wish to define a layout depending upon the device size, there are + See the Layout Container page for a basic explanation + of layout attributes. +
+ To make your layout change depending upon the device size, there are other layout attributes available:

@@ -16,93 +26,196 @@

Responsive Layout

layout sets the default layout on all devices.
  • - layout-phone sets the layout on device <600px wide. + layout-sm sets the layout on devices less than 600px wide (phones). +
  • +
  • + layout-gt-sm sets the layout on devices greater than 600px wide (bigger than phones).
  • - layout-tablet sets the layout on devices >=600px and <960px wide. + layout-md sets the layout on devices between 600px and 960px wide (tablets in portrait).
  • - layout-tablet-landscape sets the layout on devices >=960px and <1200px wide. + layout-gt-md sets the layout on devices greater than 960px wide (bigger than tablets in portrait).
  • - layout-pc sets the layout on devices >=1200px wide. + layout-lg sets the layout on devices between 960 and 1200px wide (tablets in landscape). +
  • +
  • + layout-gt-lg sets the layout on devices greater than 1200px wide (computers and large screens).
  • +
    -

    + -

    Layout Options

    + + +
    +
    I'm on the left, and there's an empty area around me.
    +
    I'm on the right, and there's an empty area around me.
    +
    +
    +

    - layout-padding adds padding between this layout's children with - the flex attribute. + layout-margin adds a margin around each flex child. It also adds a margin to the layout container itself. +
    + layout-fill forces the layout element to fill its parent container.

    - -
    -
    I'm on the left, and there's an empty area between.
    -
    I'm on the right, and there's an empty area between.
    -
    -
    +
    + + + + +
    +
    + I flex to one-third of the space on mobile, and two-thirds on other devices. +
    +
    + I flex to two-thirds of the space on mobile, and one-third on other devices. +
    +
    +
    +

    - layout-fill forces the layout element to fill its parent container. + See the Layout Grid page for a basic explanation + of flex and offset attributes.

    - -
    - This layout fills up 100% of its parent's width and height. -
    -
    -

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    flexSets flex.
    flex-smSets flex on devices less than 600px wide.
    flex-gt-smSets flex on devices greater than 600px wide.
    flex-mdSets flex on devices between 600px and 960px wide..
    flex-gt-mdSets flex on devices greater than 960px wide. +
    flex-lgSets flex on devices between 960px and 1200px.
    flex-gt-lgSets flex on devices greater than 1200px wide.
    offsetSets offset.
    offset-smSets offset on devices less than 600px wide.
    offset-gt-smSets offset on devices greater than 600px wide.
    offset-mdSets offset on devices between 600px and 960px wide..
    offset-gt-mdSets offset on devices greater than 960px wide. +
    offset-lgSets offset on devices between 960px and 1200px.
    offset-gt-lgSets offset on devices greater than 1200px wide.
    -

    Utility Attributes

    - + + +
    + + I'm hidden on mobile and shown on larger devices. + + + I'm shown on mobile and hidden on larger devices. + +
    +
    +
    +
    - - + + - - + + - - + + - - + + + + + + + + + - + + + + + - - + + - - + + - - + + - - + + + + + +
    hide display: none
    hide-phonedisplay: none when the phone media query is active.hide-smdisplay: none on devices less than 600px wide.
    hide-tabletdisplay: none when the tablet media query is active.hide-gt-smdisplay: none on devices greater than 600px wide.
    hide-tablet-landscapedisplay: none when the tablet-landscape media query is active.hide-mddisplay: none on devices between 600px and 960px wide..
    hide-pcdisplay: none when the pc media query is active.hide-gt-mddisplay: none on devices greater than 960px wide. +
    hide-lgdisplay: none on devices between 960px and 1200px.
    hide-gt-lgdisplay: none on devices greater than 1200px wide.
    shownegates hide operatorNegates hide.
    show-smNegates hide on devices less than 600px wide.
    show-phonenegates hide operator when the phone media query is active.show-gt-smNegates hide on devices greater than 600px wide.
    show-tabletnegates hide operator when the tablet media query is active.show-mdNegates hide on devices between 600px and 960px wide..
    show-tablet-landscapenegates hide operator when the tablet-landscape media query is active.show-gt-mdNegates hide on devices greater than 960px wide.
    show-pcnegates hide operator when the pc media query is active.show-lgNegates hide on devices between 960px and 1200px.
    show-gt-lgNegates hide on devices greater than 1200px wide.
    -
    diff --git a/docs/config/processors/content.js b/docs/config/processors/content.js index b6a610073ab..7a8e6c30416 100644 --- a/docs/config/processors/content.js +++ b/docs/config/processors/content.js @@ -30,4 +30,4 @@ module.exports = function contentProcessor(templateFinder) { }); } }; -}; \ No newline at end of file +}; diff --git a/docs/config/template/index.template.html b/docs/config/template/index.template.html index 517b37cfe5d..71388dabba1 100644 --- a/docs/config/template/index.template.html +++ b/docs/config/template/index.template.html @@ -53,16 +53,16 @@

    - -

    +

    {{menu.currentSection.name}}

    - +

    @@ -86,10 +86,10 @@

    - View on Github - Source + View on Github + Source - + Improve This Doc diff --git a/src/components/bottomSheet/demoBasicUsage/index.html b/src/components/bottomSheet/demoBasicUsage/index.html index 5e9f7f994ab..9762d031896 100644 --- a/src/components/bottomSheet/demoBasicUsage/index.html +++ b/src/components/bottomSheet/demoBasicUsage/index.html @@ -2,7 +2,7 @@

    Bottom sheet can be dismissed with the service or a swipe down.

    -
    +
    Show as List @@ -13,7 +13,7 @@

    - + {{alert}}
    diff --git a/src/components/button/demoBasicUsage/index.html b/src/components/button/demoBasicUsage/index.html index 9ebb584ccc6..a3ceecf54d5 100644 --- a/src/components/button/demoBasicUsage/index.html +++ b/src/components/button/demoBasicUsage/index.html @@ -2,14 +2,14 @@
    -
    +
    {{title1}} Primary (md-noink) Disabled {{title4}}
    -
    +
    Button Primary Disabled @@ -17,7 +17,7 @@
    raised
    -
    +
    @@ -36,12 +36,12 @@
    FAB
    -
    +
    Go to Google RSVP
    -
    +
    Button Button Button diff --git a/src/components/dialog/demoBasicUsage/index.html b/src/components/dialog/demoBasicUsage/index.html index 9e597a4111d..9f632e5642c 100644 --- a/src/components/dialog/demoBasicUsage/index.html +++ b/src/components/dialog/demoBasicUsage/index.html @@ -1,4 +1,4 @@ -
    +

    Open a dialog over the app's content. Press escape or click outside to close the dialog.

    @@ -18,7 +18,7 @@

    - + {{alert}}
    diff --git a/src/components/progressCircular/demoBasicUsage/index.html b/src/components/progressCircular/demoBasicUsage/index.html index 44a55308747..8bbd52e7316 100644 --- a/src/components/progressCircular/demoBasicUsage/index.html +++ b/src/components/progressCircular/demoBasicUsage/index.html @@ -1,8 +1,8 @@ -
    +

    Determinate

    For operations where the percentage of the operation completed can be determined, use a determinate indicator. They give users a quick sense of how long an operation will take.

    -
    +
    @@ -14,7 +14,7 @@

    Indeterminate

    Theming

    -
    +
    diff --git a/src/components/progressLinear/demoBasicUsage/index.html b/src/components/progressLinear/demoBasicUsage/index.html index 6adab47344a..aa53e323a5c 100644 --- a/src/components/progressLinear/demoBasicUsage/index.html +++ b/src/components/progressLinear/demoBasicUsage/index.html @@ -1,4 +1,4 @@ -
    +

    Determinate

    For operations where the percentage of the operation completed can be determined, use a determinate indicator. They give users a quick sense of how long an operation will take.

    diff --git a/src/components/sidenav/demoBasicUsage/index.html b/src/components/sidenav/demoBasicUsage/index.html index 4b3356b931e..97368222402 100644 --- a/src/components/sidenav/demoBasicUsage/index.html +++ b/src/components/sidenav/demoBasicUsage/index.html @@ -9,10 +9,10 @@

    Sidenav Left

    - + Close Sidenav Left -

    +

    This sidenav is locked open on your device. To go back to the default behavior, narrow your display.

    diff --git a/src/components/tabs/demoDynamicTabs/index.html b/src/components/tabs/demoDynamicTabs/index.html index 157e7785c35..b89cd398324 100644 --- a/src/components/tabs/demoDynamicTabs/index.html +++ b/src/components/tabs/demoDynamicTabs/index.html @@ -17,11 +17,11 @@
    -
    +
    -
    +
    Add a new Tab: diff --git a/src/components/tabs/demoStaticTabs/index.html b/src/components/tabs/demoStaticTabs/index.html index a64aa5dc679..b19d2b0fba6 100644 --- a/src/components/tabs/demoStaticTabs/index.html +++ b/src/components/tabs/demoStaticTabs/index.html @@ -43,7 +43,7 @@
    -
    +
    diff --git a/src/components/toast/demoBasicUsage/index.html b/src/components/toast/demoBasicUsage/index.html index d28ede55389..d4cc1524227 100644 --- a/src/components/toast/demoBasicUsage/index.html +++ b/src/components/toast/demoBasicUsage/index.html @@ -1,7 +1,7 @@

    Toast can be dismissed with a swipe, a timer, or a button.

    -
    +
    Show Custom diff --git a/src/core/style/layout.scss b/src/core/style/layout.scss index 920a9b05f30..7af2089086d 100644 --- a/src/core/style/layout.scss +++ b/src/core/style/layout.scss @@ -22,14 +22,16 @@ flex-direction: row; } -[layout-padding], -[layout][layout-padding] > [flex] { - padding: $layout-gutter-width / 2; +[layout-margin], /* DEPRECATED */ +[layout-margin] > [flex], /* DEPRECATED */ +[layout-margin], +[layout-margin] > [flex] { + margin: $layout-gutter-width / 2; } -[layout-padding] + [layout-padding] { +[layout-margin] + [layout-margin], /* DEPRECATED */ +[layout-margin] + [layout-margin] { margin-top: -($layout-gutter-width / 2); - padding-top: 0; } [layout-wrap] { @@ -43,7 +45,7 @@ } -@mixin layout-for-size($name) { +@mixin layout-for-name($name) { [hide]:not([show-#{$name}]), [hide-#{$name}]:not([show-#{$name}]) { display: none; @@ -61,7 +63,7 @@ } } -@mixin flex-properties-for-size($name: null) { +@mixin flex-properties-for-name($name: null) { $flexName: 'flex'; $offsetName: 'offset'; @if $name != null { @@ -106,38 +108,49 @@ flex: 1; } -@include flex-properties-for-size(); +@include flex-properties-for-name(); + @media (max-width: $layout-breakpoint-sm) { - @include layout-for-size(phone); - @include flex-properties-for-size(phone); + @include layout-for-name(sm); + @include flex-properties-for-name(sm); +} +@media (min-width: $layout-breakpoint-sm) { + @include layout-for-name(gt-sm); + @include flex-properties-for-name(gt-sm); } -@media (min-width: $layout-breakpoint-sm + 1) and (max-width: $layout-breakpoint-md) { - @include layout-for-size(tablet); - @include flex-properties-for-size(tablet); + +@media (min-width: $layout-breakpoint-sm) and (max-width: $layout-breakpoint-md) { + @include layout-for-name(md); + @include flex-properties-for-name(md); } -@media (min-width: $layout-breakpoint-md + 1) and (max-width: $layout-breakpoint-lg) { - @include layout-for-size(tablet-landscape); - @include flex-properties-for-size(tablet-landscape); +@media (min-width: $layout-breakpoint-md) { + @include layout-for-name(gt-md); + @include flex-properties-for-name(gt-md); +} + +@media (min-width: $layout-breakpoint-md) and (max-width: $layout-breakpoint-lg) { + @include layout-for-name(lg); + @include flex-properties-for-name(lg); } -@media (min-width: $layout-breakpoint-lg + 1) { - @include layout-for-size(pc); - @include flex-properties-for-size(pc); +@media (min-width: $layout-breakpoint-lg) { + @include layout-for-name(gt-lg); + @include flex-properties-for-name(gt-lg); } // Order attributes for layout children // ------------------------------ -[layout-order="0"] { order: 0; } -[layout-order="1"] { order: 1; } -[layout-order="2"] { order: 2; } -[layout-order="3"] { order: 3; } -[layout-order="4"] { order: 4; } -[layout-order="5"] { order: 5; } -[layout-order="6"] { order: 6; } -[layout-order="7"] { order: 7; } -[layout-order="8"] { order: 8; } -[layout-order="9"] { order: 9; } +[flex-order="0"] { order: 0; } +[flex-order="1"] { order: 1; } +[flex-order="2"] { order: 2; } +[flex-order="3"] { order: 3; } +[flex-order="4"] { order: 4; } +[flex-order="5"] { order: 5; } +[flex-order="6"] { order: 6; } +[flex-order="7"] { order: 7; } +[flex-order="8"] { order: 8; } +[flex-order="9"] { order: 9; } // Alignment attributes for layout containers' children