Skip to content

Commit d5348f0

Browse files
committed
feat(row): add support for space-evenly
1 parent e4f678f commit d5348f0

File tree

8 files changed

+77
-52
lines changed

8 files changed

+77
-52
lines changed

components/grid/Col.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export default defineComponent({
141141
});
142142
return () => {
143143
return (
144-
<div class={classes.value} style={mergedStyle.value}>
144+
<div role="cell" class={classes.value} style={mergedStyle.value}>
145145
{slots.default?.()}
146146
</div>
147147
);

components/grid/Row.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ import useFlexGapSupport from '../_util/hooks/useFlexGapSupport';
99
import useProvideRow from './context';
1010

1111
const RowAligns = tuple('top', 'middle', 'bottom', 'stretch');
12-
const RowJustify = tuple('start', 'end', 'center', 'space-around', 'space-between');
12+
const RowJustify = tuple('start', 'end', 'center', 'space-around', 'space-between', 'space-evenly');
1313

14-
export type Gutter = number | Partial<Record<Breakpoint, number>>;
14+
type Gap = number | undefined;
15+
export type Gutter = number | undefined | Partial<Record<Breakpoint, number>>;
1516

1617
export interface rowContextState {
1718
gutter?: [number, number];
@@ -68,9 +69,9 @@ const ARow = defineComponent({
6869
});
6970

7071
const gutter = computed(() => {
71-
const results: [number, number] = [0, 0];
72+
const results: [Gap, Gap] = [undefined, undefined];
7273
const { gutter = 0 } = props;
73-
const normalizedGutter = Array.isArray(gutter) ? gutter : [gutter, 0];
74+
const normalizedGutter = Array.isArray(gutter) ? gutter : [gutter, undefined];
7475
normalizedGutter.forEach((g, index) => {
7576
if (typeof g === 'object') {
7677
for (let i = 0; i < responsiveArray.length; i++) {
@@ -81,7 +82,7 @@ const ARow = defineComponent({
8182
}
8283
}
8384
} else {
84-
results[index] = g || 0;
85+
results[index] = g;
8586
}
8687
});
8788
return results;
@@ -106,8 +107,8 @@ const ARow = defineComponent({
106107
const gt = gutter.value;
107108
// Add gutter related style
108109
const style: CSSProperties = {};
109-
const horizontalGutter = gt[0] > 0 ? `${gt[0] / -2}px` : undefined;
110-
const verticalGutter = gt[1] > 0 ? `${gt[1] / -2}px` : undefined;
110+
const horizontalGutter = gt[0] != null && gt[0] > 0 ? `${gt[0] / -2}px` : undefined;
111+
const verticalGutter = gt[1] != null && gt[1] > 0 ? `${gt[1] / -2}px` : undefined;
111112

112113
if (horizontalGutter) {
113114
style.marginLeft = horizontalGutter;
@@ -126,7 +127,7 @@ const ARow = defineComponent({
126127

127128
return () => {
128129
return (
129-
<div class={classes.value} style={rowStyle.value}>
130+
<div role="row" class={classes.value} style={rowStyle.value}>
130131
{slots.default?.()}
131132
</div>
132133
);

components/grid/demo/playfround.vue

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ A simple playground for column count and gutter.
5858
>
5959
<div>Column</div>
6060
</a-col>
61-
6261
<a-col
6362
v-for="item in colCounts[colCountKey]"
6463
:key="item.toString()"
@@ -119,23 +118,34 @@ export default defineComponent({
119118
});
120119
</script>
121120
<style scoped>
122-
#components-grid-demo-playground :deep(.ant-col) {
121+
#components-grid-demo-playground [class~='ant-col'] {
123122
background: transparent;
124123
border: 0;
125124
}
126-
#components-grid-demo-playground :deep(.ant-col) > div {
127-
background: #00a0e9;
125+
#components-grid-demo-playground [class~='ant-col'] > div {
128126
height: 120px;
127+
font-size: 14px;
129128
line-height: 120px;
130-
font-size: 13px;
129+
background: #0092ff;
130+
border-radius: 4px;
131131
}
132132
#components-grid-demo-playground pre {
133+
padding: 8px 16px;
134+
font-size: 13px;
133135
background: #f9f9f9;
134136
border-radius: 6px;
135-
font-size: 13px;
136-
padding: 8px 16px;
137137
}
138-
[data-theme='dark'] #components-grid-demo-playground pre {
139-
background: #2f2f2f;
138+
#components-grid-demo-playground pre.demo-code {
139+
direction: ltr;
140+
}
141+
#components-grid-demo-playground .ant-col {
142+
padding: 0;
143+
}
144+
.code-box-demo #components-grid-demo-playground .ant-row > div {
145+
margin-top: 0;
146+
margin-bottom: 0;
147+
}
148+
[data-theme='dark'] #components-grid-demo-playground [class~='ant-col'] > div {
149+
background: #028ac8;
140150
}
141151
</style>

components/grid/index.en-US.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ cover: https://gw.alipayobjects.com/zos/alicdn/5rWLU27so/Grid.svg
1010

1111
## Design concept
1212

13+
<div class="grid-demo">
14+
<img src="https://gw.alipayobjects.com/zos/bmw-prod/9189c9ef-c601-40dc-9960-c11dbb681888.svg" alt="grid design" />
15+
</div>
16+
1317
In most business situations, Ant Design Vue needs to solve a lot of information storage problems within the design area, so based on 12 Grids System, we divided the design area into 24 sections.
1418

1519
We name the divided area 'box'. We suggest four boxes for horizontal arrangement at most, one at least. Boxes are proportional to the entire screen as shown in the picture above. To ensure a high level of visual comfort, we customize the typography inside of the box based on the box unit.
@@ -37,7 +41,7 @@ Our grid systems support Flex layout to allow the elements within the parent to
3741
| --- | --- | --- | --- |
3842
| align | the vertical alignment of the flex layout: `top` `middle` `bottom` | string | `top` |
3943
| gutter | spacing between grids, could be a number or a object like `{ xs: 8, sm: 16, md: 24}`. or you can use array to make horizontal and vertical spacing work at the same time `[horizontal, vertical]` (supported after `1.5.0`) | number/object/array | 0 |
40-
| justify | horizontal arrangement of the flex layout: `start` `end` `center` `space-around` `space-between` | string | `start` |
44+
| justify | horizontal arrangement of the flex layout: `start` \| `end` \| `center` \| `space-around` \| `space-between` \| `space-evenly` | string | `start` |
4145
| wrap | Auto wrap line | boolean | false |
4246

4347
### Col

components/grid/index.zh-CN.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ cover: https://gw.alipayobjects.com/zos/alicdn/5rWLU27so/Grid.svg
1111

1212
## 设计理念
1313

14+
<div class="grid-demo">
15+
<img src="https://gw.alipayobjects.com/zos/bmw-prod/9189c9ef-c601-40dc-9960-c11dbb681888.svg" alt="grid design" />
16+
</div>
17+
1418
在多数业务情况下,Ant Design Vue 需要在设计区域内解决大量信息收纳的问题,因此在 12 栅格系统的基础上,我们将整个设计建议区域按照 24 等分的原则进行划分。划分之后的信息区块我们称之为『盒子』。建议横向排列的盒子数量最多四个,最少一个。『盒子』在整个屏幕上占比见上图。设计部分基于盒子的单位定制盒子内部的排版规则,以保证视觉层面的舒适感。
1519

1620
## 概述
@@ -34,7 +38,7 @@ cover: https://gw.alipayobjects.com/zos/alicdn/5rWLU27so/Grid.svg
3438
| --- | --- | --- | --- |
3539
| align | flex 布局下的垂直对齐方式:`top` `middle` `bottom` | string | `top` |
3640
| gutter | 栅格间隔,可以写成像素值或支持响应式的对象写法来设置水平间隔 `{ xs: 8, sm: 16, md: 24}`。或者使用数组形式同时设置 `[水平间距, 垂直间距]``1.5.0 后支持`)。 | number/object/array | 0 |
37-
| justify | flex 布局下的水平排列方式:`start` `end` `center` `space-around` `space-between` | string | `start` |
41+
| justify | flex 布局下的水平排列方式: `start` \| `end` \| `center` \| `space-around` \| `space-between` \| `space-evenly` | string | `start` |
3842
| wrap | 是否自动换行 | boolean | false |
3943

4044
### Col

components/grid/style/index.less

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
@import '../../style/mixins/index';
33
@import './mixin';
44

5-
@row-prefix-cls: ~'@{ant-prefix}-row';
6-
@col-prefix-cls: ~'@{ant-prefix}-col';
7-
85
// Grid system
96
.@{row-prefix-cls} {
107
display: flex;
@@ -46,6 +43,11 @@
4643
justify-content: space-around;
4744
}
4845

46+
// x轴有间隔地均分
47+
.@{row-prefix-cls}-space-evenly {
48+
justify-content: space-evenly;
49+
}
50+
4951
// 顶部对齐
5052
.@{row-prefix-cls}-top {
5153
align-items: flex-start;

components/grid/style/mixin.less

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,52 @@
11
@import '../../style/mixins/index';
22

3+
@row-prefix-cls: ~'@{ant-prefix}-row';
4+
@col-prefix-cls: ~'@{ant-prefix}-col';
5+
36
// mixins for grid system
47
// ------------------------
58

69
.loop-grid-columns(@index, @class) when (@index > 0) {
7-
.@{ant-prefix}-col@{class}-@{index} {
10+
.@{col-prefix-cls}@{class}-@{index} {
811
display: block;
912
flex: 0 0 percentage((@index / @grid-columns));
1013
max-width: percentage((@index / @grid-columns));
1114
}
12-
.@{ant-prefix}-col@{class}-push-@{index} {
15+
.@{col-prefix-cls}@{class}-push-@{index} {
1316
left: percentage((@index / @grid-columns));
1417
}
15-
.@{ant-prefix}-col@{class}-pull-@{index} {
18+
.@{col-prefix-cls}@{class}-pull-@{index} {
1619
right: percentage((@index / @grid-columns));
1720
}
18-
.@{ant-prefix}-col@{class}-offset-@{index} {
21+
.@{col-prefix-cls}@{class}-offset-@{index} {
1922
margin-left: percentage((@index / @grid-columns));
2023
}
21-
.@{ant-prefix}-col@{class}-order-@{index} {
24+
.@{col-prefix-cls}@{class}-order-@{index} {
2225
order: @index;
2326
}
2427
.loop-grid-columns((@index - 1), @class);
2528
}
2629

2730
.loop-grid-columns(@index, @class) when (@index = 0) {
28-
.@{ant-prefix}-col@{class}-@{index} {
31+
.@{col-prefix-cls}@{class}-@{index} {
2932
display: none;
3033
}
31-
.@{ant-prefix}-col-push-@{index} {
34+
.@{col-prefix-cls}-push-@{index} {
3235
left: auto;
3336
}
34-
.@{ant-prefix}-col-pull-@{index} {
37+
.@{col-prefix-cls}-pull-@{index} {
3538
right: auto;
3639
}
37-
.@{ant-prefix}-col@{class}-push-@{index} {
40+
.@{col-prefix-cls}@{class}-push-@{index} {
3841
left: auto;
3942
}
40-
.@{ant-prefix}-col@{class}-pull-@{index} {
43+
.@{col-prefix-cls}@{class}-pull-@{index} {
4144
right: auto;
4245
}
43-
.@{ant-prefix}-col@{class}-offset-@{index} {
46+
.@{col-prefix-cls}@{class}-offset-@{index} {
4447
margin-left: 0;
4548
}
46-
.@{ant-prefix}-col@{class}-order-@{index} {
49+
.@{col-prefix-cls}@{class}-order-@{index} {
4750
order: 0;
4851
}
4952
}

components/grid/style/rtl.less

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,68 @@
11
@import '../../style/themes/index';
22
@import '../../style/mixins/index';
3+
@import './mixin';
34

4-
.@{ant-prefix}-row {
5+
.@{row-prefix-cls} {
56
&-rtl {
67
direction: rtl;
78
}
89
}
910

1011
// mixin
1112
.loop-grid-columns(@index, @class) when (@index > 0) {
12-
.@{ant-prefix}-col@{class}-push-@{index} {
13+
.@{col-prefix-cls}@{class}-push-@{index} {
1314
// reset property in RTL direction
14-
&.@{ant-prefix}-col-rtl {
15+
&.@{col-prefix-cls}-rtl {
1516
right: percentage((@index / @grid-columns));
1617
left: auto;
1718
}
1819
}
1920

20-
.@{ant-prefix}-col@{class}-pull-@{index} {
21+
.@{col-prefix-cls}@{class}-pull-@{index} {
2122
// reset property in RTL direction
22-
&.@{ant-prefix}-col-rtl {
23+
&.@{col-prefix-cls}-rtl {
2324
right: auto;
2425
left: percentage((@index / @grid-columns));
2526
}
2627
}
2728

28-
.@{ant-prefix}-col@{class}-offset-@{index} {
29+
.@{col-prefix-cls}@{class}-offset-@{index} {
2930
// reset property in RTL direction
30-
&.@{ant-prefix}-col-rtl {
31+
&.@{col-prefix-cls}-rtl {
3132
margin-right: percentage((@index / @grid-columns));
3233
margin-left: 0;
3334
}
3435
}
3536
}
3637

3738
.loop-grid-columns(@index, @class) when (@index = 0) {
38-
.@{ant-prefix}-col-push-@{index} {
39+
.@{col-prefix-cls}-push-@{index} {
3940
// reset property in RTL direction
40-
&.@{ant-prefix}-col-rtl {
41+
&.@{col-prefix-cls}-rtl {
4142
right: auto;
4243
}
4344
}
4445

45-
.@{ant-prefix}-col-pull-@{index} {
46-
&.@{ant-prefix}-col-rtl {
46+
.@{col-prefix-cls}-pull-@{index} {
47+
&.@{col-prefix-cls}-rtl {
4748
left: auto;
4849
}
4950
}
5051

51-
.@{ant-prefix}-col@{class}-push-@{index} {
52-
&.@{ant-prefix}-col-rtl {
52+
.@{col-prefix-cls}@{class}-push-@{index} {
53+
&.@{col-prefix-cls}-rtl {
5354
right: auto;
5455
}
5556
}
5657

57-
.@{ant-prefix}-col@{class}-pull-@{index} {
58-
&.@{ant-prefix}-col-rtl {
58+
.@{col-prefix-cls}@{class}-pull-@{index} {
59+
&.@{col-prefix-cls}-rtl {
5960
left: auto;
6061
}
6162
}
6263

63-
.@{ant-prefix}-col@{class}-offset-@{index} {
64-
&.@{ant-prefix}-col-rtl {
64+
.@{col-prefix-cls}@{class}-offset-@{index} {
65+
&.@{col-prefix-cls}-rtl {
6566
margin-right: 0;
6667
}
6768
}

0 commit comments

Comments
 (0)