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

Commit d24cf25

Browse files
fix(layouts): support layout-align start and stretch
fixes #5509. fixes #5249.
1 parent 5e5e6cd commit d24cf25

File tree

3 files changed

+54
-12
lines changed

3 files changed

+54
-12
lines changed

docs/app/partials/layout-alignment.tmpl.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
<md-radio-button value="end">end</md-radio-button>
7575
<md-radio-button value="space-around">space-around</md-radio-button>
7676
<md-radio-button value="space-between">space-between</md-radio-button>
77+
<md-radio-button value="stretch">stretch</md-radio-button>
7778
</md-radio-group>
7879
</div>
7980
<div>
@@ -82,6 +83,7 @@
8283
<md-radio-button value="start">start</md-radio-button>
8384
<md-radio-button value="center">center</md-radio-button>
8485
<md-radio-button value="end">end</md-radio-button>
86+
<md-radio-button value="stretch">stretch</md-radio-button>
8587
</md-radio-group>
8688
</div>
8789

src/core/services/layout/layout.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,8 @@
88

99
var FLEX_OPTIONS = ['grow', 'initial', 'auto', 'none'];
1010
var LAYOUT_OPTIONS = ['row', 'column'];
11-
var ALIGNMENT_OPTIONS = [
12-
"start start", "start center", "start end",
13-
"center", "center center", "center start", "center end",
14-
"end", "end center", "end start", "end end",
15-
"space-around", "space-around center", "space-around start", "space-around end",
16-
"space-between", "space-between center", "space-between start", "space-between end"
17-
];
11+
var ALIGNMENT_MAIN_AXIS= [ "", "start", "center", "end", "stretch", "space-around", "space-between" ];
12+
var ALIGNMENT_CROSS_AXIS= [ "", "start", "center", "end", "stretch" ];
1813

1914

2015
var config = {
@@ -373,9 +368,14 @@
373368
break;
374369

375370
case 'layout-align' :
376-
if (!findIn(value, ALIGNMENT_OPTIONS, "-")) {
377-
value = ALIGNMENT_OPTIONS[0]; // 'start-start';
378-
}
371+
var axis = value.split(" ");
372+
var main = axis.length ? axis[0] : "stretch";
373+
var cross = axis.length > 1 ? axis[1] : "stretch";
374+
375+
if ( ALIGNMENT_MAIN_AXIS.indexOf(main) < 0 ) main = "stretch";
376+
if ( ALIGNMENT_CROSS_AXIS.indexOf(cross) < 0 ) cross = "stretch";
377+
378+
value = main + " " + cross;
379379
break;
380380

381381
case 'layout-padding' :

src/core/services/layout/layout.scss

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,24 +181,50 @@
181181
$name: 'layout-align-#{$suffix}';
182182
}
183183

184+
.#{$name},
185+
.#{$name}-stretch-stretch // defaults
186+
{
187+
justify-content : stretch;
188+
align-content : stretch;
189+
align-items: stretch;
190+
}
191+
192+
// Main Axis Center
193+
.#{$name}-start,
194+
.#{$name}-start-start,
195+
.#{$name}-start-center,
196+
.#{$name}-start-end
197+
{
198+
justify-content: start;
199+
}
200+
184201
// Main Axis Center
185202
.#{$name}-center, //stretch
186-
.#{$name}-center-center,
187203
.#{$name}-center-start,
204+
.#{$name}-center-center,
188205
.#{$name}-center-end
189206
{
190207
justify-content: center;
191208
}
192209

193210
// Main Axis End
194211
.#{$name}-end, //stretch
195-
.#{$name}-end-center,
196212
.#{$name}-end-start,
213+
.#{$name}-end-center,
197214
.#{$name}-end-end
198215
{
199216
justify-content: flex-end;
200217
}
201218

219+
// Main Axis Center
220+
.#{$name}-stretch,
221+
.#{$name}-stretch-center,
222+
.#{$name}-stretch-start,
223+
.#{$name}-stretch-end
224+
{
225+
justify-content: stretch;
226+
}
227+
202228
// Main Axis Space Around
203229
.#{$name}-space-around, //stretch
204230
.#{$name}-space-around-center,
@@ -231,6 +257,7 @@
231257
.#{$name}-space-around-start
232258
{
233259
align-items: flex-start;
260+
align-content: flex-start;
234261
}
235262

236263
// Cross Axis Center
@@ -241,6 +268,7 @@
241268
.#{$name}-space-around-center
242269
{
243270
align-items: center;
271+
align-content: center;
244272
max-width: 100%;
245273
}
246274

@@ -263,6 +291,18 @@
263291
.#{$name}-space-around-end
264292
{
265293
align-items: flex-end;
294+
align-content: flex-end;
295+
}
296+
297+
// Cross Axis Start
298+
.#{$name}-center-stretch,
299+
.#{$name}-start-stretch,
300+
.#{$name}-end-stretch,
301+
.#{$name}-space-between-stretch,
302+
.#{$name}-space-around-stretch
303+
{
304+
align-items: stretch;
305+
align-content: stretch;
266306
}
267307
}
268308

0 commit comments

Comments
 (0)