From fc5961ca428225cdd9925a9e682303d7cd449b6b Mon Sep 17 00:00:00 2001 From: Leon <> Date: Mon, 24 Jan 2022 12:37:08 +0200 Subject: [PATCH] table added --- ui/src/components/UI/Table.tsx | 74 +++++++++++++++++ ui/src/components/UI/style/Table.sass | 92 ++++++++++++++++++++++ ui/src/components/assets/dotted-circle.svg | 3 + ui/src/variables.module.scss | 2 + 4 files changed, 171 insertions(+) create mode 100644 ui/src/components/UI/Table.tsx create mode 100644 ui/src/components/UI/style/Table.sass create mode 100644 ui/src/components/assets/dotted-circle.svg diff --git a/ui/src/components/UI/Table.tsx b/ui/src/components/UI/Table.tsx new file mode 100644 index 000000000..e8506c7f5 --- /dev/null +++ b/ui/src/components/UI/Table.tsx @@ -0,0 +1,74 @@ +import React, {useEffect, useState} from "react"; +import './style/Table.sass'; +import editImg from "../assets/edit.svg"; +import deleteImg from "../assets/delete.svg" +import circleImg from "../assets/dotted-circle.svg" +import Delete from '@material-ui/icons/Delete'; +import Edit from '@material-ui/icons/Edit'; + + +interface Props { + rows : any[]; + cols : {field:string, cellClassName?: string,header:string, width?:number, + getCellClassName?:(field:string,value : any) => string}[]; + onRowEdit : (any) => void; + onRowDelete : (any) => void; + noDataMeesage : string; +} + +export const Table: React.FC = ({rows, cols, onRowDelete, onRowEdit,noDataMeesage}) => { + + const [tableRows, updateTableRows] = useState(rows); + + useEffect(() => { + updateTableRows(rows) + },[rows]) + + const _onRowEdit = (row) => { + onRowEdit(row) + } + + const _onRowDelete = (row) => { + onRowDelete(row); + } + return + + + {cols?.map((col)=> { + return + })} + + + + + { + ((tableRows == null) || (tableRows.length === 0)) ? + + No data Found +
{noDataMeesage}
+ + + : + + tableRows?.map(rowData => { + return + {cols.map(col => { + return + })} + + + }) + } + +
{col.header}
+ {rowData[col.field]} + + _onRowEdit(rowData)}> + + + _onRowDelete(rowData)}> + + +
+} \ No newline at end of file diff --git a/ui/src/components/UI/style/Table.sass b/ui/src/components/UI/style/Table.sass new file mode 100644 index 000000000..bcd4223f7 --- /dev/null +++ b/ui/src/components/UI/style/Table.sass @@ -0,0 +1,92 @@ +@import '../../../variables.module' + +.mui-table + width: 100% + margin-top: 20px + + &__tbody + max-height: calc(70vh - 355px) + overflow-y: auto + display: block + + &__th + color: $blue-gray + text-align: left + padding: 10px + + &__tr + border-bottom-width: 1px + border-bottom-color: $data-background-color + border-bottom-style: solid + display: table + table-layout: fixed + width: 100% + + &__no-data + display: flex; + justify-content: space-between; + flex-direction: column; + height: 95px; + overflow-y: auto; + margin: 2%; + align-items: center; + align-content: center; + padding-top: 3%; + padding-bottom: 3%; + + &-message + font-style: normal; + font-weight: 600; + font-size: 12px; + line-height: 15px; + color: $light-gray; + + &__tr:hover + background: #F7F9FC + + & .mui-table__row-actions + &--delete + cursor: pointer; + path + fill:#DB2156 + &--edit + cursor: pointer; + path + fill: $blue-color + + &__row-actions + display: flex + justify-content: flex-end + + + &__td + color: $light-gray + padding: 10px + font-size: 16px + +@mixin row-actions + display: flex + justify-content: flex-end + + +@mixin status-base($bg_color, $color, $border) + box-sizing: border-box + border-radius: 4px + height : 20px + width : 63px + display: flex + align-content: center + justify-content: center + align-items: center + background: $bg_color + color: $color + border: $border + +.status + &--active + @include status-base(rgba(111, 207, 151, 0.5), #247E4B, 1px solid #219653) + + &--pending + @include status-base(rgba(242, 201, 76, 0.5), #8C7325, 1px solid #F2994A) + + \ No newline at end of file diff --git a/ui/src/components/assets/dotted-circle.svg b/ui/src/components/assets/dotted-circle.svg new file mode 100644 index 000000000..2017acec3 --- /dev/null +++ b/ui/src/components/assets/dotted-circle.svg @@ -0,0 +1,3 @@ + + + diff --git a/ui/src/variables.module.scss b/ui/src/variables.module.scss index 8c9623ddb..1d97738cc 100644 --- a/ui/src/variables.module.scss +++ b/ui/src/variables.module.scss @@ -7,6 +7,8 @@ $blue-color: #205CF5; $light-blue-color: #BCCEFD; $success-color: #27AE60; $failure-color: #EB5757; + + $blue-gray: #494677; $light-gray: #8F9BB2;