Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(layouts): support layout-align start and stretch
Browse files Browse the repository at this point in the history
fixes #5509. fixes #5249.
  • Loading branch information
ThomasBurleson committed Nov 25, 2015
1 parent 5e5e6cd commit d24cf25
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 12 deletions.
2 changes: 2 additions & 0 deletions docs/app/partials/layout-alignment.tmpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<md-radio-button value="end">end</md-radio-button>
<md-radio-button value="space-around">space-around</md-radio-button>
<md-radio-button value="space-between">space-between</md-radio-button>
<md-radio-button value="stretch">stretch</md-radio-button>
</md-radio-group>
</div>
<div>
Expand All @@ -82,6 +83,7 @@
<md-radio-button value="start">start</md-radio-button>
<md-radio-button value="center">center</md-radio-button>
<md-radio-button value="end">end</md-radio-button>
<md-radio-button value="stretch">stretch</md-radio-button>
</md-radio-group>
</div>

Expand Down
20 changes: 10 additions & 10 deletions src/core/services/layout/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@

var FLEX_OPTIONS = ['grow', 'initial', 'auto', 'none'];
var LAYOUT_OPTIONS = ['row', 'column'];
var ALIGNMENT_OPTIONS = [
"start start", "start center", "start end",
"center", "center center", "center start", "center end",
"end", "end center", "end start", "end end",
"space-around", "space-around center", "space-around start", "space-around end",
"space-between", "space-between center", "space-between start", "space-between end"
];
var ALIGNMENT_MAIN_AXIS= [ "", "start", "center", "end", "stretch", "space-around", "space-between" ];
var ALIGNMENT_CROSS_AXIS= [ "", "start", "center", "end", "stretch" ];


var config = {
Expand Down Expand Up @@ -373,9 +368,14 @@
break;

case 'layout-align' :
if (!findIn(value, ALIGNMENT_OPTIONS, "-")) {
value = ALIGNMENT_OPTIONS[0]; // 'start-start';
}
var axis = value.split(" ");
var main = axis.length ? axis[0] : "stretch";
var cross = axis.length > 1 ? axis[1] : "stretch";

if ( ALIGNMENT_MAIN_AXIS.indexOf(main) < 0 ) main = "stretch";
if ( ALIGNMENT_CROSS_AXIS.indexOf(cross) < 0 ) cross = "stretch";

value = main + " " + cross;
break;

case 'layout-padding' :
Expand Down
44 changes: 42 additions & 2 deletions src/core/services/layout/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -181,24 +181,50 @@
$name: 'layout-align-#{$suffix}';
}

.#{$name},
.#{$name}-stretch-stretch // defaults
{
justify-content : stretch;
align-content : stretch;
align-items: stretch;
}

// Main Axis Center
.#{$name}-start,
.#{$name}-start-start,
.#{$name}-start-center,
.#{$name}-start-end
{
justify-content: start;
}

// Main Axis Center
.#{$name}-center, //stretch
.#{$name}-center-center,
.#{$name}-center-start,
.#{$name}-center-center,
.#{$name}-center-end
{
justify-content: center;
}

// Main Axis End
.#{$name}-end, //stretch
.#{$name}-end-center,
.#{$name}-end-start,
.#{$name}-end-center,
.#{$name}-end-end
{
justify-content: flex-end;
}

// Main Axis Center
.#{$name}-stretch,
.#{$name}-stretch-center,
.#{$name}-stretch-start,
.#{$name}-stretch-end
{
justify-content: stretch;
}

// Main Axis Space Around
.#{$name}-space-around, //stretch
.#{$name}-space-around-center,
Expand Down Expand Up @@ -231,6 +257,7 @@
.#{$name}-space-around-start
{
align-items: flex-start;
align-content: flex-start;
}

// Cross Axis Center
Expand All @@ -241,6 +268,7 @@
.#{$name}-space-around-center
{
align-items: center;
align-content: center;
max-width: 100%;
}

Expand All @@ -263,6 +291,18 @@
.#{$name}-space-around-end
{
align-items: flex-end;
align-content: flex-end;
}

// Cross Axis Start
.#{$name}-center-stretch,
.#{$name}-start-stretch,
.#{$name}-end-stretch,
.#{$name}-space-between-stretch,
.#{$name}-space-around-stretch
{
align-items: stretch;
align-content: stretch;
}
}

Expand Down

0 comments on commit d24cf25

Please sign in to comment.