From d040961e25aaa409c368e592784d72496ba82489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Tue, 1 Dec 2020 22:14:48 +0200 Subject: [PATCH] Sync width directive --- apps/red-ui/src/app/app.module.ts | 4 +- .../table-col-name.component.scss | 1 - .../dictionary-listing-screen.component.html | 46 ++++++++--------- .../dictionary-listing-screen.component.scss | 21 ++++---- .../file-preview-screen.component.scss | 1 + .../file-preview-screen.component.ts | 1 - .../project-listing-screen.component.html | 18 ++++--- .../project-listing-screen.component.scss | 2 + .../project-overview-screen.component.html | 50 ++++++++++--------- .../project-overview-screen.component.scss | 25 ++++++---- .../src/app/utils/sync-width.directive.ts | 38 ++++++++++++++ apps/red-ui/src/assets/styles/red-grid.scss | 3 +- .../src/assets/styles/red-page-layout.scss | 4 +- apps/red-ui/src/assets/styles/red-tables.scss | 21 +++----- 14 files changed, 140 insertions(+), 95 deletions(-) create mode 100644 apps/red-ui/src/app/utils/sync-width.directive.ts diff --git a/apps/red-ui/src/app/app.module.ts b/apps/red-ui/src/app/app.module.ts index 60059d4f3..21d8e1d4d 100644 --- a/apps/red-ui/src/app/app.module.ts +++ b/apps/red-ui/src/app/app.module.ts @@ -87,6 +87,7 @@ import { CustomTooltipModule } from './common/red-tooltip/custom-tooltip.module' import { ScrollingModule } from '@angular/cdk/scrolling'; import { VirtualScrollComponent } from './utils/virtual-scroll/virtual-scroll.component'; import { DragDropModule } from '@angular/cdk/drag-drop'; +import { SyncWidthDirective } from './utils/sync-width.directive'; export function HttpLoaderFactory(httpClient: HttpClient) { return new TranslateHttpLoader(httpClient, '/assets/i18n/', '.json'); @@ -139,7 +140,8 @@ export function HttpLoaderFactory(httpClient: HttpClient) { CircleButtonComponent, ChevronButtonComponent, DictionaryListingScreenComponent, - VirtualScrollComponent + VirtualScrollComponent, + SyncWidthDirective ], imports: [ BrowserModule, diff --git a/apps/red-ui/src/app/components/table-col-name/table-col-name.component.scss b/apps/red-ui/src/app/components/table-col-name/table-col-name.component.scss index 9d530967d..9c3491ce0 100644 --- a/apps/red-ui/src/app/components/table-col-name/table-col-name.component.scss +++ b/apps/red-ui/src/app/components/table-col-name/table-col-name.component.scss @@ -2,7 +2,6 @@ :host { display: flex; - border-bottom: 1px solid $separator; height: 30px; > div { diff --git a/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/dictionary-listing-screen.component.html b/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/dictionary-listing-screen.component.html index c54c4eaa8..3aa4233b3 100644 --- a/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/dictionary-listing-screen.component.html +++ b/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/dictionary-listing-screen.component.html @@ -5,30 +5,29 @@
-
-
-
-
- - -
- - - {{ 'dictionary-listing.table-header.title' | translate: { length: dictionaries.length } }} - +
+
+
+ +
- + + {{ 'dictionary-listing.table-header.title' | translate: { length: dictionaries.length } }} + +
+ +
+
- +
diff --git a/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/dictionary-listing-screen.component.scss b/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/dictionary-listing-screen.component.scss index 6ccf1d86d..c2006dacc 100644 --- a/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/dictionary-listing-screen.component.scss +++ b/apps/red-ui/src/app/screens/admin/dictionary-listing-screen/dictionary-listing-screen.component.scss @@ -1,20 +1,20 @@ @import '../../../../assets/styles/red-variables'; @import '../../../../assets/styles/red-mixins'; +.header-item { + padding: 0 24px 0 10px; +} + +redaction-table-col-name::ng-deep { + > div { + padding-left: 10px !important; + } +} + .left-container { .grid-container { grid-template-columns: auto 1fr 1fr 2fr; - .header-item { - padding: 0 24px 0 10px; - } - - redaction-table-col-name::ng-deep { - > div { - padding-left: 10px; - } - } - .table-item { > div { display: flex; @@ -39,6 +39,7 @@ margin-top: 4px; } } + width: calc(100vw - 353px); } .right-container { diff --git a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.scss b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.scss index 344b3d1a4..eb6abc394 100644 --- a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.scss +++ b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.scss @@ -27,6 +27,7 @@ width: 100%; height: 50px; } + width: calc(100vw - 350px); } .right-container { diff --git a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.ts b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.ts index 3e8dc147f..74e99588c 100644 --- a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.ts @@ -258,7 +258,6 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy { @HostListener('window:keyup', ['$event']) handleKeyEvent($event: KeyboardEvent) { - console.log('handle', $event.key); if (!KEY_ARRAY.includes($event.key) || this._dialogRef?.getState() === MatDialogState.OPEN) { return; } diff --git a/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.html b/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.html index 00a1fc082..754840b9e 100644 --- a/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.html +++ b/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.html @@ -39,13 +39,13 @@
-
-
- - {{ 'project-listing.table-header.title' | translate: { length: displayedProjects.length || 0 } }} - -
+
+ + {{ 'project-listing.table-header.title' | translate: { length: displayedProjects.length || 0 } }} + +
+
+
-
+
+
-
+
{{ pw.project.projectName }}
diff --git a/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.scss b/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.scss index 7c5362cf8..cb88f0546 100644 --- a/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.scss +++ b/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.scss @@ -13,6 +13,8 @@ .status-container { width: 160px; } + + width: calc(100vw - 466px); } .right-container { diff --git a/apps/red-ui/src/app/screens/project-overview-screen/project-overview-screen.component.html b/apps/red-ui/src/app/screens/project-overview-screen/project-overview-screen.component.html index e9854a425..81a6a466d 100644 --- a/apps/red-ui/src/app/screens/project-overview-screen/project-overview-screen.component.html +++ b/apps/red-ui/src/app/screens/project-overview-screen/project-overview-screen.component.html @@ -90,31 +90,31 @@
-
-
-
-
- - -
- - - {{ 'project-overview.table-header.title' | translate: { length: displayedFiles.length || 0 } }} - - - +
+
+
+ +
+ + {{ 'project-overview.table-header.title' | translate: { length: displayedFiles.length || 0 } }} + + + +
+ +
@@ -160,9 +160,11 @@ column="statusSort" label="project-overview.table-col-names.status" > +
-
+
+
div { + padding-left: 10px !important; + } +} + .grid-container { grid-template-columns: auto 3fr 2fr 1fr 1fr 2fr auto; - .header-item { - padding: 0 24px 0 10px; - } - - redaction-table-col-name::ng-deep { - > div { - padding-left: 10px; - } - } - .table-item { > div { padding-left: 10px; @@ -63,7 +63,12 @@ } } +.left-container { + width: calc(100vw - 350px); +} + .right-container { + display: flex; width: 350px; min-width: 350px; padding: 16px 16px 16px 24px; diff --git a/apps/red-ui/src/app/utils/sync-width.directive.ts b/apps/red-ui/src/app/utils/sync-width.directive.ts new file mode 100644 index 000000000..18a0399df --- /dev/null +++ b/apps/red-ui/src/app/utils/sync-width.directive.ts @@ -0,0 +1,38 @@ +import { AfterViewChecked, Directive, ElementRef, HostListener, Input } from '@angular/core'; +import { debounce } from './debounce'; + +@Directive({ + selector: '[redactionSyncWidth]', + exportAs: 'redactionSyncWidth' +}) +export class SyncWidthDirective implements AfterViewChecked { + @Input() + redactionSyncWidth: string; + + constructor(private el: ElementRef) {} + + ngAfterViewChecked() { + this.matchWidth(); + } + + @debounce(0) + matchWidth() { + const headerItems = this.el.nativeElement.children; + const tableRows = document.getElementsByClassName(this.redactionSyncWidth); + + if (!tableRows || !tableRows.length) return; + + const tableRow = tableRows[0]; + if (tableRow.children.length !== headerItems.length) return; + + for (let idx = 0; idx < headerItems.length; ++idx) { + headerItems[idx].style.width = `${tableRow.children[idx].getBoundingClientRect().width}px`; + headerItems[idx].style.minWidth = `${tableRow.children[idx].getBoundingClientRect().width}px`; + } + } + + @HostListener('window:resize') + onResize() { + this.matchWidth(); + } +} diff --git a/apps/red-ui/src/assets/styles/red-grid.scss b/apps/red-ui/src/assets/styles/red-grid.scss index 7d606d86c..3e64d6327 100644 --- a/apps/red-ui/src/assets/styles/red-grid.scss +++ b/apps/red-ui/src/assets/styles/red-grid.scss @@ -1,4 +1,5 @@ @import 'red-variables'; +@import 'red-mixins'; .header-item { background-color: $grey-6; @@ -7,8 +8,6 @@ display: flex; align-items: center; z-index: 1; - position: sticky; - top: 0; gap: 10px; border-bottom: 1px solid $separator; box-sizing: border-box; diff --git a/apps/red-ui/src/assets/styles/red-page-layout.scss b/apps/red-ui/src/assets/styles/red-page-layout.scss index 424fb48f3..47e540a66 100644 --- a/apps/red-ui/src/assets/styles/red-page-layout.scss +++ b/apps/red-ui/src/assets/styles/red-page-layout.scss @@ -66,7 +66,8 @@ body { } .left-container { - width: 100%; + overflow: hidden; + transition: width ease-in-out 0.2s, min-width ease-in-out 0.2s; &.extended { width: calc(100vw - 60px) !important; @@ -75,6 +76,7 @@ body { .right-container { border-left: 1px solid $grey-4; + box-sizing: border-box; background: $white; z-index: 1; overflow-y: scroll; diff --git a/apps/red-ui/src/assets/styles/red-tables.scss b/apps/red-ui/src/assets/styles/red-tables.scss index bd1e23eb8..7d46b8916 100644 --- a/apps/red-ui/src/assets/styles/red-tables.scss +++ b/apps/red-ui/src/assets/styles/red-tables.scss @@ -1,29 +1,22 @@ @import 'red-variables'; @import 'red-mixins'; -redaction-table-col-name, -.select-oval-placeholder { - background-color: $white; - position: sticky; - top: 50px; - z-index: 1; +.no-data { + padding: 24px; } -.no-data { - grid-column: 1/-1; - padding: 12px; +.table-header { + display: flex; + justify-content: space-between; + border-bottom: 1px solid $separator; } .grid-container { display: grid; - max-height: 100%; + max-height: calc(100vh - 50px - 30px - 111px); overflow-y: scroll; @include no-scroll-bar(); - .placeholder-bottom-border { - border-bottom: 1px solid $separator; - } - .table-item { display: contents;