Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit 5e3ec0e

Browse files
aleixsuauCaerusKaru
authored andcommitted
fix(fxLayoutAlign): add space-between and space-around options (#845)
The actual implementation doesn't allow the 'space-between' and 'space-around' flex align-content options in the cross-axis. fxLayoutAlign should cover all of them. Closes #841
1 parent 2c11fd7 commit 5e3ec0e

File tree

2 files changed

+39
-11
lines changed

2 files changed

+39
-11
lines changed

src/lib/flex/layout-align/layout-align.spec.ts

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,6 @@ describe('layout-align directive', () => {
154154
styler
155155
);
156156
});
157-
it('should add correct styles for `fxLayoutAlign="start baseline"` usage', () => {
158-
createTestComponent(`<div fxLayoutAlign='start baseline'></div>`);
159-
expectNativeEl(fixture)
160-
.toHaveStyle({
161-
'justify-content': 'flex-start',
162-
'align-items': 'baseline'
163-
}, styler);
164-
});
165157
it('should add correct styles for `fxLayoutAlign="start center"` usage', () => {
166158
createTestComponent(`<div fxLayoutAlign='start center'></div>`);
167159
expectNativeEl(fixture).toHaveStyle(
@@ -180,6 +172,33 @@ describe('layout-align directive', () => {
180172
}), styler
181173
);
182174
});
175+
it('should add correct styles for `fxLayoutAlign="start space-between"` usage', () => {
176+
createTestComponent(`<div fxLayoutAlign='start space-between'></div>`);
177+
expectNativeEl(fixture).toHaveStyle(
178+
extendObject(MAINAXIS_DEFAULTS, {
179+
'align-items': 'stretch',
180+
'align-content': 'space-between'
181+
}), styler
182+
);
183+
});
184+
it('should add correct styles for `fxLayoutAlign="start space-around"` usage', () => {
185+
createTestComponent(`<div fxLayoutAlign='start space-around'></div>`);
186+
expectNativeEl(fixture).toHaveStyle(
187+
extendObject(MAINAXIS_DEFAULTS, {
188+
'align-items': 'stretch',
189+
'align-content': 'space-around'
190+
}), styler
191+
);
192+
});
193+
it('should add correct styles for `fxLayoutAlign="start baseline"` usage', () => {
194+
createTestComponent(`<div fxLayoutAlign='start baseline'></div>`);
195+
expectNativeEl(fixture)
196+
.toHaveStyle({
197+
'justify-content': 'flex-start',
198+
'align-items': 'baseline',
199+
'align-content': 'stretch'
200+
}, styler);
201+
});
183202
it('should add ignore invalid cross-axis values', () => {
184203
createTestComponent(`<div fxLayoutAlign='start invalid'></div>`);
185204
expectNativeEl(fixture).toHaveStyle(

src/lib/flex/layout-align/layout-align.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,16 +171,25 @@ export class LayoutAlignDirective extends BaseDirective implements OnInit, OnCha
171171
case 'flex-start':
172172
css['align-items'] = css['align-content'] = 'flex-start';
173173
break;
174-
case 'baseline':
175-
css['align-items'] = 'baseline';
176-
break;
177174
case 'center':
178175
css['align-items'] = css['align-content'] = 'center';
179176
break;
180177
case 'end':
181178
case 'flex-end':
182179
css['align-items'] = css['align-content'] = 'flex-end';
183180
break;
181+
case 'space-between':
182+
css['align-content'] = 'space-between';
183+
css['align-items'] = 'stretch';
184+
break;
185+
case 'space-around':
186+
css['align-content'] = 'space-around';
187+
css['align-items'] = 'stretch';
188+
break;
189+
case 'baseline':
190+
css['align-content'] = 'stretch';
191+
css['align-items'] = 'baseline';
192+
break;
184193
case 'stretch':
185194
default : // 'stretch'
186195
css['align-items'] = css['align-content'] = 'stretch'; // default cross axis

0 commit comments

Comments
 (0)