Skip to content

Commit

Permalink
TableColumn: add align attribute, #78 (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
QingWei-Li authored and furybean committed Sep 20, 2016
1 parent 76683d1 commit 56ed21d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions examples/docs/table.md
Original file line number Diff line number Diff line change
Expand Up @@ -865,3 +865,4 @@
| formatter | 用来格式化内容,在 formatter 执行的时候,会传入 row 和 column | function |||
| show-tooltip-when-overflow | 当过长被隐藏时显示 tooltip | Boolean || false |
| inline-template | 指定该属性后可以自定义 column 模板,参考多选的时间列,通过 row 获取行信息,JSX 里通过 _self 获取当前上下文。此时不需要配置 property 属性 |||
| align | 对齐方式 | String | left, center, right | left |
2 changes: 1 addition & 1 deletion packages/table/src/table-body.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default {
this._l(this.columns, (column) =>
<td
style={ this.getColumnWhiteSpaceStyle(column) }
class={ column.id }
class={ [column.id, column.align] }
on-mouseenter={ ($event) => this.handleCellMouseEnter($event, row) }
on-mouseleave={ this.handleCellMouseLeave }>
{
Expand Down
2 changes: 2 additions & 0 deletions packages/table/src/table-column.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export default {
type: Boolean,
default: true
},
align: String,
showTooltipWhenOverflow: {
type: Boolean,
default: false
Expand Down Expand Up @@ -160,6 +161,7 @@ export default {
minWidth,
width,
isColumnGroup,
align: this.align ? 'is-' + this.align : null,
realWidth: width || minWidth,
sortable: this.sortable,
resizable: this.resizable,
Expand Down
2 changes: 1 addition & 1 deletion packages/table/src/table-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default {
on-mouseout={ this.handleMouseOut }
on-mousedown={ ($event) => this.handleMouseDown($event, column) }
on-click={ ($event) => this.handleHeaderClick($event, column) }
class={ [column.id, column.direction] }>
class={ [column.id, column.direction, column.align] }>
{
[
column.headerTemplate
Expand Down
12 changes: 12 additions & 0 deletions packages/theme-default/src/table.css
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@
vertical-align: middle;
position: relative;
border-bottom: 1px solid var(--table-border-color);

@when center {
text-align: center;
}

@when left {
text-align: left;
}

@when right {
text-align: right;
}
}

@modifier border {
Expand Down

0 comments on commit 56ed21d

Please sign in to comment.