Skip to content

Commit

Permalink
feat: Space support align stretch (ant-design#36310)
Browse files Browse the repository at this point in the history
* feat/Space-component-support-align-stretch: support align to stretch

Signed-off-by: Chang Wei <changwei1006@gmail.com>

* feat/Space-component-support-align-stretch: update document of zh-CN and en-US

Signed-off-by: Chang Wei <changwei1006@gmail.com>

* feat/Space-component-support-align-stretch: update demo

Signed-off-by: Chang Wei <changwei1006@gmail.com>

* feat/Space-component-support-align-stretch: update snapshot by command `npm test -- components/space -u`

Signed-off-by: Chang Wei <changwei1006@gmail.com>
  • Loading branch information
cw1997 committed Jul 5, 2022
1 parent e7bc2e2 commit bfa8aae
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 3 deletions.
36 changes: 36 additions & 0 deletions components/space/__tests__/__snapshots__/demo-extend.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,42 @@ exports[`renders ./components/space/demo/align.md extend context correctly 1`] =
</div>
</div>
</div>
<div
class="space-align-block"
>
<div
class="ant-space ant-space-horizontal ant-space-align-stretch"
>
<div
class="ant-space-item"
style="margin-right:8px"
>
stretch
</div>
<div
class="ant-space-item"
style="margin-right:8px"
>
<button
class="ant-btn ant-btn-primary"
type="button"
>
<span>
Primary
</span>
</button>
</div>
<div
class="ant-space-item"
>
<span
class="mock-block"
>
Block
</span>
</div>
</div>
</div>
</div>
`;

Expand Down
36 changes: 36 additions & 0 deletions components/space/__tests__/__snapshots__/demo.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,42 @@ exports[`renders ./components/space/demo/align.md correctly 1`] = `
</div>
</div>
</div>
<div
class="space-align-block"
>
<div
class="ant-space ant-space-horizontal ant-space-align-stretch"
>
<div
class="ant-space-item"
style="margin-right:8px"
>
stretch
</div>
<div
class="ant-space-item"
style="margin-right:8px"
>
<button
class="ant-btn ant-btn-primary"
type="button"
>
<span>
Primary
</span>
</button>
</div>
<div
class="ant-space-item"
>
<span
class="mock-block"
>
Block
</span>
</div>
</div>
</div>
</div>
`;

Expand Down
7 changes: 7 additions & 0 deletions components/space/demo/align.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ const App: React.FC = () => (
<span className="mock-block">Block</span>
</Space>
</div>
<div className="space-align-block">
<Space align="stretch">
stretch
<Button type="primary">Primary</Button>
<span className="mock-block">Block</span>
</Space>
</div>
</div>
);

Expand Down
2 changes: 1 addition & 1 deletion components/space/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Avoid components clinging together and set a unified space.

| Property | Description | Type | Default | Version |
| --- | --- | --- | --- | --- |
| align | Align items | `start` \| `end` \|`center` \|`baseline` | - | 4.2.0 |
| align | Align items | `start` \| `end` \|`center` \|`baseline` \|`stretch` | - | 4.2.0 |
| direction | The space direction | `vertical` \| `horizontal` | `horizontal` | 4.1.0 |
| size | The space size | [Size](#Size) \| [Size\[\]](#Size) | `small` | 4.1.0 \| Array: 4.9.0 |
| split | Set split | ReactNode | - | 4.7.0 |
Expand Down
2 changes: 1 addition & 1 deletion components/space/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface SpaceProps extends React.HTMLAttributes<HTMLDivElement> {
size?: SpaceSize | [SpaceSize, SpaceSize];
direction?: 'horizontal' | 'vertical';
// No `stretch` since many components do not support that.
align?: 'start' | 'end' | 'center' | 'baseline';
align?: 'start' | 'end' | 'center' | 'baseline' | 'stretch';
split?: React.ReactNode;
wrap?: boolean;
}
Expand Down
2 changes: 1 addition & 1 deletion components/space/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ cover: https://gw.alipayobjects.com/zos/antfincdn/wc6%263gJ0Y8/Space.svg

| 参数 | 说明 | 类型 | 默认值 | 版本 |
| --- | --- | --- | --- | --- |
| align | 对齐方式 | `start` \| `end` \|`center` \|`baseline` | - | 4.2.0 |
| align | 对齐方式 | `start` \| `end` \|`center` \|`baseline` \|`stretch` | - | 4.2.0 |
| direction | 间距方向 | `vertical` \| `horizontal` | `horizontal` | 4.1.0 |
| size | 间距大小 | [Size](#Size) \| [Size\[\]](#Size) | `small` | 4.1.0 \| Array: 4.9.0 |
| split | 设置拆分 | ReactNode | - | 4.7.0 |
Expand Down
4 changes: 4 additions & 0 deletions components/space/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
&-baseline {
align-items: baseline;
}

&-stretch {
align-items: stretch;
}
}
}

Expand Down

0 comments on commit bfa8aae

Please sign in to comment.