From f195f791f67a53d2d69a7fd9ff33c9112e8c8ae7 Mon Sep 17 00:00:00 2001 From: zhangwen <1062680993@qq.com> Date: Wed, 27 May 2020 19:25:59 +0800 Subject: [PATCH] feat(gant-table): add gantt table style --- .../src/app/examples/examples.component.html | 2 +- packages/gantt/src/gantt-upper.ts | 2 +- packages/gantt/src/gantt.scss | 8 ++-- .../src/table/gantt-table.component.html | 10 ++--- .../src/table/gantt-table.component.scss | 45 +++++++++++++++++++ .../gantt/src/table/gantt-table.component.ts | 4 +- .../src/table/group/group.component.scss | 10 +++++ .../src/table/items/items.component.html | 4 +- 8 files changed, 71 insertions(+), 14 deletions(-) create mode 100644 packages/gantt/src/table/group/group.component.scss diff --git a/example/src/app/examples/examples.component.html b/example/src/app/examples/examples.component.html index 4b158751..e4953c79 100644 --- a/example/src/app/examples/examples.component.html +++ b/example/src/app/examples/examples.component.html @@ -1,7 +1,7 @@ - {{ row.origin.title }} + {{ row.title }} diff --git a/packages/gantt/src/gantt-upper.ts b/packages/gantt/src/gantt-upper.ts index 8eac17d5..1944acf1 100644 --- a/packages/gantt/src/gantt-upper.ts +++ b/packages/gantt/src/gantt-upper.ts @@ -25,7 +25,7 @@ import { Subject, fromEvent } from 'rxjs'; import { GanttTableColumnComponent } from './table/column/column.component'; const defaultStyles = { - lineHeight: 55, + lineHeight: 50, barHeight: 25, }; diff --git a/packages/gantt/src/gantt.scss b/packages/gantt/src/gantt.scss index f66b9330..03f0a35b 100644 --- a/packages/gantt/src/gantt.scss +++ b/packages/gantt/src/gantt.scss @@ -48,10 +48,10 @@ $gantt-date-today-color: #FF9F73 !default; .gantt-viewer-container { width: 100%; - height: calc(100% - 60px); + height: calc(100% - 50px); flex: 1; position: absolute; - top: 60px; + top: 50px; bottom: 0; left: 0; right: 0; @@ -62,13 +62,13 @@ $gantt-date-today-color: #FF9F73 !default; } .gantt-group { - height: 45px; + height: 50px; box-sizing: border-box; background: #fafafa; } .gantt-item { - height: 55px; + height: 50px; border-bottom: 1px solid $gantt-border-color; box-sizing: border-box; position: relative; diff --git a/packages/gantt/src/table/gantt-table.component.html b/packages/gantt/src/table/gantt-table.component.html index db6e8fb6..0ca17cf3 100644 --- a/packages/gantt/src/table/gantt-table.component.html +++ b/packages/gantt/src/table/gantt-table.component.html @@ -1,5 +1,5 @@ -
+
@@ -8,15 +8,15 @@
-
+
- + + +
diff --git a/packages/gantt/src/table/gantt-table.component.scss b/packages/gantt/src/table/gantt-table.component.scss index 98239c1a..244c9c5f 100644 --- a/packages/gantt/src/table/gantt-table.component.scss +++ b/packages/gantt/src/table/gantt-table.component.scss @@ -1,3 +1,48 @@ +$gantt-table-color: #333 !default; +$gantt-table-td-height: 50px !default; +$gantt-table-thead-height: 50px !default; +$gantt-table-td-padding: 0 15px !default; +$gantt-table-bg: #fff !default; +$gantt-table-border-color: #eee !default; + +@import './group/group.component.scss'; + .gantt-table { + table { + width: 100%; + margin: 0; + padding: 0; + table-layout: fixed; + border-collapse: separate; + border-spacing: 0; + color: $gantt-table-color; + background-color: transparent; + thead, + tbody { + tr { + height: $gantt-table-td-height; + } + + th, + td { + padding: $gantt-table-td-padding; + background-color: $gantt-table-bg; + border-right: 1px solid $gantt-table-border-color; + border-bottom: 1px solid $gantt-table-border-color; + position: relative; + } + td { + transition: width 0.5s; + } + } + thead { + th { + font-weight: 400; + height: $gantt-table-thead-height; + } + } + } + .gantt-table-header { + } } diff --git a/packages/gantt/src/table/gantt-table.component.ts b/packages/gantt/src/table/gantt-table.component.ts index c45fef8a..a4cd4d12 100644 --- a/packages/gantt/src/table/gantt-table.component.ts +++ b/packages/gantt/src/table/gantt-table.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, ElementRef, ChangeDetectionStrategy, Input, EventEmitter, Output } from '@angular/core'; +import { Component, OnInit, ElementRef, ChangeDetectionStrategy, Input, EventEmitter, Output, HostBinding } from '@angular/core'; import { GanttUpper } from '../gantt-upper'; import { GanttRef, GANTT_REF_TOKEN } from '../gantt-ref'; import { GanttDependencyDragEvent, GanttDependencyEvent, GanttItemInternal } from '../class'; @@ -23,6 +23,8 @@ export class GanttTableComponent extends GanttUpper implements GanttRef, OnInit @Output() dependencyClick = new EventEmitter(); + @HostBinding('class.gantt-table') ganttTableClass = true; + constructor(elementRef: ElementRef) { super(elementRef); } diff --git a/packages/gantt/src/table/group/group.component.scss b/packages/gantt/src/table/group/group.component.scss new file mode 100644 index 00000000..17dd419d --- /dev/null +++ b/packages/gantt/src/table/group/group.component.scss @@ -0,0 +1,10 @@ +.gantt-table-group { + .gantt-table-group-header { + height: 50px; + background: #fafafa; + vertical-align: middle; + display: flex; + align-items: center; + padding: 0 15px; + } +} diff --git a/packages/gantt/src/table/items/items.component.html b/packages/gantt/src/table/items/items.component.html index 3867a58e..39660f80 100644 --- a/packages/gantt/src/table/items/items.component.html +++ b/packages/gantt/src/table/items/items.component.html @@ -17,7 +17,7 @@ [ngTemplateOutlet]="tdTemplate" [ngTemplateOutletContext]="{ column: column, - row: row, + row: row.origin, index: i }" > @@ -29,6 +29,6 @@