Skip to content

Commit

Permalink
Merge pull request #1359 from Micro-sun/develop
Browse files Browse the repository at this point in the history
 feat: add align for grid
  • Loading branch information
chaishi authored Aug 24, 2022
2 parents a07efd4 + bba978a commit 44c7683
Show file tree
Hide file tree
Showing 11 changed files with 99 additions and 91 deletions.
3 changes: 1 addition & 2 deletions examples/grid/grid.en-US.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
:: BASE_DOC ::

## API

### Row Props

name | type | default | description | required
-- | -- | -- | -- | --
align | String | top | options:top/middle/bottom | N
align | String | top | options:start/end/center/stretch/baseline/top/middle/bottom | N
gutter | Number / Object / Array | 0 | Typescript:`number | GutterObject | Array<GutterObject | number>` `interface GutterObject { xs: number; sm: number; md: number } `[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/grid/type.ts) | N
justify | String | start | options:start/end/center/space-around/space-between | N
tag | String | div | \- | N
Expand Down
2 changes: 1 addition & 1 deletion examples/grid/grid.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

名称 | 类型 | 默认值 | 说明 | 必传
-- | -- | -- | -- | --
align | String | top | 纵向对齐方式可选项:top/middle/bottom | N
align | String | top | 纵向对齐方式,CSS 属性 `align-items` 值。其中 `top``start` 等效;`middle``center` 等效;`bottom``end` 等效。可选项:start/end/center/stretch/baseline/top/middle/bottom | N
gutter | Number / Object / Array | 0 | 栅格间隔,示例:`{ xs: 8, sm: 16, md: 24}`。当数据类型为 Number 和 Object 时,用于指定横向间隔。当数据类型为数组时,第一个参数为横向间隔,第二个参数为纵向间隔, [水平间隔, 垂直间隔]。TS 类型:`number | GutterObject | Array<GutterObject | number>` `interface GutterObject { xs: number; sm: number; md: number } `[详细类型定义](https://github.com/Tencent/tdesign-vue/tree/develop/src/grid/type.ts) | N
justify | String | start | flex 布局下的水平排列方式。可选项:start/end/center/space-around/space-between | N
tag | String | div | 自定义元素标签 | N
Expand Down
3 changes: 1 addition & 2 deletions src/grid/col-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

/**
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* updated at 2021-11-19 10:44:26
* */

import { TdColProps } from '../grid/type';
Expand Down Expand Up @@ -36,7 +35,7 @@ export default {
type: Number,
default: 0,
},
/** 栅格向左移动格数 */
/** 栅格向右移动格数 */
push: {
type: Number,
default: 0,
Expand Down
7 changes: 4 additions & 3 deletions src/grid/row-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

/**
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* updated at 2021-11-19 10:44:26
* */

import { TdRowProps } from '../grid/type';
import { PropType } from 'vue';

export default {
/** 纵向对齐方式 */
/** 纵向对齐方式,CSS 属性 `align-items` 值。其中 `top` 和 `start` 等效;`middle` 和 `center` 等效;`bottom` 和 `end` 等效 */
align: {
type: String as PropType<TdRowProps['align']>,
default: 'top' as TdRowProps['align'],
validator(val: TdRowProps['align']): boolean {
return ['top', 'middle', 'bottom'].includes(val);
if (!val) return true;
return ['start', 'end', 'center', 'stretch', 'baseline', 'top', 'middle', 'bottom'].includes(val);
},
},
/** 栅格间隔,示例:`{ xs: 8, sm: 16, md: 24}`。当数据类型为 Number 和 Object 时,用于指定横向间隔。当数据类型为数组时,第一个参数为横向间隔,第二个参数为纵向间隔, [水平间隔, 垂直间隔] */
Expand All @@ -27,6 +27,7 @@ export default {
type: String as PropType<TdRowProps['justify']>,
default: 'start' as TdRowProps['justify'],
validator(val: TdRowProps['justify']): boolean {
if (!val) return true;
return ['start', 'end', 'center', 'space-around', 'space-between'].includes(val);
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/grid/row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default mixins(classPrefixMixins).extend({
this.componentName,
{
[`${this.componentName}--${justify}`]: justify,
[`${this.componentName}--${align}`]: align,
[`${this.componentName}--align-${align}`]: align,
},
];
},
Expand Down
27 changes: 18 additions & 9 deletions src/grid/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@

/**
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* updated at 2021-11-19 10:44:26
* */

export interface TdRowProps {
/**
* 纵向对齐方式
* 纵向对齐方式,CSS 属性 `align-items` 值。其中 `top` 和 `start` 等效;`middle` 和 `center` 等效;`bottom` 和 `end` 等效
* @default top
*/
align?: 'top' | 'middle' | 'bottom';
align?: 'start' | 'end' | 'center' | 'stretch' | 'baseline' | 'top' | 'middle' | 'bottom';
/**
* 栅格间隔,示例:`{ xs: 8, sm: 16, md: 24}`。当数据类型为 Number 和 Object 时,用于指定横向间隔。当数据类型为数组时,第一个参数为横向间隔,第二个参数为纵向间隔, [水平间隔, 垂直间隔]
* @default 0
*/
gutter?: number | GutterObject | Array<GutterObject | number>;
gutter?: number | GutterObject | Array<GutterObject | number>;
/**
* flex 布局下的水平排列方式
* @default start
Expand All @@ -26,7 +25,7 @@ export interface TdRowProps {
* @default div
*/
tag?: string;
};
}

export interface TdColProps {
/**
Expand Down Expand Up @@ -57,7 +56,7 @@ export interface TdColProps {
*/
pull?: number;
/**
* 栅格向左移动格数
* 栅格向右移动格数
* @default 0
*/
push?: number;
Expand Down Expand Up @@ -87,8 +86,18 @@ export interface TdColProps {
* ≥1880px 响应式栅格,可为栅格数或一个包含其他属性的对象(大尺寸电脑)
*/
xxl?: number | BaseColProps;
};
}

export interface GutterObject { xs: number; sm: number; md: number } ;
export interface GutterObject {
xs: number;
sm: number;
md: number;
}

export interface BaseColProps { offset: number; order: number; pull: number; push: number; span: number };
export interface BaseColProps {
offset: number;
order: number;
pull: number;
push: number;
span: number;
}
Loading

0 comments on commit 44c7683

Please sign in to comment.