From 72f7782898b10c4b3c8a49ab73adaa01baafbc4b Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Thu, 7 Oct 2021 18:01:05 +0200 Subject: [PATCH] fix(core): update --- ts_web/elements/dees-table.ts | 223 ++++++++++++++++++++++++++++++++++ ts_web/elements/index.ts | 1 + 2 files changed, 224 insertions(+) create mode 100644 ts_web/elements/dees-table.ts diff --git a/ts_web/elements/dees-table.ts b/ts_web/elements/dees-table.ts new file mode 100644 index 0000000..bbb002a --- /dev/null +++ b/ts_web/elements/dees-table.ts @@ -0,0 +1,223 @@ +import { + customElement, + html, + DeesElement, + property, + TemplateResult, + cssManager, + css, + unsafeCSS, +} from '@designestate/dees-element'; + +import * as domtools from '@designestate/dees-domtools'; + +declare global { + interface HTMLElementTagNameMap { + 'dees-table': DeesTable; + } +} + +@customElement('dees-table') +export class DeesTable extends DeesElement { + public static demo = () => html` + +
+ This is a slotted Text +
+ `; + + @property() + public heading1: string; + + @property() + public heading2: string; + + @property({ + type: Array + }) + public data: T[] = []; + + @property() + public selectedDataRow: T; + + @property({ + type: String, + }) + public type: 'normal' | 'highlighted' | 'discreet' | 'big' = 'normal'; + + @property({ + type: String, + }) + public status: 'normal' | 'pending' | 'success' | 'error' = 'normal'; + + constructor() { + super(); + } + + public static styles = [ + cssManager.defaultStyles, + css` + .mainbox { + color: #fff; + font-family: Roboto Mono; + padding: 20px; + display: block; + width: 100%; + min-height: 50px; + background: #393939; + border-radius: 3px; + } + .headingSeparation { + margin-top: 7px; + border-bottom: 1px solid #bcbcbc; + } + + table, + .noDataSet { + margin-top: 20px; + color: #fff; + border-collapse: collapse; + width: 100%; + } + .noDataSet { + text-align: center; + } + tr { + border-bottom: 1px dashed #808080; + text-align: left; + } + tr:last-child { + border-bottom: none; + text-align: left; + } + tr:hover { + cursor: pointer; + } + tr:hover .innerCellContainer { + background: #ffffff10; + } + tr:first-child:hover { + cursor: auto; + } + tr:first-child:hover .innerCellContainer { + background: none; + } + th { + text-transform: uppercase; + } + th, + td { + padding: 3px 0px; + border-right: 1px dashed #808080; + } + .innerCellContainer { + padding: 7px 10px; + } + th:first-child .innerCellContainer, + td:first-child .innerCellContainer { + padding-left: 0px; + } + th:last-child .innerCellContainer, + td:last-child .innerCellContainer { + padding-right: 0px; + } + th:last-child, + td:last-child { + border-right: none; + } + + .tableStatistics { + padding: 5px 20px; + font-size: 14px; + color: #ffffff90; + background: #00000050; + margin: 20px -20px -20px -20px; + } + `, + ]; + + public render(): TemplateResult { + return html` +
+ +
${this.heading1}
+
${this.heading2}
+
+ + + + ${this.data.length > 0 + ? (() => { + const headings: string[] = Object.keys(this.data[0]); + return html` + + + ${headings.map(headingArg => html` + + `)} + + ${this.data.map(itemArg => html` + + ${headings.map(headingArg => html` + + `)} + + `)} +
+
${headingArg}
+
+
${itemArg[headingArg]}
+
+ `; + })() + : html`
No data set!
`} +
+ ${this.data.length} data rows (total) | + ${this.selectedDataRow ? html`` : html`No row selected`} +
+
+ `; + } + + public async firstUpdated() {} +} diff --git a/ts_web/elements/index.ts b/ts_web/elements/index.ts index db00ec4..2f5b099 100644 --- a/ts_web/elements/index.ts +++ b/ts_web/elements/index.ts @@ -10,6 +10,7 @@ export * from './dees-input-radio'; export * from './dees-input-text'; export * from './dees-spinner'; export * from './dees-stepper'; +export * from './dees-table'; export * from './dees-toast'; export * from './dees-updater'; export * from './dees-windowlayer';