Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pages/space-between/alignment.permutations.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const permutations = createPermutations<Pick<SpaceBetweenProps, 'direction' | 'a
{
children: [ExampleChildren, NestedExample],
direction: ['vertical', 'horizontal'],
alignItems: [undefined, 'center', 'start', 'end'],
alignItems: [undefined, 'center', 'start', 'end', 'stretch'],
},
]);

Expand Down
2 changes: 2 additions & 0 deletions pages/space-between/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@

.border-box-outer,
.box {
block-size: 100%;
border-block: 1px solid tokens.$color-border-status-info;
border-inline: 1px solid tokens.$color-border-status-info;
}

.border-box-inner {
block-size: 100%;
border-block: 1px solid tokens.$color-border-status-error;
border-inline: 1px solid tokens.$color-border-status-error;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26931,6 +26931,7 @@ exports[`Components definition for space-between matches the snapshot: space-bet
"center",
"end",
"start",
"stretch",
],
},
"name": "alignItems",
Expand Down
23 changes: 23 additions & 0 deletions src/space-between/__tests__/space-between.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,29 @@ describe('SpaceBetween', () => {
expect(content[0].getElement()).toHaveAttribute('id', 'button-one');
expect(content[1].getElement()).toHaveAttribute('id', 'button-two');
});

it.each(['center', 'start', 'end', 'stretch'] as const)('applies align-%s class', alignItems => {
const { container } = render(
<SpaceBetween size="s" alignItems={alignItems}>
<button />
<button />
</SpaceBetween>
);
expect(container.firstChild).toHaveClass(styles[`align-${alignItems}`]);
});

it('does not apply an alignment class when alignItems is undefined', () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we don't define the alignItems props, it basically falls back to "stretched" (browser default). Should we explicitly set it to "stretch" instead of relying on the implicit browser defaults?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand. The default value for align-items is normal, not stretch.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, which in our case behaves like stretch (https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/align-items#values). Except that I missed

behaves like start on replaced absolutely-positioned boxes

which would change the behavior on rare cases were SpaceBetween has a absolutely-positioned replaced element (e.g., img, canvas, input?) as a direct child. So I think we are good, keeping it as is to ensure we don't break some niche cases.

const { container } = render(
<SpaceBetween size="s">
<button />
<button />
</SpaceBetween>
);
expect(container.firstChild).not.toHaveClass(styles['align-center']);
expect(container.firstChild).not.toHaveClass(styles['align-start']);
expect(container.firstChild).not.toHaveClass(styles['align-end']);
expect(container.firstChild).not.toHaveClass(styles['align-stretch']);
});
});

describe('native attributes', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/space-between/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ export namespace SpaceBetweenProps {

export type Size = 'xxxs' | 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl';

export type AlignItems = 'center' | 'start' | 'end';
export type AlignItems = 'center' | 'start' | 'end' | 'stretch';
}
4 changes: 4 additions & 0 deletions src/space-between/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,7 @@ $sizes-vertical: (
.align-end {
align-items: end;
}

.align-stretch {
align-items: stretch;
}
Loading